Re: [PATCH 3/3] posix timers: use SIGQUEUE_CANCELLED when the timer is destroyed

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Oleg Nesterov <oleg@...>
Cc: Andrew Morton <akpm@...>, Austin Clements <amdragon+kernelbugzilla@...>, Ingo Molnar <mingo@...>, john stultz <johnstul@...>, Michael Kerrisk <mtk.manpages@...>, Roland McGrath <roland@...>, Thomas Gleixner <tglx@...>, <linux-kernel@...>
Date: Sunday, May 18, 2008 - 1:24 pm

On Sun, 18 May 2008, Oleg Nesterov wrote:

Oh, and the above is *wrong*.

Why?

Becayse if SIGQUEUE_PREALLOC setting needs the lock, then setting any 
*other* bit in that word will also need the lock!

That's because

	q->flags |= SIGQUEUE_CANCELLED;

writes those other bits too - admittedly with the value they were read 
just before, but if it races with something setting SIGQUEUE_PREALLOC that 
doesn't matter - the newly written version will simply be wrong.

So the rule is that if one bit of a word needs locking, then they *all* 
do.

(On alpha, this is true even for whole bytes or shortwords - because a 
byte/shortword write is actually "read word, update byte/short, write 
word" sequence on older CPU's. So you cannot do atomic byte updates, and 
need to use locks).

			Linus
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 3/3] posix timers: use SIGQUEUE_CANCELLED when th..., Linus Torvalds, (Sun May 18, 1:24 pm)