[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151026141949.GA26372@fixme-laptop.cn.ibm.com>
Date: Mon, 26 Oct 2015 22:19:49 +0800
From: Boqun Feng <boqun.feng@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Daniel Wagner <daniel.wagner@...-carit.de>,
linux-kernel@...r.kernel.org, linux-rt-users@...r.kernel.org,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
Paolo Bonzini <pbonzini@...hat.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait)
implementation
On Mon, Oct 26, 2015 at 02:26:01PM +0100, Peter Zijlstra wrote:
> On Mon, Oct 26, 2015 at 01:59:44PM +0100, Daniel Wagner wrote:
> > Hi Boqun,
> >
> > On 10/26/2015 01:04 PM, Boqun Feng wrote:
> > > On Tue, Oct 20, 2015 at 09:28:07AM +0200, Daniel Wagner wrote:
> > >> +
> > >> +/*
> > >> + * The thing about the wake_up_state() return value; I think we can ignore it.
> > >> + *
> > >> + * If for some reason it would return 0, that means the previously waiting
> > >> + * task is already running, so it will observe condition true (or has already).
> > >> + */
> > >> +void swake_up_locked(struct swait_queue_head *q)
> > >> +{
> > >> + struct swait_queue *curr;
> > >> +
> > >> + list_for_each_entry(curr, &q->task_list, task_list) {
> > >> + wake_up_process(curr->task);
> > >> + list_del_init(&curr->task_list);
> > >> + break;
> > >
> > > Just be curious, what's this break for? Or what's this loop(?) for?
> >
> > I have to guess here, since Peter wrote it. It looks like the function
> > is based on __wake_up_common(). Though I agree the loop is not necessary
> > and something like below should the trick. Unless I do not see something
> > important.
> >
> > void swake_up_locked(struct swait_queue_head *q)
> > {
> > struct swait_queue *curr;
> >
> > if (list_emtpy(&q))
> > return;
> >
> > curr = list_first_entry(&q, typeof(*curr), task_list);
> > wake_up_process(curr->task);
> > list_del_init(&curr->task_list);
> > }
> >
> > If Peter is not complaining I change swake_up_locked() for the next version.
This gains better readability, I think ;-)
>
> Yes, that is equivalent, just more code. As I wrote in my last email; I
> was lazy :-)
;-)
Maybe introduce a list_pick_one_if_any() macro for convenience:
#define list_pick_one_if_any(pos, list, member) \
if (!list_empty(list) && (pos = list_first_entry(list, typeof(*pos), member), 1))
then
void swake_up_locked(struct swait_queue_head *q)
{
struct swait_queue *curr;
list_pick_one_if_any(curr, q->task_list, task_list) {
wake_up_process(curr->task);
list_del_init(&curr->task_list);
}
}
Anyway, thank you both for going through this.
Regards,
Boqun
Download attachment "signature.asc" of type "application/pgp-signature" (474 bytes)
Powered by blists - more mailing lists