From: sashiko-bot@kernel.org
To: "Athira Rajeev" <atrajeev@linux.ibm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH V3 1/6] powerpc/perf: Add HTM PMU driver to expose Hardware Trace Macro data
Date: Sat, 25 Jul 2026 07:45:47 +0000 [thread overview]
Message-ID: <20260725074548.2B8B21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260725065942.78839-2-atrajeev@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Returning -ENODEV from pmu->add() does not act as a hard failure, causing a continuous retry loop that floods the hypervisor.
- [Medium] Ignored PERF_EF_RELOAD and PERF_EF_UPDATE flags break frequency-based unthrottling and fail to prevent context-switch interruption.
--
--- Patch [1]: [PATCH V3 1/6] powerpc/perf: Add HTM PMU driver to expose Hardware Trace Macro data ---
commit e3070ea34290d3e6db9f94435894d38b1866fb0b
Author: Athira Rajeev <atrajeev@linux.ibm.com>
powerpc/perf: Add HTM PMU driver to expose Hardware Trace Macro data
This commit adds a new "htm" Performance Monitoring Unit (PMU) driver to
expose Hardware Trace Macro (HTM) control via the perf interface. It
configures the trace using the H_HTM hypervisor call with a 28-bit packed
event configuration. The driver tracks tracing state to manage start, stop,
add, and del operations and attempts to handle hypervisor errors.
> diff --git a/arch/powerpc/perf/htm-perf.c b/arch/powerpc/perf/htm-perf.c
> new file mode 100644
> index 0000000000000..4e4c924ecfd05
> --- /dev/null
> +++ b/arch/powerpc/perf/htm-perf.c
[ ... ]
> @@ -201,15 +201,6 @@ static int htm_event_init(struct perf_event *event)
>
> static void htm_event_start(struct perf_event *event, int flags)
> {
> int rc, ret, retries = 0;
> struct htm_config cfg;
> struct htm_target_id *target = event->pmu_private;
>
> /*
> * Ignore context-switch re-enables. The perf core passes
> * PERF_EF_RELOAD on context-switch-in. HTM tracing is
> * continuous at hardware level, no hcall needed.
> */
> if (flags & PERF_EF_RELOAD)
> return;
[Severity: Medium]
Does ignoring PERF_EF_RELOAD here break unthrottling for frequency-based
events?
When an event opened in frequency mode is unthrottled, the core restarts it
by calling event->pmu->start(event, PERF_EF_RELOAD). Will ignoring this flag
leave the hardware trace permanently halted?
Also, does ignoring this flag actually prevent context switches from stopping
the hardware? Context-switch-in calls pmu->add(event, PERF_EF_START), which
this driver translates to htm_event_start(event, 0), and context-switch-out
calls pmu->del(event, 0), translated to htm_event_stop(event, 0). Will the
hardware still be interrupted on every context switch despite these checks?
[ ... ]
> @@ -235,15 +235,6 @@ static void htm_event_start(struct perf_event *event, int flags)
> static void htm_event_stop(struct perf_event *event, int flags)
> {
> int rc, ret, retries = 0;
> struct htm_config cfg;
> struct htm_target_id *target = event->pmu_private;
>
> /*
> * Ignore context-switch-out stops. The perf core passes
> * PERF_EF_UPDATE on context-switch-out. Do not stop the hcall.
> */
> if (flags & PERF_EF_UPDATE)
> return;
[Severity: Medium]
Does ignoring PERF_EF_UPDATE here prevent the core from correctly stopping
the event during dynamic frequency adjustments?
[ ... ]
> @@ -275,15 +275,6 @@ static void htm_event_stop(struct perf_event *event, int flags)
> static int htm_event_add(struct perf_event *event, int flags)
> {
> int rc, ret, retries = 0;
> unsigned long param1 = -1, param2 = -1;
> struct htm_target_id *target = event->pmu_private;
> struct htm_config cfg = target->cfg;
>
> /*
> * pmu->add() is invoked in an atomic context with interrupts disabled
> * and hardware context locks held. sleeping is impossible. Only retry
> * on transient H_BUSY. On H_LONG_BUSY_* (-EAGAIN) and other errors, the
> * loop exits and we return -ENODEV, which is a hard failure: the perf
> * core will not reschedule the event. Returning -EAGAIN here would cause
> * the perf core to re-queue the event and call pmu->add() again on every
> * context switch, flooding the hypervisor with H_HTM_OP_CONFIGURE hcalls
> * exactly when it has requested a long backoff delay.
> */
> do {
> rc = htm_hcall_wrapper(htmflags, cfg.nodeindex, cfg.nodalchipindex,
> cfg.coreindexonchip, cfg.htmtype,
> H_HTM_OP_CONFIGURE, param1, param2, 0);
> ret = htm_return_check(rc);
> } while (ret == -EBUSY && ++retries < MAX_RETRIES);
>
> if (ret <= 0)
> return -ENODEV;
[Severity: High]
Does returning -ENODEV here actually prevent the core from rescheduling the
event?
Looking at event_sched_in() in kernel/events/core.c, any non-zero return
code from pmu->add() is overridden to -EAGAIN and the event state is set to
inactive:
kernel/events/core.c:event_sched_in() {
...
if (event->pmu->add(event, PERF_EF_START)) {
perf_event_set_state(event, PERF_EVENT_STATE_INACTIVE);
event->oncpu = -1;
ret = -EAGAIN;
goto out;
}
...
}
Will this cause the multiplexing logic to retry scheduling on the next timer
tick, creating an infinite loop that floods the hypervisor with configure
hcalls exactly when it requested a long backoff delay?
Should this instead return 0 and call perf_event_disable_inatomic() so the
core processes the disable request and marks it PERF_EVENT_STATE_OFF?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260725065942.78839-1-atrajeev@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-07-25 7:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 6:59 [PATCH V3 0/6] powerpc/perf: Add HTM PMU driver and perf AUX support Athira Rajeev
2026-07-25 6:59 ` [PATCH V3 1/6] powerpc/perf: Add HTM PMU driver to expose Hardware Trace Macro data Athira Rajeev
2026-07-25 7:45 ` sashiko-bot [this message]
2026-07-25 6:59 ` [PATCH V3 2/6] powerpc/perf: Reject duplicate HTM target reservations Athira Rajeev
2026-07-25 6:59 ` [PATCH V3 3/6] powerpc/perf: Add AUX buffer management to capture HTM trace data Athira Rajeev
2026-07-25 7:45 ` sashiko-bot
2026-07-25 6:59 ` [PATCH V3 4/6] powerpc/perf: Capture the HTM memory configuration as part of perf data Athira Rajeev
2026-07-25 7:43 ` sashiko-bot
2026-07-25 6:59 ` [PATCH V3 5/6] docs: ABI: sysfs-bus-event_source-devices-htm: Document sysfs event format entries for htm pmu Athira Rajeev
2026-07-25 6:59 ` [PATCH V3 6/6] powerpc/perf/htm: Add documentation for Hardware Trace Macro PMU Athira Rajeev
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=20260725074548.2B8B21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atrajeev@linux.ibm.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox