From: Oleg Nesterov <oleg@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Florian Weimer <fweimer@redhat.com>,
Shawn Landden <shawn@git.icu>,
libc-alpha@sourceware.org, linux-api@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Deepa Dinamani <deepa.kernel@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Keith Packard <keithp@keithp.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: handle_exit_race && PF_EXITING
Date: Tue, 5 Nov 2019 16:27:28 +0100 [thread overview]
Message-ID: <20191105152728.GA5666@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1911051053470.17054@nanos.tec.linutronix.de>
On 11/05, Thomas Gleixner wrote:
>
> Out of curiosity, what's the race issue vs. robust list which you are
> trying to solve?
Off-topic, but this reminds me...
#include <sched.h>
#include <assert.h>
#include <unistd.h>
#include <syscall.h>
#define FUTEX_LOCK_PI 6
int main(void)
{
struct sched_param sp = {};
sp.sched_priority = 2;
assert(sched_setscheduler(0, SCHED_FIFO, &sp) == 0);
int lock = vfork();
if (!lock) {
sp.sched_priority = 1;
assert(sched_setscheduler(0, SCHED_FIFO, &sp) == 0);
_exit(0);
}
syscall(__NR_futex, &lock, FUTEX_LOCK_PI, 0,0,0);
return 0;
}
this creates the unkillable RT process spinning in futex_lock_pi() on
a single CPU machine (or you can use taskset).
Probably the patch below makes sense anyway, but of course it doesn't
solve the real problem: futex_lock_pi() should not spin in this case.
It seems to me I even sent the fix a long ago, but I can't recall what
exactly it did. Probably the PF_EXITING check in attach_to_pi_owner()
must simply die, I'll try to recall...
Oleg.
--- x/kernel/futex.c
+++ x/kernel/futex.c
@@ -2842,10 +2842,12 @@ static int futex_lock_pi(u32 __user *uaddr, unsigned int flags,
* exit to complete.
* - The user space value changed.
*/
- queue_unlock(hb);
- put_futex_key(&q.key);
- cond_resched();
- goto retry;
+ if (!fatal_signal_pending(current)) {
+ queue_unlock(hb);
+ put_futex_key(&q.key);
+ cond_resched();
+ goto retry;
+ }
default:
goto out_unlock_put_key;
}
next prev parent reply other threads:[~2019-11-05 15:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-04 0:29 [RFC v2 PATCH] futex: extend set_robust_list to allow 2 locking ABIs at the same time Shawn Landden
2019-11-04 0:51 ` Shawn Landden
2019-11-04 15:37 ` Thomas Gleixner
2019-11-05 0:10 ` Thomas Gleixner
2019-11-05 9:48 ` Florian Weimer
2019-11-05 9:59 ` Thomas Gleixner
2019-11-05 10:06 ` Florian Weimer
2019-11-05 11:56 ` Thomas Gleixner
2019-11-05 14:10 ` Carlos O'Donell
2019-11-05 14:27 ` Florian Weimer
2019-11-05 14:53 ` Thomas Gleixner
2019-11-05 14:27 ` Thomas Gleixner
2019-11-05 14:33 ` Florian Weimer
2019-11-05 14:48 ` Thomas Gleixner
2019-11-06 14:00 ` Zack Weinberg
2019-11-06 14:04 ` Florian Weimer
2019-11-05 15:27 ` Oleg Nesterov [this message]
2019-11-05 17:28 ` handle_exit_race && PF_EXITING Thomas Gleixner
2019-11-05 17:59 ` Thomas Gleixner
2019-11-05 18:56 ` Thomas Gleixner
2019-11-05 19:19 ` Thomas Gleixner
2019-11-06 8:55 ` Oleg Nesterov
2019-11-06 9:53 ` Thomas Gleixner
2019-11-06 10:35 ` Oleg Nesterov
2019-11-06 11:07 ` Thomas Gleixner
2019-11-06 12:11 ` Oleg Nesterov
2019-11-06 13:38 ` Thomas Gleixner
2019-11-06 17:42 ` Thomas Gleixner
2019-11-07 15:51 ` 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=20191105152728.GA5666@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=deepa.kernel@gmail.com \
--cc=fweimer@redhat.com \
--cc=keithp@keithp.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=shawn@git.icu \
--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;
as well as URLs for NNTP newsgroup(s).