From patchwork Mon May 22 14:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13250720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A581AC77B73 for ; Mon, 22 May 2023 14:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234080AbjEVO5X (ORCPT ); Mon, 22 May 2023 10:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234031AbjEVO5Q (ORCPT ); Mon, 22 May 2023 10:57:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 15FD1C4; Mon, 22 May 2023 07:57:14 -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 C62181480; Mon, 22 May 2023 07:57:58 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 942F33F6C4; Mon, 22 May 2023 07:57:10 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, rafael@kernel.org, linux-pm@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, delyank@fb.com, lukasz.luba@arm.com, qyousef@google.com, qyousef@layalina.io Subject: [RESEND][PATCH v2 1/3] sched/tp: Add new tracepoint to track uclamp set from user-space Date: Mon, 22 May 2023 15:57:00 +0100 Message-Id: <20230522145702.2419654-2-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230522145702.2419654-1-lukasz.luba@arm.com> References: <20230522145702.2419654-1-lukasz.luba@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The user-space can set uclamp value for a given task. It impacts task placement decisions made by the scheduler. This is very useful information and helps to understand the system behavior or track improvements in middleware and applications which start using uclamp mechanisms and report better performance in tests. Signed-off-by: Lukasz Luba --- include/trace/events/sched.h | 4 ++++ kernel/sched/core.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index fbb99a61f714..dbfb30809f15 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -735,6 +735,10 @@ DECLARE_TRACE(sched_update_nr_running_tp, TP_PROTO(struct rq *rq, int change), TP_ARGS(rq, change)); +DECLARE_TRACE(uclamp_update_tsk_tp, + TP_PROTO(struct task_struct *tsk, int uclamp_id, unsigned int value), + TP_ARGS(tsk, uclamp_id, value)); + #endif /* _TRACE_SCHED_H */ /* This part must be outside protection */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 944c3ae39861..7b9b800ebb6c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -114,6 +114,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_overutilized_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_cfs_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_util_est_se_tp); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL(uclamp_update_tsk_tp); DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); @@ -1956,12 +1957,16 @@ static void __setscheduler_uclamp(struct task_struct *p, attr->sched_util_min != -1) { uclamp_se_set(&p->uclamp_req[UCLAMP_MIN], attr->sched_util_min, true); + trace_uclamp_update_tsk_tp(p, UCLAMP_MIN, + attr->sched_util_min); } if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX && attr->sched_util_max != -1) { uclamp_se_set(&p->uclamp_req[UCLAMP_MAX], attr->sched_util_max, true); + trace_uclamp_update_tsk_tp(p, UCLAMP_MAX, + attr->sched_util_max); } } From patchwork Mon May 22 14:57:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13250721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DC11C7EE2E for ; Mon, 22 May 2023 14:57:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234037AbjEVO50 (ORCPT ); Mon, 22 May 2023 10:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234091AbjEVO5X (ORCPT ); Mon, 22 May 2023 10:57:23 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AA8A8110; Mon, 22 May 2023 07:57:17 -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 50476139F; Mon, 22 May 2023 07:58:02 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1D1213F6C4; Mon, 22 May 2023 07:57:13 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, rafael@kernel.org, linux-pm@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, delyank@fb.com, lukasz.luba@arm.com, qyousef@google.com, qyousef@layalina.io Subject: [RESEND][PATCH v2 2/3] cpufreq: schedutil: Refactor sugov_update_shared() internals Date: Mon, 22 May 2023 15:57:01 +0100 Message-Id: <20230522145702.2419654-3-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230522145702.2419654-1-lukasz.luba@arm.com> References: <20230522145702.2419654-1-lukasz.luba@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Remove the if section block. Use the simple check to bail out and jump to the unlock at the end. That makes the code more readable and ready for some future tracing. Signed-off-by: Lukasz Luba --- kernel/sched/cpufreq_schedutil.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index e3211455b203..f462496e5c07 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -446,17 +446,19 @@ sugov_update_shared(struct update_util_data *hook, u64 time, unsigned int flags) ignore_dl_rate_limit(sg_cpu); - if (sugov_should_update_freq(sg_policy, time)) { - next_f = sugov_next_freq_shared(sg_cpu, time); + if (!sugov_should_update_freq(sg_policy, time)) + goto unlock; - if (!sugov_update_next_freq(sg_policy, time, next_f)) - goto unlock; + next_f = sugov_next_freq_shared(sg_cpu, time); + + if (!sugov_update_next_freq(sg_policy, time, next_f)) + goto unlock; + + if (sg_policy->policy->fast_switch_enabled) + cpufreq_driver_fast_switch(sg_policy->policy, next_f); + else + sugov_deferred_update(sg_policy); - if (sg_policy->policy->fast_switch_enabled) - cpufreq_driver_fast_switch(sg_policy->policy, next_f); - else - sugov_deferred_update(sg_policy); - } unlock: raw_spin_unlock(&sg_policy->update_lock); } From patchwork Mon May 22 14:57:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 13250722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 042F1C77B73 for ; Mon, 22 May 2023 14:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234154AbjEVO5g (ORCPT ); Mon, 22 May 2023 10:57:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234090AbjEVO52 (ORCPT ); Mon, 22 May 2023 10:57:28 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5FD9D18D; Mon, 22 May 2023 07:57:21 -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 0055D150C; Mon, 22 May 2023 07:58:06 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9E0E73F6C4; Mon, 22 May 2023 07:57:17 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, rafael@kernel.org, linux-pm@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, delyank@fb.com, lukasz.luba@arm.com, qyousef@google.com, qyousef@layalina.io, kernel test robot Subject: [RESEND][PATCH v2 3/3] schedutil: trace: Add tracing to capture filter out requests Date: Mon, 22 May 2023 15:57:02 +0100 Message-Id: <20230522145702.2419654-4-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230522145702.2419654-1-lukasz.luba@arm.com> References: <20230522145702.2419654-1-lukasz.luba@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Some of the frequency update requests coming form the task scheduler might be filter out. It can happen when the previous request was served not that long ago (in a period smaller than provided by the cpufreq driver as minimum for frequency update). In such case, we want to know if some of the frequency updates cannot make through. Export the new tracepoint as well. That would allow to handle it by a toolkit for trace analyzes. Reported-by: kernel test robot # solved tricky build Signed-off-by: Lukasz Luba --- include/trace/events/sched.h | 4 ++++ kernel/sched/cpufreq_schedutil.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h index dbfb30809f15..e34b7cd5de73 100644 --- a/include/trace/events/sched.h +++ b/include/trace/events/sched.h @@ -739,6 +739,10 @@ DECLARE_TRACE(uclamp_update_tsk_tp, TP_PROTO(struct task_struct *tsk, int uclamp_id, unsigned int value), TP_ARGS(tsk, uclamp_id, value)); +DECLARE_TRACE(schedutil_update_filtered_tp, + TP_PROTO(int cpu), + TP_ARGS(cpu)); + #endif /* _TRACE_SCHED_H */ /* This part must be outside protection */ diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index f462496e5c07..4f9daf258a65 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -6,6 +6,8 @@ * Author: Rafael J. Wysocki */ +EXPORT_TRACEPOINT_SYMBOL_GPL(schedutil_update_filtered_tp); + #define IOWAIT_BOOST_MIN (SCHED_CAPACITY_SCALE / 8) struct sugov_tunables { @@ -318,8 +320,10 @@ static inline bool sugov_update_single_common(struct sugov_cpu *sg_cpu, ignore_dl_rate_limit(sg_cpu); - if (!sugov_should_update_freq(sg_cpu->sg_policy, time)) + if (!sugov_should_update_freq(sg_cpu->sg_policy, time)) { + trace_schedutil_update_filtered_tp(sg_cpu->cpu); return false; + } sugov_get_util(sg_cpu); sugov_iowait_apply(sg_cpu, time, max_cap); @@ -446,8 +450,10 @@ sugov_update_shared(struct update_util_data *hook, u64 time, unsigned int flags) ignore_dl_rate_limit(sg_cpu); - if (!sugov_should_update_freq(sg_policy, time)) + if (!sugov_should_update_freq(sg_policy, time)) { + trace_schedutil_update_filtered_tp(sg_cpu->cpu); goto unlock; + } next_f = sugov_next_freq_shared(sg_cpu, time);