Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4000921rdb; Thu, 28 Dec 2023 07:06:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbVD9QWJxBW/WV+xecjqYFIzJngd8zY++/K5/ilMEVunVORD/U/waI6lgi4puKf24SV4qk X-Received: by 2002:a17:903:1c8:b0:1d4:47d4:82c6 with SMTP id e8-20020a17090301c800b001d447d482c6mr4664848plh.99.1703775988042; Thu, 28 Dec 2023 07:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703775988; cv=none; d=google.com; s=arc-20160816; b=UuhkFWA/vZ1DXBf3cht19hGMPVRfiJMX7D3P4T+Ai89NUpgQwvoRQtd4L2r1/YPUjx TspSSrpsRj7fBFQXtxTyYL2xQ2glZ+oLaWeJKYLp9qkRYPcS3CyeS54pkW/7uqBXYBip DE/ce2LkBA6Z4eqBoDFrY5pmRIHm3F6j4mk4UkG+urni/jkmcc6hB5A+nJGqgSu20Ch4 UuVHef5J6bX5gap0u4Af2ClW+X04jmn510XN9Gt8/cBuMdp/VScBLoaym6Qsf4bf3M3j 5Yo54MNWlc6gwpU19Tl/P9pbJMNX1YiccroAP1FaTQ5uHLmUb76J2pGNSR9Pu5CWMFK+ Ebig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=JNem9mMoPBFMXKPM+t6RqS+oHC0LeDkk2Yz+HVfzVtY=; fh=IIn5181kkf6eV43uezdjLqEXV63ArwY//WIorpexdA4=; b=fQuLLH+Cis5UX4TD7EWyIMmsfsB8cRPpOzsM67TxQcp7Sko9A2jasd7tIrOvku5iFg a7k+5AfQ97s8olWg2jQST/yIcmK5MOTm2b2NmVrrmwS3CTsyNdPnVSn0HqRftnOLCNs1 utIaA3mujtLHFY70jeXf0p8xPDR5tledlqYFYF3JiBg/Xa8A3vFXKFocdHGmZN7htEXB YU/a9G3HTsKf63Z9bOLWm+gtxEJja3RHB3JzL8hgzRnH5qMCO0RSfCKV2L/ZaO95RZGe rFbpQfnmWk09zRR/3vsR1mUHFL19TcrvCwe4YT1quvqP+pkRtJvvOHU1j8HzLVZ7ks10 EIkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12725-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s8-20020a170902ea0800b001d453cffba2si7428866plg.391.2023.12.28.07.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 07:06:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12725-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12725-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 91455285BBF for ; Thu, 28 Dec 2023 15:06:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5ADED533; Thu, 28 Dec 2023 15:06:21 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85E7FD2E6 for ; Thu, 28 Dec 2023 15:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7D8FB2F4; Thu, 28 Dec 2023 07:07:03 -0800 (PST) Received: from [10.57.87.187] (unknown [10.57.87.187]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7CC293F64C; Thu, 28 Dec 2023 07:06:14 -0800 (PST) Message-ID: Date: Thu, 28 Dec 2023 15:06:13 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 06/23] sched: Add CONFIG_SCHED_PROXY_EXEC & boot argument to enable/disable Content-Language: en-US To: John Stultz , LKML Cc: 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" , Xuewen Yan , K Prateek Nayak , Thomas Gleixner , kernel-team@android.com References: <20231220001856.3710363-1-jstultz@google.com> <20231220001856.3710363-7-jstultz@google.com> From: Metin Kaya In-Reply-To: <20231220001856.3710363-7-jstultz@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 20/12/2023 12:18 am, John Stultz wrote: > Add a CONFIG_SCHED_PROXY_EXEC option, along with a boot argument > sched_prox_exec= that can be used to disable the feature at boot > time if CONFIG_SCHED_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: Metin Kaya > Cc: Xuewen Yan > Cc: K Prateek Nayak > Cc: Thomas Gleixner > Cc: kernel-team@android.com > Signed-off-by: John Stultz > --- > v7: > * Switch to CONFIG_SCHED_PROXY_EXEC/sched_proxy_exec= as > suggested by Metin Kaya. > * Switch boot arg from =disable/enable to use kstrtobool(), > which supports =yes|no|1|0|true|false|on|off, as also > suggested by Metin Kaya, and print a message when a boot > argument is used. > --- > .../admin-guide/kernel-parameters.txt | 5 ++++ > include/linux/sched.h | 13 +++++++++ > init/Kconfig | 7 +++++ > kernel/sched/core.c | 29 +++++++++++++++++++ > 4 files changed, 54 insertions(+) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 65731b060e3f..cc64393b913f 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -5714,6 +5714,11 @@ > sa1100ir [NET] > See drivers/net/irda/sa1100_ir.c. > > + sched_proxy_exec= [KNL] > + Enables or disables "proxy execution" style > + solution to mutex based priority inversion. > + Format: > + > sched_verbose [KNL] Enables verbose scheduler debug messages. > > schedstats= [KNL,X86] Enable or disable scheduled statistics. > diff --git a/include/linux/sched.h b/include/linux/sched.h > index bfe8670f99a1..880af1c3097d 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -1566,6 +1566,19 @@ struct task_struct { > */ > }; > > +#ifdef CONFIG_SCHED_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 9ffb103fc927..c5a759b6366a 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 SCHED_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. > + Should `SCHED_PROXY_EXEC` config option be under `Scheduler features` menu? > menuconfig CGROUPS > bool "Control Group support" > select KERNFS > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 4e46189d545d..e06558fb08aa 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -117,6 +117,35 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp); > > DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); > > +#ifdef CONFIG_SCHED_PROXY_EXEC > +DEFINE_STATIC_KEY_TRUE(__sched_proxy_exec); > +static int __init setup_proxy_exec(char *str) > +{ > + bool proxy_enable; > + > + if (kstrtobool(str, &proxy_enable)) { > + pr_warn("Unable to parse sched_proxy_exec=\n"); > + return 0; > + } > + > + if (proxy_enable) { > + pr_info("sched_proxy_exec enabled via boot arg\n"); > + static_branch_enable(&__sched_proxy_exec); > + } else { > + pr_info("sched_proxy_exec disabled via boot arg\n"); > + static_branch_disable(&__sched_proxy_exec); > + } > + return 1; > +} > +#else > +static int __init setup_proxy_exec(char *str) > +{ > + pr_warn("CONFIG_SCHED_PROXY_EXEC=n, so it cannot be enabled or disabled at boottime\n"); > + return 0; > +} > +#endif > +__setup("sched_proxy_exec=", setup_proxy_exec); > + > #ifdef CONFIG_SCHED_DEBUG > /* > * Debugging: various feature bits