Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp276048rdb; Tue, 19 Dec 2023 17:04:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IExHJohVqwAjEk3CK4BbTvjwvvwnDCrIZA233aTgst5pqjr13mgpWhn3f9LIAWs7jPffdMf X-Received: by 2002:ac8:5753:0:b0:427:75d9:e64c with SMTP id 19-20020ac85753000000b0042775d9e64cmr2165353qtx.54.1703034260975; Tue, 19 Dec 2023 17:04:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703034260; cv=none; d=google.com; s=arc-20160816; b=kYEZMYrLkeLL4OSoUcqukc/4ZoigMZzy81Y/tB7BctWS/8eJUS+X+1CRQo+XH/eqZs sjMFjZYoiLj0UZOA/Loo2SqQTZVVz6JTbN7VUOdXYnaA2CNIpszmKD5p2/doWDNcmH/v YfU69ZImnjIkhj32Ia6IkRCnxjIZwFA9F07p0RQ1rP8FFR9GRCpilkPyqDlpFe+CyaXS GvfRcfkDbkv8ADdNhKRggb61/NjiMKWhFu5EIBhnrDI34oZti+a9Y6d9OHFI0fgc6A3G Z/Dvg8zi5sircYPtEiPMoNyNCRJuSS+I7CPTDPWvjgmNsxC1p1ciPiYHfTrgkqZMkVBM d2AQ== 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:dkim-signature; bh=aFf71YKlmBdavy5zuWJqFMWS/uiK5dKGj3zZ+PjZ9FY=; fh=JmPrTHK9H2ptCv5pObHw3siGszRtZD8I0+NG2lwlOO4=; b=gqFPCgqa4mErjI7FMZWkqRAubIqFX49d6iTSYD/2quIYy/rPvbB2wdiJ16g7W0WhbF diR72Zm1xKceiKXFkwzCWvogGraD9Va+NuGbv3zpg+v/mAuPxYEkcDBr+pDCy9xTOBa5 e9t0cgRaQ+sikn5gY7U4oqJbBwisodcVXceL8Z00JY2UBJvTojAMs2m4ckS5KlaRiAOU r6yidOtVwWv9FCU5a0emaMWDiE5xR67HlEVo98gKUTPs63quZdVBIlbE8a7x6OCvi6Cm TZVfT46pUubKy9WLNaBCe1A14afzvX3U17zThWMemhIbXcqnPm9jxzq5k/yN75oaYdYx pnbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FA8NfmAP; spf=pass (google.com: domain of linux-kernel+bounces-6221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6221-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fk10-20020a05622a558a00b00427821fe7ebsi1422732qtb.454.2023.12.19.17.04.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 17:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FA8NfmAP; spf=pass (google.com: domain of linux-kernel+bounces-6221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6221-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A84081C2547B for ; Wed, 20 Dec 2023 01:04:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 474805241; Wed, 20 Dec 2023 01:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="FA8NfmAP" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCFB2440B for ; Wed, 20 Dec 2023 01:04:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Sender:Reply-To:Content-ID:Content-Description; bh=aFf71YKlmBdavy5zuWJqFMWS/uiK5dKGj3zZ+PjZ9FY=; b=FA8NfmAPI3pUNkh4ps+a6iLirM ZtkIhBicbYm5PCmZ/SgIPeVWojMvE8KGdOoV2XUU6yVApUxkQ2RyjZyaAdlIwH6LlFBCzktkaKW6k ghtAfJ7b+AD58mpLeVSg+vX5GjlXSHQSaxzt0vB/1J61Ru3mDnRrftmSIEyT7VzBtRNJsbCXziILK aPPhSw+Bu8drCM4JosRAvPbfUwLZ7XsFzFL7SmIkWHBVdzX/Z1NP+k3AAvfVG/afRgScGbHWrr86G dl0YjgR5Vt315qwcoE2vkLnqyQ2JLSZy1yONxGogpPiXI1/ZtO1N4cPcQ+x1qAaLXFyHCvJtYuWHY btjabnwA==; Received: from [50.53.46.231] (helo=[192.168.254.15]) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rFl0L-00FrLp-38; Wed, 20 Dec 2023 01:04:10 +0000 Message-ID: <155363f0-26f5-4946-a36e-ee68b5887e60@infradead.org> Date: Tue, 19 Dec 2023 17:04:08 -0800 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" , Metin Kaya , 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: Randy Dunlap In-Reply-To: <20231220001856.3710363-7-jstultz@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/19/23 16:18, 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 sched_proxy_exec= > 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. mutex-based > + 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 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 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"); Preferably s/boottime/boot time/. > + return 0; > +} > +#endif > +__setup("sched_proxy_exec=", setup_proxy_exec); > + > #ifdef CONFIG_SCHED_DEBUG > /* > * Debugging: various feature bits -- #Randy https://people.kernel.org/tglx/notes-about-netiquette https://subspace.kernel.org/etiquette.html