Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4424315ioa; Wed, 27 Apr 2022 03:40:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybHXm74MzNm9GXreMxKOR2N+AmVSUS7pkvVhqSukpD4tQTCrI94PJtxYIglZqkNKrW1YbF X-Received: by 2002:a63:d347:0:b0:39c:d7d5:77fc with SMTP id u7-20020a63d347000000b0039cd7d577fcmr23358751pgi.201.1651056026157; Wed, 27 Apr 2022 03:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056026; cv=none; d=google.com; s=arc-20160816; b=R0ZMfSiSwo/2ehipz6Kk1Ga6/Dwl38zPzx+cB5oO+vsYZVIYt6hXpccfCya5t0XyB4 4Vqyx4fUbUW5LVGTnvE2POmW5W5Xzr/W0Qj64/IAEHM5kVjrm8rWeeBCX1qhBJoShhkY J/5hnWAoZ9rHq3LVa6gjYkYYZXVmWV8VCg1Bwnk9ELxfQ1MMQ66ImrgPiJTOS5YN+M5z E8tOafIO+vZgBGOA+Q4jy/INyvgNv8DIGNS9YkXo1zRZRqCqmru5SXOTlkhXWQN0Ghgb DKG+gFDBkJc3UShWbARFZlo75rX4PFXt+uMkzCv11mudeaX3S8fF4sIkIrtZOVo1XtZY s+Pg== 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=KwoJHgC+bd4Rw2HlV2E+GHqyRiJtWIB/76lgyX3VvY4=; b=DcQjIo1MM79jHAXoK4a06SVI6JJv9LmYWsM5eyc3RttIqiIlY29Y6ZQB42Cg9hGBAI Z2+Hop2T7Y3Eqa+Bkw8hXAoZJSz5bXOq/Dln+K6pWwl7wNlNN/kzVBNctzZ2lg+GQSRR qakUii3efjU76rrFiPdjAEfFAtDBJ6D9C4NxdnIVV9/J1wC2opR7Ct+XUhRXhV74n38Z XVdrp4EXBqTpZB+TNgtBiCl1u+33EsXbLke40J6IkZx+EC6BSvXSdze+3OsDKHIT4gYO 0iLDMEQKX9exu5f9XiJkbSIy2LtS9E70/td19jDAaI0BAIfK1WghW7tbUEIY1V16WsHJ pGvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 9-20020a17090a0cc900b001bf207bdb67si1293336pjt.47.2022.04.27.03.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:40:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC9B63E2827; Wed, 27 Apr 2022 02:51:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359320AbiD0IL3 (ORCPT + 99 others); Wed, 27 Apr 2022 04:11:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354468AbiD0IL0 (ORCPT ); Wed, 27 Apr 2022 04:11:26 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7EAE551E71 for ; Wed, 27 Apr 2022 01:08:16 -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 3FC8AED1; Wed, 27 Apr 2022 01:08:16 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.7.196]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1B42C3F5A1; Wed, 27 Apr 2022 01:08:13 -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 v4] arch_topology: Trace the update thermal pressure Date: Wed, 27 Apr 2022 09:08:06 +0100 Message-Id: <20220427080806.1906-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 occur in a system dealing with throttling. This trace event is needed since the old 'cdev_update' might not be used by some drivers. The old 'cdev_update' trace event only provides a cooling state value: [0, n]. That state value then needs additional tools to translate it: state -> freq -> capacity -> thermal pressure. This new trace event just stores proper thermal pressure value in the trace buffer, no need for additional logic. This is helpful for cooperation when someone can simply sends to the list the trace buffer output from the platform (no need from additional information from other subsystems). There are also platforms which due to some design reasons don't use cooling devices and thus don't trigger old 'cdev_update' trace event. They are also important and measuring latency for the thermal signal raising/decaying characteristics is in scope. This new trace event would cover them as well. 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 thermal pressure (and why). Signed-off-by: Lukasz Luba --- Changes v4: - following Greg's comment, removed the test robot tag 'Reported-by' which is not need for this patch; the compilation issue was captured in v1 not in mainline code The v3 is here: https://lore.kernel.org/lkml/20220427073551.19032-1-lukasz.luba@arm.com/ The v2 is here: https://lore.kernel.org/lkml/20220425135317.5880-1-lukasz.luba@arm.com/ 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 f73b836047cf..579c851a2bd7 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