From: Peter Zijlstra <peterz@infradead.org>
To: Peng Tao <bergwolf@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Oleg Drokin <oleg.drokin@intel.com>,
Andreas Dilger <andreas.dilger@intel.com>,
Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH RFC] sched: introduce add_wait_queue_exclusive_head
Date: Tue, 18 Mar 2014 14:33:31 +0100 [thread overview]
Message-ID: <20140318133331.GA23193@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <1395148208-2209-1-git-send-email-bergwolf@gmail.com>
On Tue, Mar 18, 2014 at 09:10:08PM +0800, Peng Tao wrote:
> Normally wait_queue_t is a FIFO list for exclusive waiting tasks.
> As a side effect, if there are many threads waiting on the same
> condition (which is common for data servers like Lustre), all
> threads will be waken up again and again, causing unnecessary cache
> line polution. Instead of FIFO lists, we can use LIFO lists to always
> wake up the most recent active threads.
>
> Lustre implements this add_wait_queue_exclusive_head() privately but we
> think it might be useful as a generic function. With it being moved to
> generic layer, the rest of Lustre private wrappers for wait queue can be
> all removed.
>
> Of course there is an alternative approach to just open code it but we'd
> like to ask first to see if there is objection to making it generic.
OK, so I don't particularly mind LIFO, but there are a few problems with
the patch.
Firstly I think the _head postfix for LIFO is a bad name, and secondly,
and most important, this breaks __wake_up_common().
So waitqueue wakeups are specified as waking all !exclusive tasks and @n
exclusive tasks. The way this works is that !exclusive tasks are added
to the head (LIFO) and exclusive tasks are added to the tail
(FIFO).
We can then iterate the list until @n exclusive tasks have been
observed.
However if you start adding exclusive tasks to the head this all comes
apart.
If you don't mix exclusive and !exclusive tasks on the same waitqueue
this isn't a problem, but I'm sure people will eventually do this and
get a nasty surprise.
I'm not sure what the best way around this would be; but I can see two
options:
- add enough debugging bits to detect this fail case.
- extend wait_queue_head_t to keep a pointer to the first !exclusive
element and insert exclusive LIFO tasks there -- thereby keeping
!exclusive tasks at the front.
Anybody?
next prev parent reply other threads:[~2014-03-18 13:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-18 13:10 [PATCH RFC] sched: introduce add_wait_queue_exclusive_head Peng Tao
2014-03-18 13:33 ` Peter Zijlstra [this message]
2014-03-18 13:51 ` Peng Tao
2014-03-18 14:05 ` Peter Zijlstra
2014-03-18 14:44 ` Peng Tao
2014-03-18 16:23 ` Oleg Nesterov
2014-03-19 2:22 ` Peng Tao
2014-03-19 17:33 ` Oleg Nesterov
2014-03-19 19:44 ` Dilger, Andreas
2014-03-19 19:55 ` Peter Zijlstra
2014-03-20 7:06 ` Dilger, Andreas
2014-03-20 18:49 ` Oleg Nesterov
2014-03-18 15:47 ` Oleg Nesterov
2014-03-19 2:17 ` Peng Tao
[not found] ` <20140319164907.GA10113@redhat.com>
2014-03-19 16:57 ` Peter Zijlstra
2014-03-19 17:19 ` Oleg Nesterov
2014-03-20 17:51 ` [PATCH 0/2] wait: introduce WQ_FLAG_EXCLUSIVE_HEAD Oleg Nesterov
2014-03-20 17:51 ` [PATCH 1/2] wait: turn "bool exclusive" arg of __wait_event() into wflags Oleg Nesterov
2014-03-20 17:51 ` [PATCH 2/2] wait: introduce WQ_FLAG_EXCLUSIVE_HEAD Oleg Nesterov
2014-03-21 2:45 ` [PATCH 0/2] " Dilger, Andreas
2014-03-21 18:49 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140318133331.GA23193@laptop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=andreas.dilger@intel.com \
--cc=bergwolf@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg.drokin@intel.com \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox