Re: [PATCH v2 1/2] sched/wait: Add wait_threshold
From: Pavel Begunkov <asml.silence@gmail.com>
Date: 2019-09-23 16:37:58
Also in:
lkml
Just in case duplicating a mail from the cover-letter thread: It could be done with @cond indeed, that's how it works for now. However, this addresses performance issues only. The problem with wait_event_*() is that, if we have a counter and are trying to wake up tasks after each increment, it would schedule each waiting task O(threshold) times just for it to spuriously check @cond and go back to sleep. All that overhead (memory barriers, registers save/load, accounting, etc) turned out to be enough for some workloads to slow down the system. With this specialisation it still traverses a wait list and makes indirect calls to the checker callback, but the list supposedly is fairly small, so performance there shouldn't be a problem, at least for now. Regarding semantics; It should wake a task when a value passed to wake_up_threshold() is greater or equal then a task's threshold, that is specified individually for each task in wait_threshold_*(). In pseudo code:
def wake_up_threshold(n, wait_queue):
for waiter in wait_queue:
waiter.wake_up_if(n >= waiter.threshold);
Any thoughts how to do it better? Ideas are very welcome. BTW, this monster is mostly a copy-paste from wait_event_*(), wait_bit_*(). We could try to extract some common parts from these three, but that's another topic. On 23/09/2019 10:19, Peter Zijlstra wrote:
On Sun, Sep 22, 2019 at 11:08:50AM +0300, Pavel Begunkov (Silence) wrote:quoted
From: Pavel Begunkov <asml.silence@gmail.com> Add wait_threshold -- a custom wait_event derivative, that waits until a value is equal to or greater than the specified threshold.This is quite insufficient justification for this monster... what exact semantics do you want? Why can't you do this exact same with a slightly more complicated @cond ?
-- Yours sincerely, Pavel Begunkov
Attachments
- signature.asc [application/pgp-signature] 833 bytes