mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Daniel Wagner <daniel.wagner@bmw-carit.de>,
	linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait) implementation
Date: Mon, 26 Oct 2015 22:19:49 +0800	[thread overview]
Message-ID: <20151026141949.GA26372@fixme-laptop.cn.ibm.com> (raw)
In-Reply-To: <20151026132601.GV2508@worktop.programming.kicks-ass.net>

[-- Attachment #1: Type: text/plain, Size: 2249 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-10-26 14:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20  7:28 [PATCH v3 0/4] Simple wait queue support Daniel Wagner
2015-10-20  7:28 ` [PATCH v3 1/4] wait.[ch]: Introduce the simple waitqueue (swait) implementation Daniel Wagner
2015-10-26 12:04   ` Boqun Feng
2015-10-26 12:28     ` Peter Zijlstra
2015-10-26 12:59     ` Daniel Wagner
2015-10-26 13:26       ` Peter Zijlstra
2015-10-26 14:19         ` Boqun Feng [this message]
2015-11-04 10:33   ` Thomas Gleixner
2015-11-04 12:12     ` Daniel Wagner
2015-11-18 10:33     ` Peter Zijlstra
2015-11-18 15:07       ` Thomas Gleixner
2015-10-20  7:28 ` [PATCH v3 2/4] KVM: use simple waitqueue for vcpu->wq Daniel Wagner
2015-10-20 13:11   ` Paolo Bonzini
2015-10-20 14:00   ` Peter Zijlstra
2015-10-20 15:40     ` Paolo Bonzini
2015-10-20 16:06       ` Peter Zijlstra
2015-10-21  8:55     ` Paul Mackerras
2015-10-21  9:05       ` Peter Zijlstra
2015-10-21  9:10     ` Paul Mackerras
2015-10-21  9:24     ` Paul Mackerras
2015-10-21 11:13       ` Peter Zijlstra
2015-10-23 11:51         ` Daniel Wagner
2015-10-20  7:28 ` [PATCH v3 3/4] rcu: Do not call rcu_nocb_gp_cleanup() while holding rnp->lock Daniel Wagner
2015-10-20  7:28 ` [PATCH v3 4/4] rcu: use simple wait queues where possible in rcutree Daniel Wagner
2015-10-25 20:10 ` [PATCH v3 0/4] Simple wait queue support Paul E. McKenney
2015-10-26  6:34   ` Daniel Wagner

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=20151026141949.GA26372@fixme-laptop.cn.ibm.com \
    --to=boqun.feng@gmail.com \
    --cc=daniel.wagner@bmw-carit.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®