From: Peter Zijlstra <peterz@infradead.org>
To: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] wait-simple: Introduce the simple waitqueue implementation
Date: Thu, 12 Dec 2013 12:18:09 +0100 [thread overview]
Message-ID: <20131212111809.GF21999@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1386810399-8973-2-git-send-email-paul.gortmaker@windriver.com>
On Wed, Dec 11, 2013 at 08:06:37PM -0500, Paul Gortmaker wrote:
> +/*
> + * Event API
> + */
> +#define __swait_event(wq, condition) \
> +do { \
> + DEFINE_SWAITER(__wait); \
> + \
> + for (;;) { \
> + swait_prepare(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
> + if (condition) \
> + break; \
> + schedule(); \
> + } \
> + swait_finish(&wq, &__wait); \
> +} while (0)
> +
> +#define __swait_event_interruptible(wq, condition, ret) \
> +do { \
> + DEFINE_SWAITER(__wait); \
> + \
> + for (;;) { \
> + swait_prepare(&wq, &__wait, TASK_INTERRUPTIBLE); \
> + if (condition) \
> + break; \
> + if (signal_pending(current)) { \
> + ret = -ERESTARTSYS; \
> + break; \
> + } \
> + schedule(); \
> + } \
> + swait_finish(&wq, &__wait); \
> +} while (0)
> +
> +#define __swait_event_interruptible_timeout(wq, condition, ret) \
> +do { \
> + DEFINE_SWAITER(__wait); \
> + \
> + for (;;) { \
> + swait_prepare(&wq, &__wait, TASK_INTERRUPTIBLE); \
> + if (condition) \
> + break; \
> + if (signal_pending(current)) { \
> + ret = -ERESTARTSYS; \
> + break; \
> + } \
> + ret = schedule_timeout(ret); \
> + if (!ret) \
> + break; \
> + } \
> + swait_finish(&wq, &__wait); \
> +} while (0)
Urgh, please have a look at ___wait_event() we just killed all the
pointless replication for the normal waitqueues, please don't add more
of it.
> +unsigned int
> +__swake_up_locked(struct swait_queue_head *head, unsigned int state,
> + unsigned int num)
> +{
> + struct swaiter *curr, *next;
> + int woken = 0;
> +
> + list_for_each_entry_safe(curr, next, &head->task_list, node) {
> + if (wake_up_state(curr->task, state)) {
> + __swait_dequeue(curr);
> + /*
> + * The waiting task can free the waiter as
> + * soon as curr->task = NULL is written,
> + * without taking any locks. A memory barrier
> + * is required here to prevent the following
> + * store to curr->task from getting ahead of
> + * the dequeue operation.
> + */
> + smp_wmb();
> + curr->task = NULL;
> + if (++woken == num)
> + break;
> + }
> + }
> + return woken;
> +}
> +
> +unsigned int
> +__swake_up(struct swait_queue_head *head, unsigned int state, unsigned int num)
> +{
> + unsigned long flags;
> + int woken;
> +
> + if (!swaitqueue_active(head))
> + return 0;
> +
> + raw_spin_lock_irqsave(&head->lock, flags);
> + woken = __swake_up_locked(head, state, num);
> + raw_spin_unlock_irqrestore(&head->lock, flags);
> + return woken;
> +}
> +EXPORT_SYMBOL(__swake_up);
Urgh, fail. Do not put unbounded loops in raw_spin_lock.
I think I posted a patch a while back to cure this.
next prev parent reply other threads:[~2013-12-12 11:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 1:06 [PATCH 0/3] Introduce simple wait queues Paul Gortmaker
2013-12-12 1:06 ` [PATCH 1/3] wait-simple: Introduce the simple waitqueue implementation Paul Gortmaker
2013-12-12 1:58 ` Steven Rostedt
2013-12-12 2:09 ` Steven Rostedt
2013-12-12 8:03 ` Christoph Hellwig
2013-12-12 10:56 ` Thomas Gleixner
2013-12-12 14:48 ` Paul Gortmaker
2013-12-12 14:55 ` Steven Rostedt
2013-12-12 15:25 ` Thomas Gleixner
2013-12-12 15:44 ` Steven Rostedt
2013-12-12 15:30 ` Paul Gortmaker
2013-12-12 11:18 ` Peter Zijlstra [this message]
2013-12-12 11:20 ` Peter Zijlstra
2013-12-12 14:19 ` Paul Gortmaker
2013-12-12 16:17 ` Paul Gortmaker
2013-12-12 11:44 ` Peter Zijlstra
2013-12-12 14:42 ` Steven Rostedt
2013-12-12 16:03 ` Peter Zijlstra
2013-12-12 16:51 ` Steven Rostedt
2013-12-12 17:10 ` Steven Rostedt
2013-12-12 17:17 ` Peter Zijlstra
2013-12-12 1:06 ` [PATCH 2/3] sched/core: convert completions to use simple wait queues Paul Gortmaker
2013-12-12 1:06 ` [PATCH 3/3] rcu: use simple wait queues where possible in rcutree Paul Gortmaker
2013-12-12 3:42 ` Paul E. McKenney
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=20131212111809.GF21999@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.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
Powered by JetHome