From: Manfred Spraul <manfred@colorfullife.com>
To: Mike Galbraith <bitbucket@online.de>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH RT] rt,ipc,sem: fix -rt livelock
Date: Wed, 11 Sep 2013 16:03:00 +0200 [thread overview]
Message-ID: <52307814.4020104@colorfullife.com> (raw)
In-Reply-To: <1378794614.6046.37.camel@marge.simpson.net>
Hi Mike,
On 09/10/2013 08:30 AM, Mike Galbraith wrote:
>
> You can kill this particular (osim induced) livelock by using Manfred's
> completion wakeup scheme. It may not make it all better, but it does
> eliminate this trigger, despite that not being what the patch is about.
[snip]
> +#elif defined(SYSVSEM_CUSTOM)
> + struct queue_done {
> + atomic_t done;
> + };
> +
> + static void queuewakeup_prepare(void)
> + {
> + preempt_disable();
> + }
> +
> + static void queuewakeup_completed(void)
> + {
> + preempt_enable();
> + }
> +
> + static void queuewakeup_handsoff(struct queue_done *qd)
> + {
> + BUG_ON(atomic_read(&qd->done) != 2);
> + smp_mb();
> + atomic_set(&qd->done, 1);
> + }
> +
> + static void queuewakeup_init(struct queue_done *qd)
> + {
> + atomic_set(&qd->done, 2);
> + }
> +
> + static void queuewakeup_wait(struct queue_done *qd)
> + {
> + while (atomic_read(&qd->done) != 1)
> + cpu_relax();
> +
> + smp_mb();
> + }
Two remarks:
- The reason why a standard waitqueue is not used should be mentioned in
the commit comment:
A standard wait queue that waits with a timeout (or with
TASK_INTERRUPTIBLE) doesn't allow the caller of add_wait_queue to figure
out if the thread was woken up to due expiry of the timer or due to an
explicit wake_up() call.
a) The ipc code must know that in order to decide if the task must
return with -EAGAIN/-EINTR or with 0. Therefore ipc/sem.c, ipc/msg.c and
ipc/mqueue.c use custom queues.
b) These custom queues have a lockless fast-path for a successful
operation - and this fast path must handle the various races that may
happen the timer expires in parallel with a wake_up() call.
- the ipc/msg.c and ipc/mqueue.c should be converted as well (just
search for cpu_relax()).
--
Manfred
next prev parent reply other threads:[~2013-09-11 14:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-19 21:33 [PATCH RT 0/3] hwlat-detector: Have it actually find hardware latency Steven Rostedt
2013-08-19 21:33 ` [PATCH RT 1/3] hwlat-detector: Update hwlat_detector to add outer loop detection Steven Rostedt
2013-08-19 21:33 ` [PATCH RT 2/3] hwlat-detector: Use trace_clock_local if available Steven Rostedt
2013-08-19 21:33 ` [PATCH RT 3/3] hwlat-detector: Use thread instead of stop machine Steven Rostedt
2013-08-21 15:59 ` [PATCH RT 0/3] hwlat-detector: Have it actually find hardware latency Sebastian Andrzej Siewior
2013-08-30 5:57 ` [PATCH RT] hwlat-detector: Don't ignore threshold module parameter Mike Galbraith
2013-08-30 14:39 ` [PATCH RT] rt,ipc,sem: fix -rt livelock Mike Galbraith
2013-08-31 5:27 ` Mike Galbraith
2013-09-06 7:08 ` Mike Galbraith
2013-09-10 6:30 ` Mike Galbraith
2013-09-11 14:03 ` Manfred Spraul [this message]
2013-09-12 7:40 ` Mike Galbraith
2013-09-12 19:15 ` Steven Rostedt
2013-09-13 3:20 ` Mike Galbraith
2013-09-13 3:33 ` Steven Rostedt
2013-09-13 4:48 ` Mike Galbraith
2013-09-13 4:36 ` Mike Galbraith
2013-09-13 12:56 ` Mike Galbraith
2013-09-12 18:23 ` [PATCH RT] hwlat-detector: Don't ignore threshold module parameter Steven Rostedt
2013-10-04 10:30 ` Sebastian Andrzej Siewior
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=52307814.4020104@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=a.p.zijlstra@chello.nl \
--cc=bigeasy@linutronix.de \
--cc=bitbucket@online.de \
--cc=linux-rt-users@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.