From patchwork Mon Mar 20 23:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 72530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1492331wrt; Mon, 20 Mar 2023 16:39:50 -0700 (PDT) X-Google-Smtp-Source: AK7set/m9rmMhHBf7lMmjM0s/rhgWx7zKt8eiU1NVFOkOIY8lhGpqhsGaLeP/+IJGOOjaraFrq+Z X-Received: by 2002:a17:902:d0d4:b0:199:3a4a:d702 with SMTP id n20-20020a170902d0d400b001993a4ad702mr10518017pln.0.1679355590305; Mon, 20 Mar 2023 16:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679355590; cv=none; d=google.com; s=arc-20160816; b=sNcAhkULUWH2hlmyjNPPLv/GJEdd0XgRJE8N0dTTBq0mnZfiJV4LDqBoCI/Jw2/J5c CIiwFzNeEtyNyNt65mCB3XB75twlgv4HnnY+AaKV2OAvhmi2DXg26ZsyVflBoe/GEx6Q FE1fW0xq9nHaBaQ3aTXYPdiE7lnzqhEcZruxqlKy+bzQJTzew6yyKhqZfBmijCFGd8nJ h5BIGcf7SqBkyU5kLjqbhMrgoNSfBehdb5Ex9J4dj/V47CfDeNvtd8GjEOzgt6uOb10c D5k08PCbmmkClwhp+51lpsgbMpol6Okn3ynD/kJcYLOX0iIKfbo5JwJZ9p/UINvXUUVI /Qmw== 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=1bMyxMo2OrU8zdLjC4DVnVi1YjKD+2xFoy9FGGeajpo=; b=UqZuqTv0k2pZuFDWGZTZdi4txOcBbOpBpdyAXljIwXhKLLZH9KZRTsd6o9h4I9x7s3 WTmIGxJfTw6z3hppV5KBuKrYioZ92bRUWL4DNJ2nG8pq0TbiUqyJM6U1OnXVnzEG4agB lJpWrAWr9jlyaU9XGkYe5Jt7MhBt+LL0KqMOo5uPY8C/Sp7gjqnB42uX75uDGJA0ZgSx 3G7UaY5ONP5kWlXd8fKDafM2V7ZenESza+NMJ3GNkorgwuQt6xjfK4W+ZtKoxbsbhkxK Yl78E6L1SsbukFWaR71I3P0DpW/yxDLnp4xQTtCE2nzbSJ9nu6tZ4FZ5dAM8N+CQzBLL 9pFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="qR8HRj/u"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id on11-20020a17090b1d0b00b0023d23393339si18143685pjb.117.2023.03.20.16.39.37; Mon, 20 Mar 2023 16:39:50 -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="qR8HRj/u"; 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 S229966AbjCTXh5 (ORCPT + 99 others); Mon, 20 Mar 2023 19:37:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbjCTXhn (ORCPT ); Mon, 20 Mar 2023 19:37:43 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86F2336685 for ; Mon, 20 Mar 2023 16:37:40 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id m6-20020a056902118600b00aeb1e3dbd1bso14424180ybu.9 for ; Mon, 20 Mar 2023 16:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679355459; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1bMyxMo2OrU8zdLjC4DVnVi1YjKD+2xFoy9FGGeajpo=; b=qR8HRj/uNpfNeexzdD3NSFaYQWdRoJDVXPizK+wXOQWFYtX8R1+aVjZdU1/ib5VwkW o9bIMNcgC6U84WI611cMZ3nMGR9lOmlNY1EQhi82VZbDdFW/yXZF40jXonjZiLi64YtT m6e81g6eATsubVyjsLc1gajg52/Otu95UYKZpdJNog4uqyQoC+DxyntBgL40uO4GxP2S kXhooO86PZE/PSev2YsGtyaVxzG/RPaLyHu8bf6ufuy4YMx5cdDBFiG6j/wqXnCg6mZQ dWmsqe1nTDvTZyesWKeDcXYmP2C26cRfJhwlNHXclJm0tumQxdmwQHgp0rvpM9O03z+N TcPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679355459; 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=1bMyxMo2OrU8zdLjC4DVnVi1YjKD+2xFoy9FGGeajpo=; b=mFw1/OPw4/26NFrQ3it3mTbnJ6pOheuYkTx3O6QBv7U26A5O+pWHqCv2sltgm/eml4 7hH+1x1v6mrNjm7bBJPM40yuhVzGti16ibGFq6enKgG1Df5hTO5PEeEVLjlupNZ+ulfl 3gxfYY6jsCY7ZsT+gIonGQ3pNcEtZK8Rnn4RnRwQiomiWJ6h8tEcXVlD9dURTmQsnmXV JtMYwVoMudZDJjFnkDCujVURNZh9FL7i2nodFux24LuINXKkEC6dkqGcBAgrlR/ODfG3 EY/wK8YC+uRtB1aXErB5sSReBmHxn5jfRjZdfn7x4eUo/D/FDPNHn7K6KxMnXkZRr48y MwrQ== X-Gm-Message-State: AAQBX9dNNzL3j0fI+2kkzxKG3vexrNL+8nGQzX/NSOWo0Mef3oc2Ivyk WlSWML7zV3k5g+EVKB65TVjTXS+BwHzZvjBGn+VpE8uC/DodKIQ8yo/W9qZc9nvk3v2C58dIaZq J+i6yPT3NCZgLcsKX9h1Nb6SBXuMRblHy+wIG/bTolV8KWodefor/as8A/ztgrjIg3kXonbo= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a25:2d8:0:b0:b36:c001:d0a7 with SMTP id 207-20020a2502d8000000b00b36c001d0a7mr178103ybc.8.1679355459670; Mon, 20 Mar 2023 16:37:39 -0700 (PDT) Date: Mon, 20 Mar 2023 23:37:13 +0000 In-Reply-To: <20230320233720.3488453-1-jstultz@google.com> Mime-Version: 1.0 References: <20230320233720.3488453-1-jstultz@google.com> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog Message-ID: <20230320233720.3488453-6-jstultz@google.com> Subject: [PATCH v2 05/12] 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" , kernel-team@android.com, Valentin Schneider , "Connor O'Brien" , John Stultz 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760931967584803266?= X-GMAIL-MSGID: =?utf-8?q?1760931967584803266?= 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" Cc: kernel-team@android.com 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); +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 d322f7c1c8fa..ead4213232cc 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);