Re: Do not misuse Coverity please (Was: sound/oss/cs46xx.c: fix a check after use)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jean Delvare wrote:

Wow. Great point. I completely missed that possibility. In fact I didn't
know that the compiler could possibly alter the order of the
instructions. For one thing, I thought it was simply not allowed to. For
another, I didn't know that it had been made so aware that it could
actually figure out how to do this kind of things. What a mess. Let's
just hope that the gcc folks know their business :)

I'll try to remember this next time I debug something. Do not assume
that instructions are run in the order seen in the source. Irk.

It gets better, in that the cpus themselves can reorder instructions. This becomes interesting when dealing with memory being shared between multiple cpus on SMP machines. Either you need to use existing locking primitives which enforce ordering or else you need to use explicit cpu-level ordering instructions to ensure that data gets written/read in the expected order. (See "mb" and friends in the kernel code.)

Then you get into potential caching issues with memory mapped at different addresses on cpus with VIVT caches, and that introduces more issues.

Computers are perfectly predictable, as long as you understand exactly what you've told them to do...

Chris
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux