Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3442171rwb; Mon, 3 Oct 2022 15:19:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6j/XpK7NCBueOzEer6jSdaseyx4WYUkmChsWV6gW24LpRQKriWal/iBKK8tx6j6fdZ85GL X-Received: by 2002:a17:907:2d13:b0:783:eb5b:a32b with SMTP id gs19-20020a1709072d1300b00783eb5ba32bmr17043475ejc.175.1664835565132; Mon, 03 Oct 2022 15:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664835565; cv=none; d=google.com; s=arc-20160816; b=elUdkt1fjpRJeTC+vPbkJQzq9QzouLAzRo3zJJLfhMXgCPRkO3UGZde4lYgrKA5ZCk LE1rUr75gKm3Zu5ePsu5qeAwwBOXS05L3F0wRjvckk/C2fhdjZNKj7N8aba8v2s0zPdv EYYFMsNfaz80Hpnqin1P4yUX0joA+pPyaBAkNJheVVVkPaCJI8jtfsJq5+weTAzcscZ5 Vn8mz0l0ERdr97yJtSPsnQDiZDM1Ph2zMy+d1MirjcWFWdvPqqwAlnTkp8nbDR6xcm8v aUX4ViNAGGMemKUrBoIrcCQbW8GpVP5rTZBal+myDajx1wtgw0Z0BYvltHb3JYVja/hc 1rNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=CJ9H8CBxKRJhGb0mR/hcQ6BYPBA27hx15DUelORRnZs=; b=xp3+xbY+3PzcyoQGlM/P7LhI1L6IYnUa+CZwjarFNsfvAWIZqgPD3Hpb6NnZXCsPjM f2sMnzEQo07gU8zLbIUSZ+XdDH7XsNCVYtVUnWDZfC5/jbFtke9LchhUaICcyuGzZd3T ygh6TjR3CK39y6MbLUBQkGTUnedxjIla1vfTvzYQaQVcpVjpw6IdPI7prV/eXXEzIcjG AWSc+zAMoHytrA3eemVRL2bY8O+IoLTzUKejuROuGDVQDHtBzTXL4dkrp7gTGh4mgoky gUFqSPTji+iMx7kQMoI2DV6nb04VZMH3NlyEw4dw6rFaTTtMHTyHz6UrPnwJ+HUJl8HJ GZ/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fFFXrcOs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hu8-20020a170907a08800b0078cec0cc0f5si1627917ejc.689.2022.10.03.15.18.56; Mon, 03 Oct 2022 15:19:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=fFFXrcOs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiJCVpm (ORCPT + 99 others); Mon, 3 Oct 2022 17:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbiJCVpb (ORCPT ); Mon, 3 Oct 2022 17:45:31 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26FE31A819 for ; Mon, 3 Oct 2022 14:45:15 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id m16-20020a17090ab79000b0020abf0d3ff4so1085762pjr.1 for ; Mon, 03 Oct 2022 14:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=CJ9H8CBxKRJhGb0mR/hcQ6BYPBA27hx15DUelORRnZs=; b=fFFXrcOsme29dcf0SBMdtGRw+Z2z/5WbDMWzaUwqECnq7yfvXqkJ4MI09tebTl5oaY cuMGa+jCVkzCTIajVNDpg6UwKha/QIzFvjSLplviyY5KKTyu9UG1Ii9wGVz9aYbi7+uh s5AQmiWZQt+1yn4Gml95Fp+lDcekS25o7JdcRwBUic9IEtOl5C+ni+OGitSAqvH3vr5f WYKrFRnJ6pX6XxxuSABy+g0aNeCxvKAlopz7E/S6MHKzfXflGzVJihWNftfJE6NSOdJz 9F4oMpST2xFk+GKJGtEx7h/Cs4DTKQqxgJstDnumpg+6gBSZM1Pj5z5bBVl7xeIpL249 8dPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=CJ9H8CBxKRJhGb0mR/hcQ6BYPBA27hx15DUelORRnZs=; b=mcnk+sGmhS8PKHrgpCJ40uxANt3LD1HZbcaPzJkEYTOWO01fTUBowuJ6OgEaI5twI7 TumrbMSRIOgUctRqM8vwkzjDxYELXgigJ5CzivYev2paDkklZFz3EolL0U4mODrj9XtR JwwpTMwN5dzAlmCm2Fa7GJdOQ0NHA+GNhgq6wTfNFTVLMfFyVOXrtUC0vTVHMPCXwul0 ZQzFjpbUCirli4HeAKcOWi/cW+K6RcUYQAmT7hUdFdWRp5Kva9dzsauCBvge0PZkjrrn dUtO5n22QfK3xNSXFs8I+uHSJyiC4cwnVgn7cLiAd8hlkn/UCvGepByd106jTg23Z0Q3 SD0g== X-Gm-Message-State: ACrzQf3DuTbMiNA87umpcBOwSK9vYP61uoBOQtqdSq+SE/m6UZyOUsO+ 80QhMcdv6bK/FCZdjxgzb5ug18OyfMM17NwmoXsuxe0aQXNqaK05eLaP1ZXXREMP84U/Rbue6ID 5ccJHObsCq5bh6Tw+Z0O28VnB9YVjDZWasLdKQNFnjXhg2iFRYniAiUFrrswBR13qE9keU+hT X-Received: from connoro.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:a99]) (user=connoro job=sendgmr) by 2002:a17:902:c40f:b0:17f:6737:9527 with SMTP id k15-20020a170902c40f00b0017f67379527mr3751625plk.19.1664833514103; Mon, 03 Oct 2022 14:45:14 -0700 (PDT) Date: Mon, 3 Oct 2022 21:44:56 +0000 In-Reply-To: <20221003214501.2050087-1-connoro@google.com> Mime-Version: 1.0 References: <20221003214501.2050087-1-connoro@google.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221003214501.2050087-7-connoro@google.com> Subject: [RFC PATCH 06/11] kernel/locking: Expose mutex_owner() From: "Connor O'Brien" To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , "Connor O'Brien" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Juri Lelli [Removed the EXPORT_SYMBOL] Signed-off-by: Valentin Schneider Signed-off-by: Connor O'Brien --- 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); +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 f39e9ee3c4d0..325fc9db5004 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -81,6 +81,11 @@ static inline struct task_struct *__mutex_owner(struct mutex *lock) return (struct task_struct *)(atomic_long_read(&lock->owner) & ~MUTEX_FLAGS); } +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); -- 2.38.0.rc1.362.ged0d419d3c-goog