Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp314109pxb; Mon, 25 Apr 2022 10:26:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+2pcPB0srZLg9jxPE+n8dIURPapu43fAyCHzS7FVy+RzSE89H7IouWAgkVnTYDRllJXJj X-Received: by 2002:a05:6a00:10d0:b0:4f7:5af4:47b6 with SMTP id d16-20020a056a0010d000b004f75af447b6mr19679557pfu.6.1650907610393; Mon, 25 Apr 2022 10:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650907610; cv=none; d=google.com; s=arc-20160816; b=TQW5vBb3njABQXKLJDUvyDCCeetdrzbFWX1QAhOnqcMQiHvXkLtQe03O0GIFFZPMmk yJ4V9+KHUejW9W+gCFnCYIMbkz9XSQP//TvQX8EfDqAL2Se7knvoTsPCnUAcC6eTI8wv A7brpbKm+EXPBSz/QmUnakqMiBS/CTyh6T8E5hD8eSOe4TGGEvQ8wnksHiVewjLI2VVO rt3qfMNFa9dssm60OthDigtOCfPnSm90a7KqRGu7M068rXsTeOw8Rqs5sYDuhPljCmXo fWYXgNGtqLBxwPmvKL1ZPhvoSsc35TKjVZk5lhwC39M5KuS8EZq8Sv6Ovs0o+ouamTvJ 3uHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=Ln5Ci2XCPSI43t/6B2MEmOQXagyALnKp/Nu/69kPu5E=; b=tionfvcXsbYT8PUFLEQIFMO2cmrd7fw/4k3vqhUSKTWJt1oKodjC1VbJWdUQfal87v 1AxZLFfgHOUfrbENsEOy9vHCtEFtTqbJDl08b3vTb4CwnRgrUs3nPc69aJ2RbrJa3lDe m8y6ScrFBoD/wqRFgpDCnHURucMOVe4cwHK6bQ4OL4RZXH8jIMt9sUPH+OEQbNXIGKVr Ah5audgu49KHPHUdP1qgKMgMelohUbHfJqADz2AEzGuSHps7YNVhHV0ggaD7s6PFPced DXuL3NpFilqW1TfHVMJQbQXpFm32mOAl9PNMEdQcCaJECbbypKcj4niNtFG1T4GffaOt v2Ww== 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 n15-20020a170902d2cf00b0015b3dbc18b3si5581146plc.371.2022.04.25.10.26.32; Mon, 25 Apr 2022 10:26:50 -0700 (PDT) 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 S242268AbiDYN4h (ORCPT + 99 others); Mon, 25 Apr 2022 09:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242259AbiDYN4f (ORCPT ); Mon, 25 Apr 2022 09:56:35 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3084D67D12 for ; Mon, 25 Apr 2022 06:53:31 -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 E40371FB; Mon, 25 Apr 2022 06:53:30 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.10.156]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3A0453F774; Mon, 25 Apr 2022 06:53:29 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org Cc: sudeep.holla@arm.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, gregkh@linuxfoundation.org, rafael@kernel.org, rostedt@goodmis.org, mingo@redhat.com, lukasz.luba@arm.com Subject: [PATCH v2] arch_topology: Trace the update thermal pressure Date: Mon, 25 Apr 2022 14:53:17 +0100 Message-Id: <20220425135317.5880-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Add trace event to capture the moment of the call for updating the thermal pressure value. It's helpful to investigate how often those events occurs in a system dealing with throttling. This trace event is needed since the old 'cdev_update' might not be used by some drivers. Also, the new trace event shows capacity value, not a cooling state. We already have a trace point 'pelt_thermal_tp' which after a change to trace event can be paired with this new 'thermal_pressure_update' and derive more insight what is going on in the system under pressure (and why). Reported-by: kernel test robot Signed-off-by: Lukasz Luba --- Hi all, This v2 solves the issue reported by build robot. After experiments and checks I decided to not add the EXPORT_TRACEPOINT_SYMBOL_GPL(thermal_pressure_update) The trace event shouldn't be used by modules, since they use the exported update function: EXPORT_SYMBOL_GPL(topology_update_thermal_pressure) which calls that trace event internally. The code duplication for updating thermal pressure in a modules is not recommended - that was the goal of introducing topology_update_thermal_pressure(). Changes in v2: - as suggested by Steve, I have swapped the fields - a new trace header, so no conflicts with thermal.h - added CREATE_TRACE_POINTS before header The v1 and discussion can be found here at: https://lore.kernel.org/lkml/20220419164801.29078-1-lukasz.luba@arm.com/ Regards, Lukasz drivers/base/arch_topology.c | 5 +++++ include/trace/events/thermal_pressure.h | 29 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 include/trace/events/thermal_pressure.h diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 1d6636ebaac5..20bdad18dccd 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -19,6 +19,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + static DEFINE_PER_CPU(struct scale_freq_data __rcu *, sft_data); static struct cpumask scale_freq_counters_mask; static bool scale_freq_invariant; @@ -195,6 +198,8 @@ void topology_update_thermal_pressure(const struct cpumask *cpus, th_pressure = max_capacity - capacity; + trace_thermal_pressure_update(cpu, th_pressure); + for_each_cpu(cpu, cpus) WRITE_ONCE(per_cpu(thermal_pressure, cpu), th_pressure); } diff --git a/include/trace/events/thermal_pressure.h b/include/trace/events/thermal_pressure.h new file mode 100644 index 000000000000..b68680201360 --- /dev/null +++ b/include/trace/events/thermal_pressure.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM thermal_pressure + +#if !defined(_TRACE_THERMAL_PRESSURE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_THERMAL_PRESSURE_H + +#include + +TRACE_EVENT(thermal_pressure_update, + TP_PROTO(int cpu, unsigned long thermal_pressure), + TP_ARGS(cpu, thermal_pressure), + + TP_STRUCT__entry( + __field(unsigned long, thermal_pressure) + __field(int, cpu) + ), + + TP_fast_assign( + __entry->thermal_pressure = thermal_pressure; + __entry->cpu = cpu; + ), + + TP_printk("cpu=%d thermal_pressure=%lu", __entry->cpu, __entry->thermal_pressure) +); +#endif /* _TRACE_THERMAL_PRESSURE_H */ + +/* This part must be outside protection */ +#include -- 2.17.1