Skip to contentSkip to conversation

[email protected]

DISCUSSION Manfred Spraul 2 participants 3 messages Oct 30, 2002

lore
Share & tools
lore
#0 lore raw

You are right, there is a race in pipelined_send, but slightly different than in your description:
pipelined_send is carefull not to read the msr pointer after wake_up_process, but it does rely on the contents of the msr structure after setting msr->r_msg.

I.e. the description is

CPU 1 CPU 2

sys_msgrcv()
(sleeps for messsage)

sys_msgsnd() pipelined_send()
(woken up by a signal)
Notices that a message is there,
accepts the message and exists.
stack trashed, perhaps even task structure gone.
wake_up_process(msr->r_tsk) *oops - msr is not valid anymore.

Is that possible? Do you apps use signals?

Your fix solves the problem, but I'd prefer to keep the current, lockless receive path - it avoids 50% of the spinlock operations. I'll write a patch that adds the missing memory barriers and copies the fields before setting msr->r_msg.

--
Manfred

#1 lore raw
Quoted 6 lines · Manfred Spraul

You are right, there is a race in pipelined_send, but slightly different than in your description:
pipelined_send is carefull not to read the msr pointer after wake_up_process, but it does rely on the contents of the msr structure after setting msr->r_msg.

Quoted 6 lines

Is that possible? Do you apps use signals?

Your fix solves the problem, but I'd prefer to keep the current, lockless receive path - it avoids 50% of the spinlock operations. I'll write a patch that adds the missing memory barriers and copies the fields before setting msr->r_msg.

Don't know about his, my app does, it's only a benchmark, but I do see bad behaviour from time to time (total lockups) on SMP machines.

Signature · 3 lines
bill davidsen <[email protected]>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
#2 lore raw

Re: [PATCH] IPC SMP race: msgrcv may not return before msgsnd is done

[subject line switched back, sorry for the wrong line]

Quoted 5 lines · Bill Davidsen

Don't know about his, my app does, it's only a benchmark, but I do see bad behaviour from time to time (total lockups) on SMP machines.

Could you try Bernhard's patch? Lockless receive is nice, but fixing the found race would be really tricky, and is probably not worth the effort.

--
Manfred