Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp597023rwb; Tue, 13 Dec 2022 23:40:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7V2k7pZ39TeR7TFmZDQw0DZuM2ZiITktRXAv8A5ntEI+gaVRkRn3bDzWtCBGb6eU5LEgCC X-Received: by 2002:aa7:96f2:0:b0:576:bb87:f2f7 with SMTP id i18-20020aa796f2000000b00576bb87f2f7mr24402121pfq.12.1671003657350; Tue, 13 Dec 2022 23:40:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671003657; cv=none; d=google.com; s=arc-20160816; b=B3IeOULe3ENXhThclMhdo1YzUGJ5N/fPU87AHQeQEWjcNp8r4zpk5tV68ex8iosdk2 Vc/ltip0JlZvDr8Jj6DmTjbeEvbYl92CaU1XapvjdWFyGZaeJBe5jef8VkvH1/g7M5Wz S30ij6eK9yNa6lDIzhHW4g/cJ4nwfXPSLZ2LyyvxkLcOmNhxSmXKAjhN1yMoB5G7D99a c9CT6fn0+C6K9dHOQ1q4Hk0kyTOhPyswJFMvNruzFMU6wJZLrprwuKUchXUIr00NbGeL Opl/6NlzKvZUKKt4WV07EGXtSb4CxDYGeQt64nCD7s2jjyD2hiP7P2GDVjn9Rb1zZDaI Dumw== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=JUFddXNEduhRaKhPerDZOR4JkTqu5g+kdVLZYYaKO4U=; b=B0PoBFfvgXOyCCtOKSOuwvjSBndSv9xN+WMVlkXudbaOC8yOAWnamgn3NvYKzlyB7I +O5KvPOPOK0AeWZGeXAyt3nPrT/qWug/FKl+li9me/J932pk338SPJ/vwfLE44qqT9mc N9Gy/39HE1TNG4iwLtWed2th2RyiRDKjEeUOVitmyp+t79ECC4akf96KmF4OMYPkoVrj hKtivUto5SAkQcqV62P4tn+wjNM4NXHsFfjh/SSAf+c7cY0UDPNXRbMhrr8+gn/d3KL+ fmOrVyLoRLAQ6HC7Ns850UxQ/nD3deQWQqfNmYZgjQdtMXfoTjZcoOBXGV1tnb7LWJaD e9WA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a056a00244f00b00556c1c66b61si16242676pfj.143.2022.12.13.23.40.46; Tue, 13 Dec 2022 23:40:57 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237581AbiLNHg5 (ORCPT + 70 others); Wed, 14 Dec 2022 02:36:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237552AbiLNHgv (ORCPT ); Wed, 14 Dec 2022 02:36:51 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AA12C178BA; Tue, 13 Dec 2022 23:36:50 -0800 (PST) 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 D15DAFEC; Tue, 13 Dec 2022 23:37:30 -0800 (PST) Received: from [10.57.11.76] (unknown [10.57.11.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B81643F5A1; Tue, 13 Dec 2022 23:36:46 -0800 (PST) Message-ID: Date: Wed, 14 Dec 2022 07:36:44 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 02/22] sched: Add interfaces for IPC classes Content-Language: en-US To: Ricardo Neri Cc: Ricardo Neri , "Ravi V. Shankar" , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Len Brown , Mel Gorman , "Rafael J. Wysocki" , Juri Lelli , Srinivas Pandruvada , Steven Rostedt , Tim Chen , Valentin Schneider , x86@kernel.org, "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, "Tim C . Chen" , Vincent Guittot , "Peter Zijlstra (Intel)" References: <20221128132100.30253-1-ricardo.neri-calderon@linux.intel.com> <20221128132100.30253-3-ricardo.neri-calderon@linux.intel.com> From: Lukasz Luba In-Reply-To: <20221128132100.30253-3-ricardo.neri-calderon@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 Hi Richardo, I have some generic comment for the design of those interfaces. On 11/28/22 13:20, Ricardo Neri wrote: > Add the interfaces that architectures shall implement to convey the data > to support IPC classes. > > arch_update_ipcc() updates the IPC classification of the current task as > given by hardware. > > arch_get_ipcc_score() provides a performance score for a given IPC class > when placed on a specific CPU. Higher scores indicate higher performance. > > The number of classes and the score of each class of task are determined > by hardware. > > Cc: Ben Segall > Cc: Daniel Bristot de Oliveira > Cc: Dietmar Eggemann > Cc: Joel Fernandes (Google) > Cc: Len Brown > Cc: Mel Gorman > Cc: Rafael J. Wysocki > Cc: Srinivas Pandruvada > Cc: Steven Rostedt > Cc: Tim C. Chen > Cc: Valentin Schneider > Cc: x86@kernel.org > Cc: linux-pm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Ricardo Neri > --- > Changes since v1: > * Shortened the names of the IPCC interfaces (PeterZ): > sched_task_classes_enabled >> sched_ipcc_enabled > arch_has_task_classes >> arch_has_ipc_classes > arch_update_task_class >> arch_update_ipcc > arch_get_task_class_score >> arch_get_ipcc_score > * Removed smt_siblings_idle argument from arch_update_ipcc(). (PeterZ) > --- > kernel/sched/sched.h | 60 +++++++++++++++++++++++++++++++++++++++++ > kernel/sched/topology.c | 8 ++++++ > 2 files changed, 68 insertions(+) > > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index b1d338a740e5..75e22baa2622 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -2531,6 +2531,66 @@ void arch_scale_freq_tick(void) > } > #endif > > +#ifdef CONFIG_IPC_CLASSES > +DECLARE_STATIC_KEY_FALSE(sched_ipcc); > + > +static inline bool sched_ipcc_enabled(void) > +{ > + return static_branch_unlikely(&sched_ipcc); > +} > + > +#ifndef arch_has_ipc_classes > +/** > + * arch_has_ipc_classes() - Check whether hardware supports IPC classes of tasks > + * > + * Returns: true of IPC classes of tasks are supported. > + */ > +static __always_inline > +bool arch_has_ipc_classes(void) > +{ > + return false; > +} > +#endif > + > +#ifndef arch_update_ipcc > +/** > + * arch_update_ipcc() - Update the IPC class of the current task > + * @curr: The current task > + * > + * Request that the IPC classification of @curr is updated. > + * > + * Returns: none > + */ > +static __always_inline > +void arch_update_ipcc(struct task_struct *curr) > +{ > +} > +#endif > + > +#ifndef arch_get_ipcc_score > +/** > + * arch_get_ipcc_score() - Get the IPC score of a class of task > + * @ipcc: The IPC class > + * @cpu: A CPU number > + * > + * Returns the performance score of an IPC class when running on @cpu. > + * Error when either @class or @cpu are invalid. > + */ > +static __always_inline > +int arch_get_ipcc_score(unsigned short ipcc, int cpu) > +{ > + return 1; > +} > +#endif Those interfaces are quite simple, probably work really OK with your HW/FW. If any other architecture is going to re-use them in future, we might face some issue. Let me explain why. These kernel functions are start to be used very early in boot. Your HW/FW is probably instantly ready to work from the very beginning during boot. What is some other HW needs some preparation code, like setup communication channel to FW or enable needed clocks/events/etc. What I would like to see is a similar mechanism to the one in schedutil. Schedutil governor has to wait till cpufreq initialize the cpu freq driver and policy objects (which sometimes takes ~2-3 sec). After that cpufreq fwk starts the governor which populates this hook [1]. It's based on RCU mechanism with function pointer that can be then called from the task scheduler when everything is ready to work. If we (Arm) is going to use your proposed interfaces, we might need different mechanisms because the platform likely would be ready after our SCMI FW channels and cpufreq are setup. Would it be possible to address such need now or I would have to change that interface code later? Regards, Lukasz [1] https://elixir.bootlin.com/linux/latest/source/kernel/sched/cpufreq.c#L29