From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA6DDC07E95 for ; Tue, 13 Jul 2021 16:15:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2FBC611AC for ; Tue, 13 Jul 2021 16:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235127AbhGMQSA (ORCPT ); Tue, 13 Jul 2021 12:18:00 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:54702 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234036AbhGMQQ5 (ORCPT ); Tue, 13 Jul 2021 12:16:57 -0400 Message-Id: <20210713160750.564432923@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1626192845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=JN6sOwkSzGbTK7vxSf/WJ4VYhfWsi0+fBs8+6sDgMB4=; b=YyPXlAkrZqg6aCghfdlek/NWRNy5iVjLciunpCLWm2PLMFl4f4X5CH8++r91l3zjMC6k/h 71nqujat0PcgmrgpH+WjGeARUdYQWaw/26W5/JjMlaMtr9CbdAwo6cEsp3Til1RKLc+sFD 9yjtImRlZ73/F40k9jh8xhU3klXVfM9K5NzDVm8LQrjI1y0RvD4EuDKLSnAh7gDSZTsED2 FPkY+40lq6F+cZoKTNCt6I0U+xha2tHkWXJSMEK1QHY5H6g99zJJjJaI+dWGXgyAB0JuS6 SCgbvO3qb/IanT6aUdnbuHAfTUQGQj/59l8Ny1e+xBJ1x09d+T4wZxV56Bs6Yg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1626192845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=JN6sOwkSzGbTK7vxSf/WJ4VYhfWsi0+fBs8+6sDgMB4=; b=m5T4blNHCNofvnzSLtabpGXKAhUTP0ND+Dadd+lHFFfjN0vOmHhZT1EQLTCaFGxeiZGo+y 36psQLcRtezEV9Bg== Date: Tue, 13 Jul 2021 17:11:41 +0200 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , Sebastian Andrzej Siewior , Davidlohr Bueso Subject: [patch 47/50] rtmutex: Prevent lockdep false positive with PI futexes References: <20210713151054.700719949@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner On PREEMPT_RT the futex hashbucket spinlock becomes 'sleeping' and rtmutex based. That causes a lockdep false positive because some of the futex functions invoke spin_unlock(&hb->lock) with the wait_lock of the rtmutex associated to the pi_futex held. spin_unlock() in turn takes wait_lock of the rtmutex on which the spinlock is based which makes lockdep notice a lock recursion. Give the futex/rtmutex wait_lock a seperate key. Signed-off-by: Thomas Gleixner --- kernel/locking/rtmutex_api.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- --- a/kernel/locking/rtmutex_api.c +++ b/kernel/locking/rtmutex_api.c @@ -209,7 +209,19 @@ EXPORT_SYMBOL_GPL(__rt_mutex_init); void __sched rt_mutex_init_proxy_locked(struct rt_mutex *lock, struct task_struct *proxy_owner) { + static struct lock_class_key pi_futex_key; + __rt_mutex_basic_init(lock); + /* + * On PREEMPT_RT the futex hashbucket spinlock becomes 'sleeping' + * and rtmutex based. That causes a lockdep false positive because + * some of the futex functions invoke spin_unlock(&hb->lock) with + * the wait_lock of the rtmutex associated to the pi_futex held. + * spin_unlock() in turn takes wait_lock of the rtmutex on which + * the spinlock is based which makes lockdep notice a lock + * recursion. Give the futex/rtmutex wait_lock a seperate key. + */ + lockdep_set_class(&lock->wait_lock, &pi_futex_key); rt_mutex_set_owner(lock, proxy_owner); }