From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: handle_exit_race && PF_EXITING Date: Tue, 5 Nov 2019 16:27:28 +0100 Message-ID: <20191105152728.GA5666@redhat.com> References: <20191104002909.25783-1-shawn@git.icu> <87woceslfs.fsf@oldenburg2.str.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org To: Thomas Gleixner Cc: Florian Weimer , Shawn Landden , libc-alpha@sourceware.org, linux-api@vger.kernel.org, LKML , Arnd Bergmann , Deepa Dinamani , Andrew Morton , Catalin Marinas , Keith Packard , Peter Zijlstra List-Id: linux-api@vger.kernel.org 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... =09#include =09#include =09#include =09#include =09#define FUTEX_LOCK_PI=09=096 =09int main(void) =09{ =09=09struct sched_param sp =3D {}; =09=09sp.sched_priority =3D 2; =09=09assert(sched_setscheduler(0, SCHED_FIFO, &sp) =3D=3D 0); =09=09int lock =3D vfork(); =09=09if (!lock) { =09=09=09sp.sched_priority =3D 1; =09=09=09assert(sched_setscheduler(0, SCHED_FIFO, &sp) =3D=3D 0); =09=09=09_exit(0); =09=09} =09=09syscall(__NR_futex, &lock, FUTEX_LOCK_PI, 0,0,0); =09=09return 0; =09} 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, unsigne= d int flags, =09=09=09 * exit to complete. =09=09=09 * - The user space value changed. =09=09=09 */ -=09=09=09queue_unlock(hb); -=09=09=09put_futex_key(&q.key); -=09=09=09cond_resched(); -=09=09=09goto retry; +=09=09=09if (!fatal_signal_pending(current)) { +=09=09=09=09queue_unlock(hb); +=09=09=09=09put_futex_key(&q.key); +=09=09=09=09cond_resched(); +=09=09=09=09goto retry; +=09=09=09} =09=09default: =09=09=09goto out_unlock_put_key; =09=09}