Re: for review: sys/dev/md/md.c patch



On Mon, Jan 30, 2006 at 01:12:49PM +0100, Oliver Fromme wrote:
> Luigi Rizzo <rizzo@xxxxxxxx> wrote:
> > just discovered, trying to resurrect picobsd on -current,
> > that the compiler in 6.x/7.x has become smart and, at least
> > with the default compilation flags, will optimize out
> > the "end_mfs_root" string from the object.
>
> Shouldn't it be sufficient to declare the string as volatile?
> That should prevent it from being optimized by the compiler.

maybe.
but packing both into the same struct also solves the issue
of compiler potentially rearranging the variables in memory,
and since we want them contiguous, the approach i suggested is
probably more appropriate (with compilers becoming smarter
and smarter, that is...)

cheers
luigi

> (I'm not questioning your solution, mind you. I just wonder
> if "volatile" would do the job. So far I've used volatile
> for things like sig_atomic_t only.)
>
> Best regards
> Oliver
>
> --
> Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
> Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
> Any opinions expressed in this message may be personal to the author
> and may not necessarily reflect the opinions of secnetix in any way.
>
> "When your hammer is C++, everything begins to look like a thumb."
> -- Steve Haflich, in comp.lang.c++
> _______________________________________________
> freebsd-current@xxxxxxxxxxx mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Is the following code MT-Safe?
    ... the assert (which is a fundamental design error: ... and almost always leads to either major synchronization failures ... >Does _bRunning need to be tagged as volatile? ... compiler to cache values, but only during the execution of a function; ...
    (microsoft.public.vc.mfc)
  • Re: Volatile + multithreading
    ... The volatile keyword has little use in multithreaded programming. ... > field or global seems to have no impact because it seems the compiler will ... operations as "special" and suppress optimizations around them. ... > majority of the multithreading issues that could have resulted from ...
    (microsoft.public.vc.language)
  • Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures
    ... If I could trust atomic_read/atomic_setto cause the compiler ... as you've explained it below) -- neither w.r.t. CPU re-ordering (which ... You are correct about CPU re-ordering (and about the fact that this ... The compiler is prohibited from moving a volatile access across a sequence ...
    (Linux-Kernel)
  • Re: Is the following code MT-Safe?
    ... >>Explanation follows code example, MFC synchronization objects used ... > the first thread to resume, which then takes the assert. ... > volatile is unrelated to synchronization. ... > compiler to cache values, but only during the execution of a function; ...
    (microsoft.public.vc.mfc)
  • Re: Share .cpp and .h along projects
    ... pvector = InterlockedExchangePointerAcquire(&g_sharedVector, ... I really would like to hear what you think volatile accomplishes ... You can't require people to use volatile on top of synchronization. ... compiler useful for multithreaded programming. ...
    (microsoft.public.vc.language)