Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3615585imu; Mon, 28 Jan 2019 07:54:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN625yGft+ouhkIxqefL0r1SGbZbawl2bo0WGDThBVF35OJngu2VOq1IOtLwMuZwE+toxNCm X-Received: by 2002:a17:902:d911:: with SMTP id c17mr22957676plz.151.1548690882117; Mon, 28 Jan 2019 07:54:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548690882; cv=none; d=google.com; s=arc-20160816; b=Xhl1HMjxSnBOJIEUkuAREbCUlfeOP8sDaZZ+t6sZkIyq+LiZxxIAosgTKI+uE0JfFb OAiesT8hCLYxoDppqBG5CmB6wc9n5IBueTLdv8uml8XdhwJIjLwMFlfvGnmGK2RtcKeE f+L3MODL1i3aNHDa71uy07XQcg0gQGe9ohpRQO5hHZanMu1uGMgwBAgv8zTSKfJWwbWq pIotdNJfsUa7/+dtJKJVaz9d23bAQi4FU5A6SuQ8Dhve7dT1BdacKeps+TjBay0L9xmZ W5weGRlvqRybl+UkwYsjpdkydah9ykhfQvm2nf0G3X3yCzTsEIdLMrM8WiacdeJjxrVn pcAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=ZkI0ghpCD9NXvtTIEsyRD/5P5gsYME7CVqa4Bb3kOn4=; b=deqeEFaMG/dUqtfhHHJm4dYNtMTZIN7G/1uLYzS9u4DdnL4Jl8hfJ7L6kBz7nPICLZ 5wF8nRVGCwvOOzsevN5it0xDPEEoFXFffhxfO994I12Iaof8sdkLrDKQGwga9k+Z2X/c lsaTa3l8xJ8EqKX8tnepiWKkeQ3iTOsv+/1JJIUpGoOU9iDX7vUwGPcU9SGg0+DKA+hK sxePz1JK7Zwa0XIidgaNMUetfujUtDir5t02bWuZb7OTA6ttpJj6ph9ZqD0PxO7gXlCI gUBdLKxihjlh5lBI1TFMnmiV23MI5LRTJ1OwEXZUc8do2IUMBuHBxeWlYGqjrmBa9wL1 0q3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20si7534975pfk.125.2019.01.28.07.54.26; Mon, 28 Jan 2019 07:54:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729488AbfA1Pxh (ORCPT + 99 others); Mon, 28 Jan 2019 10:53:37 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:42479 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729082AbfA1Pxd (ORCPT ); Mon, 28 Jan 2019 10:53:33 -0500 Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1go9Dy-0003sj-Om; Mon, 28 Jan 2019 16:53:26 +0100 Date: Mon, 28 Jan 2019 16:53:19 +0100 (CET) From: Thomas Gleixner To: Peter Zijlstra cc: Heiko Carstens , Ingo Molnar , Martin Schwidefsky , LKML , linux-s390@vger.kernel.org, Stefan Liebler , Sebastian Sewior Subject: Re: WARN_ON_ONCE(!new_owner) within wake_futex_pi() triggered In-Reply-To: <20190128135804.GB28878@hirez.programming.kicks-ass.net> Message-ID: References: <20181127081115.GB3625@osiris> <20181129112321.GB3449@osiris> <20190128134410.GA28485@hirez.programming.kicks-ass.net> <20190128135804.GB28878@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Jan 2019, Peter Zijlstra wrote: > On Mon, Jan 28, 2019 at 02:44:10PM +0100, Peter Zijlstra wrote: > > On Thu, Nov 29, 2018 at 12:23:21PM +0100, Heiko Carstens wrote: > > > > > And indeed, if I run only this test case in an endless loop and do > > > some parallel work (like kernel compile) it currently seems to be > > > possible to reproduce the warning: > > > > > > while true; do time ./testrun.sh nptl/tst-robustpi8 --direct ; done > > > > > > within the build directory of glibc (2.28). > > > > Right; so that reproduces for me. > > > > After staring at all that for a while; trying to remember how it all > > worked (or supposed to work rather), I became suspiscous of commit: > > > > 56222b212e8e ("futex: Drop hb->lock before enqueueing on the rtmutex") > > > > And indeed, when I revert that; the above reproducer no longer works (as > > in, it no longer triggers in minutes and has -- so far -- held up for an > > hour+ or so). Right after staring long enough at it, the commit simply forgot to give __rt_mutex_start_proxy_lock() the same treatment as it gave to rt_mutex_wait_proxy_lock(). Patch below cures that. Thanks, tglx 8<---------------- --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2845,7 +2845,7 @@ static int futex_lock_pi(u32 __user *uad ret = rt_mutex_futex_trylock(&q.pi_state->pi_mutex); /* Fixup the trylock return value: */ ret = ret ? 0 : -EWOULDBLOCK; - goto no_block; + goto cleanup; } rt_mutex_init_waiter(&rt_waiter); @@ -2870,17 +2870,15 @@ static int futex_lock_pi(u32 __user *uad if (ret) { if (ret == 1) ret = 0; - - spin_lock(q.lock_ptr); goto no_block; } - if (unlikely(to)) hrtimer_start_expires(&to->timer, HRTIMER_MODE_ABS); ret = rt_mutex_wait_proxy_lock(&q.pi_state->pi_mutex, to, &rt_waiter); +no_block: spin_lock(q.lock_ptr); /* * If we failed to acquire the lock (signal/timeout), we must @@ -2894,7 +2892,7 @@ static int futex_lock_pi(u32 __user *uad if (ret && !rt_mutex_cleanup_proxy_lock(&q.pi_state->pi_mutex, &rt_waiter)) ret = 0; -no_block: +cleanup: /* * Fixup the pi_state owner and possibly acquire the lock if we * haven't already. --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1749,9 +1749,6 @@ int __rt_mutex_start_proxy_lock(struct r ret = 0; } - if (unlikely(ret)) - remove_waiter(lock, waiter); - debug_rt_mutex_print_deadlock(waiter); return ret; @@ -1778,6 +1775,8 @@ int rt_mutex_start_proxy_lock(struct rt_ raw_spin_lock_irq(&lock->wait_lock); ret = __rt_mutex_start_proxy_lock(lock, waiter, task); + if (unlikely(ret)) + remove_waiter(lock, waiter); raw_spin_unlock_irq(&lock->wait_lock); return ret;