Messages in this thread | | | Subject | Re: [PATCH 2/2] irq_work: Fix racy IRQ_WORK_BUSY flag setting | From | Steven Rostedt <> | Date | Tue, 30 Oct 2012 14:45:52 -0400 |
| |
On Wed, 2012-10-31 at 03:33 +0900, anish kumar wrote:
> > CPU 0 CPU 1 > > > > data = something flags = IRQ_WORK_BUSY > > smp_mb() (implicit with cmpxchg smp_mb() > > on flags in claim) execute_work (sees data from CPU > > 0) > > try to claim > > > As I understand without the memory barrier proposed by you the situation > would be as below: > CPU 0 CPU 1 > > data = something flags = IRQ_WORK_BUSY > smp_mb() (implicit with cmpxchg execute_work (sees data from CPU 0) > on flags in claim) > _success_ in claiming and goes
Correct, because it would see the stale value of flags.
> ahead and execute the work(wrong?) > cmpxchg cause flag to IRQ_WORK_BUSY > > Now knows the flag==IRQ_WORK_BUSY > > Am I right?
right.
> > Probably a stupid question.Why do we return the bool from irq_work_queue > when no one bothers to check the return value?Wouldn't it be better if > this function is void as used by the users of this function or am I > looking at the wrong code.
Not a stupid question, as I was asking that to myself just earlier today. But forgot to mention it as well. Especially, because it makes it look like there's a bug in the code. Maybe someday someone will care if their work was finished by itself, or some other CPU.
Probably should just nix the return value.
-- Steve
| |