From nobody Tue Dec 9 02:55:05 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CDE92E22BE for ; Wed, 12 Nov 2025 23:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762991621; cv=none; b=CxishFyGYXJBXbKFdw7zcx7uZFThsXwOmqmtL1CpyLzty3oFP5R+peyvyK+4zZfyCOg4KRdgmEkYev/dgxdN2wMJXmZBDg+fADpjy5/DnhXObbjK3iq4JGi9hYK4+RrOjVPidFlK/eLoxx5CbWiRmqoWySjOjCCMyptgKcyLRDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762991621; c=relaxed/simple; bh=ENGPD0aIdY+2YhPwx5lnx6WYkkApmZ92GCEve7RFK/U=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=hGlR7cNc4B9Qo4KNAnRnbXc0YUKBp8TL5LnB6oDj9DFuN6UCg8Ke/eFtfBMOyet4CXs7sY1sFyx6v8FqDqx91a+UEqobhhxQhAZH79SXAO4t/2y4A45nod+aCPy3eVpDwKIH4SQY2ozqI4TTvKf03eNpgmdvjVOmHBj7vJyVsUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pY/vjHJ4; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pY/vjHJ4" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-297f8a2ba9eso5131395ad.3 for ; Wed, 12 Nov 2025 15:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1762991620; x=1763596420; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=G2fCelaOXaY0hKXLaw4yZFPLF+MlvdQQ3DNLXys3oQE=; b=pY/vjHJ4muuy7ZFlb6oiGwKk8ICttYUPvsz7POoLuJpNFI4/Fd4kJY+JuPbdz4+oGW e9jcl4jvBnctL6ab1Uw6ABTDhd/R0L5kx6nvzzrFxvtMymt1CjBOzwuc4TbcUtVkrXce wfqjPm+Xo8dBZD09GCwvfMZ8ah9NkOS9z8JL6w8Oz5RYKDQForv4sL78EMwJYwHsZ7O6 6vM/OFw4wj+hetN66DLNy3jw1nXKlEtZIDQmfo3h/l9nQyA5DkY0gGDMUOjyObYruaqi mArdCH8XcXHP42eu2WQDRPYRJY9/eYihFlq9IHAO76Z0mhPdHDSf1millzriK6vvu+3K 9dpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762991620; x=1763596420; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=G2fCelaOXaY0hKXLaw4yZFPLF+MlvdQQ3DNLXys3oQE=; b=rDciAJRVNToKCE+lzUx81Ky3Nb6GmDP1uM9v0NGOB/NL9OPX+Vsky3JOBOURrprqTU GFmKqfi6pREcKExYzPjXYpIgJwKgnDHLl3mqXoIMBMJBDnBgoJFh9amSOkKeHKAOGxQp AJBPNTSqS19RgR99156n72l8MNKsI+A+MXseM/zRNpHukoWsd+dFivHsFe126DygVWjc AtjQM0sJL4jcvgEaCCj86IMm7yEPJiRFT6E006C9DnD7SOuW+xMupmC2RsJyFh1uDRDt 99ToWExg0pzwniGGmmStBugvHwwbG9qqxz/XpICU+oxpBZkZuZ2vNITxYKcnjlmf1vS3 /Ffw== X-Forwarded-Encrypted: i=1; AJvYcCWTIgm66X3O8zI1MNIsI9tWhF2QAlQJY5RUiZkM4VUPD/jPPunMEHZ/whr2zlpA+8lPwSuUzT5/qDK6ql8=@vger.kernel.org X-Gm-Message-State: AOJu0YxzMj12L0bn+JE0rYhUNLxUHotjz3ZLjBNeWbZ9t/T49mm5zw0x TZGYCqyCeaGZwp9JIrNcyWRMshdcBdB+f/eCZS/3hJAzJFXacdWZ4CpwOhxrCh0BYGnQ+cX3gEE if9HNjwpmAK2qOQ== X-Google-Smtp-Source: AGHT+IF7hTHhrm0qYbt1kdGgwC2gzoDhVXbYo4QhlWXJhezRX7mAL/XfnnuESy82/pQJzT4cXDYe7+WHmgieIA== X-Received: from dlbur14.prod.google.com ([2002:a05:7022:ea4e:b0:119:49ca:6b9c]) (user=wusamuel job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:d4c3:b0:28e:756c:707e with SMTP id d9443c01a7336-2984eda94d4mr59926575ad.33.1762991619647; Wed, 12 Nov 2025 15:53:39 -0800 (PST) Date: Wed, 12 Nov 2025 15:51:53 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.51.2.1041.gc1ab5b90ca-goog Message-ID: <20251112235154.2974902-1-wusamuel@google.com> Subject: [PATCH v1] cpufreq: Add policy_frequency trace event From: Samuel Wu To: "Rafael J. Wysocki" , Viresh Kumar , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: Samuel Wu , kernel-team@android.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The existing cpu_frequency trace_event can be verbose, emitting an event for every CPU in the policy even when their frequencies are identical. This patch adds a new policy_frequency trace event, which provides a more efficient alternative to cpu_frequency trace event. This option allows users who only need frequency at a policy level more concise logs with simpler analysis. Signed-off-by: Samuel Wu --- drivers/cpufreq/cpufreq.c | 2 ++ include/trace/events/power.h | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4472bb1ec83c..b65534a4fd9a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -345,6 +345,7 @@ static void cpufreq_notify_transition(struct cpufreq_po= licy *policy, pr_debug("FREQ: %u - CPUs: %*pbl\n", freqs->new, cpumask_pr_args(policy->cpus)); =20 + trace_policy_frequency(freqs->new, policy->cpu); for_each_cpu(cpu, policy->cpus) trace_cpu_frequency(freqs->new, cpu); =20 @@ -2214,6 +2215,7 @@ unsigned int cpufreq_driver_fast_switch(struct cpufre= q_policy *policy, arch_scale_freq_ref(policy->cpu)); cpufreq_stats_record_transition(policy, freq); =20 + trace_policy_frequency(freq, policy->cpu); if (trace_cpu_frequency_enabled()) { for_each_cpu(cpu, policy->cpus) trace_cpu_frequency(freq, cpu); diff --git a/include/trace/events/power.h b/include/trace/events/power.h index 82904291c2b8..87dbd53c8ea1 100644 --- a/include/trace/events/power.h +++ b/include/trace/events/power.h @@ -188,6 +188,27 @@ DEFINE_EVENT(cpu, cpu_frequency, TP_ARGS(frequency, cpu_id) ); =20 +TRACE_EVENT(policy_frequency, + + TP_PROTO(unsigned int frequency, unsigned int policy_cpu), + + TP_ARGS(frequency, policy_cpu), + + TP_STRUCT__entry( + __field(u32, frequency) + __field(u32, policy_cpu) + ), + + TP_fast_assign( + __entry->frequency =3D frequency; + __entry->policy_cpu =3D policy_cpu; + ), + + TP_printk("frequency=3D%lu policy_cpu=3D%lu", + (unsigned long)__entry->frequency, + (unsigned long)__entry->policy_cpu) +); + TRACE_EVENT(cpu_frequency_limits, =20 TP_PROTO(struct cpufreq_policy *policy), --=20 2.51.2.1041.gc1ab5b90ca-goog