Re: [PATCH -rt] ipc/sem: Rework semaphore wakeups
From: Manfred Spraul <hidden>
Date: 2011-09-14 18:42:23
Also in:
lkml
Attachments
- patch-rt-sem [text/plain] 1204 bytes · preview
From: Manfred Spraul <hidden>
Date: 2011-09-14 18:42:23
Also in:
lkml
On 09/14/2011 11:57 AM, Peter Zijlstra wrote:
Subject: ipc/sem: Rework semaphore wakeups From: Peter Zijlstra<redacted> Date: Tue Sep 13 15:09:40 CEST 2011 Current sysv sems have a weird ass wakeup scheme that involves keeping preemption disabled over a potential O(n^2) loop and busy waiting on that on other CPUs.
Have you checked that the patch improves the latency?
Note that the busy wait only happens if there is a simultaneous timeout
of a semtimedop() and a true wakeup.
The code does:
spin_lock()
preempt_disable();
usually_very_simple_but_worstcase_O_2
spin_unlock()
usually_very_simple_but_worstcase_O_1
preempt_enable();
with your change, it becomes:
spin_lock()
usually_very_simple_but_worstcase_O_2
usually_very_simple_but_worstcase_O_1
spin_unlock()
The complex ops remain unchanged, they are still under a lock.
What about removing the preempt_disable?
It's only there to cover a rare race on uniprocessor preempt systems.
(a task is woken up simultaneously due to timeout of semtimedop() and a
true wakeup)
Then fix the that race - something like the attached patch [obviously
buggy - see the fixme]
--
Manfred