From nobody Wed Feb 11 19:42:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64B42C76196 for ; Tue, 11 Apr 2023 04:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230107AbjDKEZ4 (ORCPT ); Tue, 11 Apr 2023 00:25:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjDKEZv (ORCPT ); Tue, 11 Apr 2023 00:25:51 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0024C10E5 for ; Mon, 10 Apr 2023 21:25:29 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id y4-20020a253204000000b00b392ae70300so7594891yby.21 for ; Mon, 10 Apr 2023 21:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1681187129; x=1683779129; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=z7PRxTE/G+TewFJJW+aiwRGrdyvM9ejq86ABZBlhxUk=; b=PRdVbcVQdfIvRjuDqKuLiynVWdcAN7tDcV7TDQEKAG5aVZGSCUbH5Ta/p4ZVugRsVq WfuN9fGmQhTNNbzm7G2sf0T+YL9tjWRwgSFCQGFO9s5L5e5CmJk58BzV21Rm/QMGEfah /CMBT1hG5tiNi0FDGwUnyi/1uKzPFNfX/6Jmx8tVF4CVqg/CeynRI0UihrstmFo23J0l jZI0F2SPu5AOYuH2u/sOCW2mBfKvgsSSnmgFtbmR3/9w0g/SAO/EsPnTe64jmwvEk+55 jpTazCE8KWeokl17MiSSofm95JOyDOiDFw5f2lSo1iUPgg/PEDE5oaFCGeWT3MUIh1cQ ZBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681187129; x=1683779129; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z7PRxTE/G+TewFJJW+aiwRGrdyvM9ejq86ABZBlhxUk=; b=0zZ5YDmcIW3e1q4JCBs3KdihVGZgSn7mqGEptDGallUJjiPeLfS6A1WA+hArAdCU5e mgPQmtx/IF6kPSiLs55Y4ddAotQxZRaJSul5yT26oQEpWLTWH3xWreI5RvlqPK5eNCfs b1LNYb2Eo54oyISGh76EREc5CcTM2IqT/fuOacl591Zmfezvi3jSod7FM8LypiOps8mj IVx3bAylchp34FUB6Xqe5yzfJ0h71ZcxaNa93XvA8HyB8/3xen4mp6uVHF3IYoiSPdOM 5e0v8d6GHvhfFZzHFiORu67TK8mWqHWLQgFvpeVEvfeIcQ86geDqI43fIxm8CF0YG/rs aaDw== X-Gm-Message-State: AAQBX9e+sGMHEZd+Hx38pCxIMoRFhQX5XXpwuPR969LcQPJw+ahRNyXo m7iCMBczLRJNu9MBPRpdjnONrE0NrSHGsqQG/66/NSTnCsLoPB3cPKk9XbENGl0QPzCiUZzoBge S10afamBNDl844AHKOUO48MhMeNATyViztofLOdI9bquYoqz+NUhab2I+y4zhFg0X1AUt6p8= X-Google-Smtp-Source: AKy350ZAZhWGobfYrb6GHmvIGepMHShBMoVGwWMp6n3Jgy5a9161QujnAr76OYbjAFiV7su1rDTLXo66KC7r X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a25:73ca:0:b0:b8e:dadc:a081 with SMTP id o193-20020a2573ca000000b00b8edadca081mr5070323ybc.5.1681187129167; Mon, 10 Apr 2023 21:25:29 -0700 (PDT) Date: Tue, 11 Apr 2023 04:25:03 +0000 In-Reply-To: <20230411042511.1606592-1-jstultz@google.com> Mime-Version: 1.0 References: <20230411042511.1606592-1-jstultz@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230411042511.1606592-7-jstultz@google.com> Subject: [PATCH v3 06/14] locking/mutex: Expose mutex_owner() From: John Stultz To: LKML Cc: Juri Lelli , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , Valentin Schneider , "Connor O'Brien" , John Stultz Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Juri Lelli Implementing proxy execution requires that scheduler code be able to identify the current owner of a mutex. Expose a new helper mutex_owner() for this purpose. Cc: Joel Fernandes Cc: Qais Yousef Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E . McKenney" Signed-off-by: Juri Lelli [Removed the EXPORT_SYMBOL] Signed-off-by: Valentin Schneider Signed-off-by: Connor O'Brien [jstultz: Tweaked subject line] Signed-off-by: John Stultz --- include/linux/mutex.h | 2 ++ kernel/locking/mutex.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 8f226d460f51..ebdc59cb0bf6 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -118,6 +118,8 @@ do { \ extern void __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key); =20 +extern struct task_struct *mutex_owner(struct mutex *lock); + /** * mutex_is_locked - is the mutex locked * @lock: the mutex to be queried diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 45f1b7519f63..cbc34d5f4486 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -81,6 +81,11 @@ static inline struct task_struct *__mutex_owner(struct m= utex *lock) return (struct task_struct *)(atomic_long_read(&lock->owner) & ~MUTEX_FLA= GS); } =20 +struct task_struct *mutex_owner(struct mutex *lock) +{ + return __mutex_owner(lock); +} + static inline struct task_struct *__owner_task(unsigned long owner) { return (struct task_struct *)(owner & ~MUTEX_FLAGS); --=20 2.40.0.577.gac1e443424-goog