Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2357319rdf; Mon, 6 Nov 2023 11:37:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRA7w0xJ7CQ+vTovqx+tlOaJqMsCMOf6DyhCzpslYPDXx3NH4Xoc1PQ9AJbnV1RVomDYXB X-Received: by 2002:a17:902:ef92:b0:1cc:50ad:58 with SMTP id iz18-20020a170902ef9200b001cc50ad0058mr15639478plb.42.1699299437582; Mon, 06 Nov 2023 11:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699299437; cv=none; d=google.com; s=arc-20160816; b=Bax6NlqZZjigaDEyvxTrMkIhUr2GpcDigdxQr3rghFOrFbTxdyakPJwFkgG+3952G0 cg+91zFCB2pZQF/woV6dy/nxSOpyz3GaRSt+sOR0cBVQ6x7+3ddtWha6rruM6tEpLGqh 0JDJiASAkiBcESetKeJmkRYuiiI31RQIDHAMDGjTwoGpc2yrXGhtz2arAHoTUlrg63Ap 692aOUXsSawLwPL+75QYpEJN3LQz1WsoIzo/3Nshm11hx3MwZinRZ5bfy5YAM7uu4lnL YsAViE4hGeQ/D7nviFcsb4gqvma3j91jaCn/J/oRPv2SRdXjQQZ4CrNxZ6URnUcnPtkg hOeQ== 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=JeaszBAoxCXKdkXYBf2TzRJcYXC3x0zPMGfP5WqEvsc=; fh=7UDRnXAyFwoHSGMn0t+ldgDKuKM1JE0l1TSpusfeMFI=; b=ebBucMoSyUxD7yJ8mUIrOpR3XwJClwVR25koKaggS9XJRyPCj/+TWXVIsvXnLzvbsJ B25wdeSBJra5lTVjnDANPAcypwsPN+PmUulDGCCSL/djbX1cOzDIUiIbbYTS2JUDVNrv IiitsJ7OMTou+3/h1neNWvhhz3V3QRLcZlf6FaoCHtW1N+YFwWw7+YgjT0jYVy80GF0f Wp2hsLNfcfglqYKVscJyoluLIDx/DsHXTNCu2bqrhvxHnur3UQMHYMHPfGLrnhGyvE4W kkseBU5sU3TDbeA5CGpTmkwPv4UL9voPVsWUx9eftLOJRoGrkmuCetxtaWEsFn14idvY 2v2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4T34G51V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x14-20020a170902ec8e00b001c45e1f034esi9541996plg.141.2023.11.06.11.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 11:37:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4T34G51V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 93D2C801F76C; Mon, 6 Nov 2023 11:36:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233057AbjKFTgT (ORCPT + 99 others); Mon, 6 Nov 2023 14:36:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232975AbjKFTf5 (ORCPT ); Mon, 6 Nov 2023 14:35:57 -0500 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 3D410D42 for ; Mon, 6 Nov 2023 11:35:52 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d9a5a3f2d4fso5597543276.3 for ; Mon, 06 Nov 2023 11:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1699299351; x=1699904151; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=JeaszBAoxCXKdkXYBf2TzRJcYXC3x0zPMGfP5WqEvsc=; b=4T34G51Vy24jzZYmXhLVBV33LpOwspeKDUmQx9HJQcv5TeDzByoGZmuh1Jx58QYspS GOo0ztpeLs7Zbct5/wX4dWIz8vkxkig9fJVuWYALs+xhjgKI3h1B0z6wlkn9ZKy6VHqN ARAA38YjWfq1heHQVGWuqG0nou7/iBtBHdH44evGq+gCm/8NpJvW9R1f+PPFPAOxkk6+ mnkA70x+yEFQj/MtNLsm9IzFE5aacYqnAlH11ATuNlXvbjbGdpnG2ShqGSMdseDseUVP /Nwl7zBP+3eB8WAK/ibp9/4PgeabDcsa21IMJw/cS1z//4pcojchVH/Vjg9TMbcvXIxd uNzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699299351; x=1699904151; 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=JeaszBAoxCXKdkXYBf2TzRJcYXC3x0zPMGfP5WqEvsc=; b=LqxsQkKrNbyX56umMmhVXarNhXUp+LxsOOLjIQNIbpM9NIZEZDWXaywKJliIf2dmGR 2rRNppWC5qgMUQt3O1YbMdz8cwMXRC6jDPO2lhek5rSD5uwYs8t7TRi0o32aUD4myeY0 JJV3dOq8tZTnJR7sEJu8GzS7qOW9cRqABiVvTGoL++Rzm/c7gUFKyX0+T1PCQW92aeqv wHgQjEsyXacv95jF1+V/JRJeLg7vf9wUha7n25bHU90hJSIolDQAiquVZ/p3JLFEiwsp S5q5z+NUls6FDRwGKyfM1MEj0sD+CUMofivcjUApvrA/cbPemJZVBNtX3y5RDP1jHweu acOQ== X-Gm-Message-State: AOJu0YxKTELPlymViI2aGbGQpmsGbYc0IHijfpBprdiXulnbcsd5TJzJ eW70ajV2eduGXBCqyL1TbbZq2F4sfZs3GqMVlxxIJO+bWxq7b8lrC9K9idgdOAxScq6X+xB6LJH ZbC8WY3C1AuJM10Uks59pcgsPF4T93W2qkVHK+bgbD4ph/A7ibQFB3Y/5AwgHfY2F8ZU304g= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a05:6902:1083:b0:d9a:c3b8:4274 with SMTP id v3-20020a056902108300b00d9ac3b84274mr698792ybu.7.1699299351218; Mon, 06 Nov 2023 11:35:51 -0800 (PST) Date: Mon, 6 Nov 2023 19:34:51 +0000 In-Reply-To: <20231106193524.866104-1-jstultz@google.com> Mime-Version: 1.0 References: <20231106193524.866104-1-jstultz@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Message-ID: <20231106193524.866104-9-jstultz@google.com> Subject: [PATCH v6 08/20] sched: Add CONFIG_PROXY_EXEC & boot argument to enable/disable From: John Stultz To: LKML Cc: John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Youssef Esmat , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E . McKenney" , kernel-team@android.com 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,T_SCC_BODY_TEXT_LINE,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 11:36:28 -0800 (PST) This patch adds the CONFIG_PROXY_EXEC option, along with a boot argument prox_exec= that can be used to disable the feature at boot time if CONFIG_PROXY_EXEC was enabled. 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: Youssef Esmat 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: John Stultz --- .../admin-guide/kernel-parameters.txt | 4 +++ include/linux/sched.h | 13 ++++++++ init/Kconfig | 7 +++++ kernel/sched/core.c | 31 +++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0a1731a0f0ef..199578ae1606 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4648,6 +4648,10 @@ that). Format: + proxy_exec= [KNL] Enable or disables "proxy execution" style + solution to mutex based priority inversion. + Format: "enable" or "disable" + psi= [KNL] Enable or disable pressure stall information tracking. Format: diff --git a/include/linux/sched.h b/include/linux/sched.h index 81334677e008..5f05d9a4cc3f 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1551,6 +1551,19 @@ struct task_struct { */ }; +#ifdef CONFIG_PROXY_EXEC +DECLARE_STATIC_KEY_TRUE(__sched_proxy_exec); +static inline bool sched_proxy_exec(void) +{ + return static_branch_likely(&__sched_proxy_exec); +} +#else +static inline bool sched_proxy_exec(void) +{ + return false; +} +#endif + static inline struct pid *task_pid(struct task_struct *task) { return task->thread_pid; diff --git a/init/Kconfig b/init/Kconfig index 6d35728b94b2..884f94d8ee9e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -908,6 +908,13 @@ config NUMA_BALANCING_DEFAULT_ENABLED If set, automatic NUMA balancing will be enabled if running on a NUMA machine. +config PROXY_EXEC + bool "Proxy Execution" + default n + help + This option enables proxy execution, a mechanism for mutex owning + tasks to inherit the scheduling context of higher priority waiters. + menuconfig CGROUPS bool "Control Group support" select KERNFS diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 802551e0009b..a38bf8ef5798 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -117,6 +117,37 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); +#ifdef CONFIG_PROXY_EXEC +DEFINE_STATIC_KEY_TRUE(__sched_proxy_exec); +static int __init setup_proxy_exec(char *str) +{ + int ret = 0; + + if (!str) + goto out; + + if (!strcmp(str, "enable")) { + static_branch_enable(&__sched_proxy_exec); + ret = 1; + } else if (!strcmp(str, "disable")) { + static_branch_disable(&__sched_proxy_exec); + ret = 1; + } +out: + if (!ret) + pr_warn("Unable to parse proxy_exec=\n"); + + return ret; +} +#else +static int __init setup_proxy_exec(char *str) +{ + pr_warn("CONFIG_PROXY_EXEC=n, so it cannot be enabled or disabled at boottime\n"); + return 0; +} +#endif +__setup("proxy_exec=", setup_proxy_exec); + #ifdef CONFIG_SCHED_DEBUG /* * Debugging: various feature bits -- 2.42.0.869.gea05f2083d-goog