Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4587559rdb; Fri, 15 Sep 2023 06:50:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKZLj/WvqtlC1kTTZKWndeg7OktEuZIwmhheWNGxo5Sv7YjSMcbOw4hNfGdOB7OY840sRr X-Received: by 2002:a05:6a00:23c7:b0:68c:2be:67bb with SMTP id g7-20020a056a0023c700b0068c02be67bbmr1938214pfc.20.1694785806447; Fri, 15 Sep 2023 06:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694785806; cv=none; d=google.com; s=arc-20160816; b=P2XHrbEKUGtKKIs95e+57ZkqukmFCqcTGx8i4tLBMy9ihdzsvQzKrq8U6EiCF9AsJs IKBhJ8sxpobq/8w83Mq7l1qi6WAJjoT8PW4gs8el5nCZteGbFQqVC4xq+ug7Ny8kALWs QD8oynP8tjMnRUBzesoleX2PvHt9H4T8h6+ROkJZpk8dhPvwMaiE+Wx/r+cGOVsNsEbM O65xJLabCIezrEp5cMhf/UKp7bF/h9dbl83E7opwhHRI7PyA8RWqg00+FN8p0G4b58MG LUGHLq5Tm6FoT9Rxx7MYxYe29wdSkbczRBI5zn826nQYyeHkbR2Irn+yqF6cdSfcLICk y2OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=QU0L6YAD0f4WsuAlohDoyNjHsvnrsL9ts0EKnxIcqx8=; fh=gv/p03oVG+jHZvLbCYSdMkzIQ7o6LnSdpEt37rU3V8Y=; b=q/bnDgGglHhPG3uyF9hkcmfF8D2I7Eb08XyChDezrnyWT7M1e+ekFmTnp+yFVYrSi0 A1kxsYURxME5CJKwBucHA12yDdNQiWXP7J6GGtDETw2JNd+s2gYmPnrHdaDA1EgnufbZ 4Nga/ci0iMWffu9p+TY5fp7XBFoLWkzDQZzISMQTSO+t/ggi7Gu2ODxeh/NVoL/X5F4Q 4Ew+0HY3H7XMXajJ2fZoqpgutsTUxl2VX8vKi4fIQOHeNfoDHOr7cATT/FUspAxHnxN4 Mu0MeWFpr+UmH0aFAXLc8GdoN/It8HnEyB/OLw5v3hs78YydSD35v3gO6pp2NJPNE165 Ro8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id bd6-20020a056a00278600b0068e3fe64a03si3334126pfb.308.2023.09.15.06.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 06:50:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 242E983EDD90; Fri, 15 Sep 2023 06:36:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235372AbjIONgM (ORCPT + 99 others); Fri, 15 Sep 2023 09:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235369AbjIONgL (ORCPT ); Fri, 15 Sep 2023 09:36:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8EC201BEB for ; Fri, 15 Sep 2023 06:36:06 -0700 (PDT) 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 9A1BE1FB; Fri, 15 Sep 2023 06:36:43 -0700 (PDT) Received: from [10.57.93.60] (unknown [10.57.93.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2ED193F5A1; Fri, 15 Sep 2023 06:36:02 -0700 (PDT) Message-ID: Date: Fri, 15 Sep 2023 15:35:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH v3] sched/topology: remove sysctl_sched_energy_aware depending on the architecture To: Valentin Schneider , Shrikanth Hegde Cc: dietmar.eggemann@arm.com, linux-kernel@vger.kernel.org, ionela.voinescu@arm.com, quentin.perret@arm.com, srikar@linux.vnet.ibm.com, mgorman@techsingularity.net, mingo@kernel.org, yu.c.chen@intel.com, tim.c.chen@linux.intel.com, mingo@redhat.com, peterz@infradead.org, vincent.guittot@linaro.org References: <20230913114807.665094-1-sshegde@linux.vnet.ibm.com> <7c6dd2ec-b9a9-b364-5a29-05336127e519@linux.vnet.ibm.com> Content-Language: en-US From: Pierre Gondois In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:36:17 -0700 (PDT) Hello Valentin, On 9/15/23 14:00, Valentin Schneider wrote: > On 14/09/23 23:26, Shrikanth Hegde wrote: >> On 9/14/23 9:51 PM, Valentin Schneider wrote: >>> On 13/09/23 17:18, Shrikanth Hegde wrote: >>>> sysctl_sched_energy_aware is available for the admin to disable/enable >>>> energy aware scheduling(EAS). EAS is enabled only if few conditions are >>>> met by the platform. They are, asymmetric CPU capacity, no SMT, >>>> valid cpufreq policy, frequency invariant load tracking. It is possible >>>> platform when booting may not have EAS capability, but can do that after. >>>> For example, changing/registering the cpufreq policy. >>>> >>>> At present, though platform doesn't support EAS, this sysctl is still >>>> present and it ends up calling rebuild of sched domain on write to 1 and >>>> NOP when writing to 0. That is confusing and un-necessary. >>>> >>> >> >> Hi Valentin, Thanks for taking a look at this patch. >> >>> But why would you write to it in the first place? Or do you mean to use >>> this as an indicator for userspace that EAS is supported? >>> >> >> Since this sysctl is present and its value being 1, it gives the >> impression to the user that EAS is supported when it is not. >> So its an attempt to correct that part. >> > > Ah, I see. Then how about just making the sysctl return 0 when EAS isn't > supported? And on top of it, prevent all writes when EAS isn't supported > (perf domains cannot be built, so there would be no point in forcing a > rebuild that will do nothing). I think the issue comes from the fact there is no variable representing whether EAS is supported or not. sched_energy_enabled()/sched_energy_present tells whether EAS is actively running on the system instead. So on a system with EAS running, I think what would happen is: # Disable EAS and set sched_energy_present=0 echo 0 > /proc/sys/kernel/sched_energy_aware # sched_energy_present==0, so we get -EOPNOTSUPP echo 1 > /proc/sys/kernel/sched_energy_aware > > I can never remember how to properly use the sysctl API, so that's a very > crude implementation, but something like so? > > --- > > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > index 05a5bc678c089..dadfc5afc4121 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -230,9 +230,28 @@ static int sched_energy_aware_handler(struct ctl_table *table, int write, > if (write && !capable(CAP_SYS_ADMIN)) > return -EPERM; > > + if (!sched_energy_enabled()) { > + if (write) > + return -EOPNOTSUPP; > + else { > + size_t len; > + > + if (*ppos) { > + *lenp = 0; > + return 0; > + } > + > + len = snprintf((char *)buffer, 3, "0\n"); > + > + *lenp = len; > + *ppos += len; > + return 0; > + } > + } > + > ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); > if (!ret && write) { > - state = static_branch_unlikely(&sched_energy_present); > + state = sched_energy_enabled(); > if (state != sysctl_sched_energy_aware) > rebuild_sched_domains_energy(); > } > Regards, Pierre