From: kan.liang@linux.intel.com
To: peterz@infradead.org, mingo@redhat.com, namhyung@kernel.org,
irogers@google.com, mark.rutland@arm.com,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Cc: eranian@google.com, ctshao@google.com, tmricht@linux.ibm.com,
leo.yan@arm.com, Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH V3 01/16] perf: Clean up event in freq mode check
Date: Fri, 16 May 2025 11:28:38 -0700 [thread overview]
Message-ID: <20250516182853.2610284-2-kan.liang@linux.intel.com> (raw)
In-Reply-To: <20250516182853.2610284-1-kan.liang@linux.intel.com>
From: Kan Liang <kan.liang@linux.intel.com>
Add a helper to check if an event is in freq mode to improve the
readability.
No functional change.
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
kernel/events/core.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a84abc2b7f20..af78ec118e8f 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2442,6 +2442,11 @@ event_filter_match(struct perf_event *event)
perf_cgroup_match(event);
}
+static inline bool is_event_in_freq_mode(struct perf_event *event)
+{
+ return event->attr.freq && event->attr.sample_freq;
+}
+
static void
event_sched_out(struct perf_event *event, struct perf_event_context *ctx)
{
@@ -2479,7 +2484,7 @@ event_sched_out(struct perf_event *event, struct perf_event_context *ctx)
if (!is_software_event(event))
cpc->active_oncpu--;
- if (event->attr.freq && event->attr.sample_freq) {
+ if (is_event_in_freq_mode(event)) {
ctx->nr_freq--;
epc->nr_freq--;
}
@@ -2780,7 +2785,7 @@ event_sched_in(struct perf_event *event, struct perf_event_context *ctx)
if (!is_software_event(event))
cpc->active_oncpu++;
- if (event->attr.freq && event->attr.sample_freq) {
+ if (is_event_in_freq_mode(event)) {
ctx->nr_freq++;
epc->nr_freq++;
}
@@ -4391,11 +4396,11 @@ static void perf_adjust_freq_unthr_events(struct list_head *event_list)
if (hwc->interrupts == MAX_INTERRUPTS) {
hwc->interrupts = 0;
perf_log_throttle(event, 1);
- if (!event->attr.freq || !event->attr.sample_freq)
+ if (!is_event_in_freq_mode(event))
event->pmu->start(event, 0);
}
- if (!event->attr.freq || !event->attr.sample_freq)
+ if (!is_event_in_freq_mode(event))
continue;
/*
@@ -13129,7 +13134,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
hwc = &event->hw;
hwc->sample_period = attr->sample_period;
- if (attr->freq && attr->sample_freq)
+ if (is_event_in_freq_mode(event))
hwc->sample_period = 1;
hwc->last_period = hwc->sample_period;
--
2.38.1
next prev parent reply other threads:[~2025-05-16 18:29 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 18:28 [PATCH V3 00/16] perf: Fix the throttle logic for group kan.liang
2025-05-16 18:28 ` kan.liang [this message]
2025-05-17 12:59 ` [tip: perf/core] perf/core: Add the is_event_in_freq_mode() helper to simplify the code tip-bot2 for Kan Liang
2025-05-16 18:28 ` [PATCH V3 02/16] perf: Fix the throttle logic for a group kan.liang
2025-05-17 8:22 ` Ingo Molnar
2025-05-20 14:16 ` Liang, Kan
2025-05-18 19:18 ` Namhyung Kim
2025-05-20 14:47 ` Liang, Kan
2025-05-20 20:02 ` Namhyung Kim
2025-05-16 18:28 ` [PATCH V3 03/16] perf/x86/intel: Remove driver-specific throttle support kan.liang
2025-05-16 18:28 ` [PATCH V3 04/16] perf/x86/amd: " kan.liang
2025-05-16 18:28 ` [PATCH V3 05/16] perf/x86/zhaoxin: " kan.liang
2025-05-16 18:28 ` [PATCH V3 06/16] powerpc/perf: " kan.liang
2025-05-16 18:28 ` [PATCH V3 07/16] s390/perf: " kan.liang
2025-05-16 18:28 ` [PATCH V3 08/16] perf/arm: " kan.liang
2025-05-16 18:28 ` [PATCH V3 09/16] perf/apple_m1: " kan.liang
2025-05-16 18:28 ` [PATCH V3 10/16] alpha/perf: " kan.liang
2025-05-16 18:28 ` [PATCH V3 11/16] arc/perf: " kan.liang
2025-05-16 18:28 ` kan.liang
2025-05-18 21:58 ` Vineet Gupta
2025-05-18 21:58 ` Vineet Gupta
2025-05-16 18:28 ` [PATCH V3 12/16] csky/perf: " kan.liang
2025-05-16 18:28 ` [PATCH V3 13/16] loongarch/perf: " kan.liang
2025-05-16 18:28 ` [PATCH V3 14/16] sparc/perf: " kan.liang
2025-05-16 18:28 ` [PATCH V3 15/16] xtensa/perf: " kan.liang
2025-05-16 18:28 ` [PATCH V3 16/16] mips/perf: " kan.liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250516182853.2610284-2-kan.liang@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=ctshao@google.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tmricht@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.