Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vikram Singh" <vikram.singh3@oss.qualcomm.com>
Cc: linux-perf-users@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 5/7] riscv: pmu: Add driver for Control Transfer Records Ext
Date: Wed, 25 Nov 2026 09:09:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-232973@kernel.org> (raw)
In-Reply-To: <20261125083942.3695072-6-vikram.singh3@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 14 potential
issues to consider:
- [Critical] riscv: pmu: perf_ctx_data type confusion and missing RCU in
  CTR task context
- [High] riscv: pmu: NULL event->ctx->task dereference in
  riscv_pmu_ctr_add() and del()
- [High] riscv: pmu: inverted CTRDATA_CCV check and cycle truncation in
  ctr_get_cycles()
- [High] riscv: pmu: missing SxCSRIND check and hardcoded CSR_SIREG* in
  CTR helpers
- [High] riscv: pmu: unmerged CSR_CTRCTL without filtering and hardirq
  pr_warn()
- [High] riscv: pmu: PERF_SAMPLE_BRANCH_HV rejected when H extension is
  absent
- [Medium] riscv: pmu: missing CTR reset in riscv_pmu_ctr_restore() and
  unpaused save
- [Medium] riscv: pmu: 32-bit truncation of CSR_CTRCTL filter bits on
  CONFIG_32BIT
- [Medium] riscv: pmu: reserved SCTRDEPTH_MASK write and unclamped
  ctr_get_depth()
- [Medium] riscv: pmu: broken !CONFIG_RISCV_CTR stubs and guards in
  riscv_pmu.h
- [Medium] riscv: pmu: section mismatch and unsafe CSR probing in
  riscv_pmu_ctr_init()
- [Medium] riscv: pmu: call and return inhibit bits left set for
  CTRCTL_RASEMU
- [Medium] riscv: pmu: early return and HV kernel enable in
  branch_type_to_ctr()
- [Low] riscv: pmu: redundant CSR_ISELECT writes in get/set_ctr_regset()
--

commit d1deee5d4cfeac01fee55cdd3cfa24ef329d2acc
Author: Vikram Singh <vikram.singh3@oss.qualcomm.com>

riscv: pmu: Add driver for Control Transfer Records Ext

This commit adds a driver for the RISC-V Control Transfer Records (CTR)
extension to support hardware branch stack sampling in perf.

> diff --git a/drivers/perf/Kconfig b/drivers/perf/Kconfig
> index 245e7bb763b99..063339ad7691b 100644
> --- a/drivers/perf/Kconfig
> +++ b/drivers/perf/Kconfig
> @@ -129,6 +129,17 @@ config ANDES_CUSTOM_PMU
>  
>  	  If you don't know what to do here, say "Y".
>  
> +config RISCV_CTR
> +       bool "Enable support for Control Transfer Records (CTR)"
> +       depends on PERF_EVENTS && RISCV_PMU
> +       default y

[Severity: Medium]
Should RISCV_CTR depend on 64BIT, or access the upper half of CSR_CTRCTL
via CSR_CTRCTLH on 32-bit builds?

On CONFIG_32BIT=y, csr_read() and csr_write() cast values to a 32-bit
unsigned long, truncating bits 33..47 (CTR_BRANCH_FILTERS_INH) in
riscv_pmu_ctr_enable() and check_available_filters().

[ ... ]

> diff --git a/drivers/perf/riscv_ctr.c b/drivers/perf/riscv_ctr.c
> new file mode 100644
> index 0000000000000..649b68247ff56
> --- /dev/null
> +++ b/drivers/perf/riscv_ctr.c
> @@ -0,0 +1,608 @@

[ ... ]

> +static inline u64 get_ctr_src_reg(unsigned int ctr_idx)
> +{
> +	return csr_indirect_read(CSR_SIREG, CTR_ENTRIES_FIRST, ctr_idx);
> +}
> +
> +static inline void set_ctr_src_reg(unsigned int ctr_idx, u64 value)
> +{
> +	return csr_indirect_write(CSR_SIREG, CTR_ENTRIES_FIRST, ctr_idx, value);
> +}
> +
> +static inline u64 get_ctr_tgt_reg(unsigned int ctr_idx)
> +{
> +	return csr_indirect_read(CSR_SIREG2, CTR_ENTRIES_FIRST, ctr_idx);
> +}
> +
> +static inline void set_ctr_tgt_reg(unsigned int ctr_idx, u64 value)
> +{
> +	return csr_indirect_write(CSR_SIREG2, CTR_ENTRIES_FIRST, ctr_idx, value);
> +}
> +
> +static inline u64 get_ctr_data_reg(unsigned int ctr_idx)
> +{
> +	return csr_indirect_read(CSR_SIREG3, CTR_ENTRIES_FIRST, ctr_idx);
> +}
> +
> +static inline void set_ctr_data_reg(unsigned int ctr_idx, u64 value)
> +{
> +	return csr_indirect_write(CSR_SIREG3, CTR_ENTRIES_FIRST, ctr_idx, value);
> +}

[Severity: High]
Should these helpers pass CSR_IREG, CSR_IREG2 and CSR_IREG3 instead of
hardcoding S-mode CSR_SIREG*, and should riscv_pmu_ctr_init(),
riscv_pmu_ctr_starting_cpu() and riscv_pmu_ctr_dying_cpu() check
riscv_isa_extension_available(NULL, SxCSRIND)?

csr_indirect_read() and csr_indirect_write() write CSR_ISELECT, which maps
to CSR_MISELECT under CONFIG_RISCV_M_MODE.  Also, neither cpufeature.c nor
the CTR init and hotplug paths verify that SxCSRIND is present before
accessing indirect CSRs, which will trap with an illegal instruction
exception if SxCSRIND is absent.

[ ... ]

> +static inline unsigned int ctr_get_cycles(u64 ctr_data)
> +{
> +	const unsigned int cce = FIELD_GET(CTRDATA_CCE_MASK, ctr_data);
> +	const unsigned int ccm = FIELD_GET(CTRDATA_CCM_MASK, ctr_data);
> +
> +	if (ctr_data & CTRDATA_CCV)
> +		return 0;
> +
> +	/* Formula to calculate cycles from spec: (2^12 + CCM) << CCE-1 */
> +	if (cce > 0)
> +		return (4096 + ccm) << (cce - 1);
> +
> +	return FIELD_GET(CTRDATA_CCM_MASK, ctr_data);
> +}

[Severity: High]
Is the CTRDATA_CCV check inverted here?  Per the CTR specification,
CTRDATA_CCV is the Cycle Count Valid bit (1 when valid), so this returns 0
for every valid cycle count and decodes invalid ones.

Also, when cce >= 5, (4096 + ccm) << (cce - 1) exceeds 16 bits, and
assigning it to the 16-bit entry->cycles bitfield in capture_ctr_flags()
truncates the upper bits instead of clamping to U16_MAX.

> +static inline unsigned int ctr_get_type(u64 ctr_data)
> +{
> +	return FIELD_GET(CTRDATA_TYPE_MASK, ctr_data);
> +}
> +
> +static inline unsigned int ctr_get_depth(u64 ctr_depth)
> +{
> +	/* Depth table from CTR Spec: 2.4 sctrdepth.
> +	 *
> +	 * sctrdepth.depth       Depth
> +	 * 000			- 16
> +	 * 001			- 32
> +	 * 010			- 64
> +	 * 011			- 128
> +	 * 100			- 256
> +	 *
> +	 * Depth = 16 * 2 ^ (ctrdepth.depth)
> +	 * or
> +	 * Depth = 16 << ctrdepth.depth.
> +	 */
> +	return 16 << FIELD_GET(SCTRDEPTH_MASK, ctr_depth);
> +}

[Severity: Medium]
Can ctr_get_depth() return more than MAX_BRANCH_RECORDS (256), and should
riscv_pmu_ctr_init() and riscv_pmu_ctr_starting_cpu() write SCTRDEPTH_MAX
(0x4) instead of SCTRDEPTH_MASK (0x7) to CSR_SCTRDEPTH?

Values 0x5..0x7 are reserved in sctrdepth.depth.  Writing 0x7 is not
guaranteed by WARL rules to select 256, and if CSR_SCTRDEPTH reports a
value above 4, ctr_get_depth() returns up to 2048 and overflows
cpuc->branches->branch_entries[256] and task_ctx->store[256].

> +static inline struct riscv_perf_task_context *task_context(void *ctx)
> +{
> +	return (struct riscv_perf_task_context *)ctx;
> +}
> +
> +/* Reads CTR entry at idx and stores it in entry struct. */
> +static bool get_ctr_regset(struct ctr_regset *entry, unsigned int idx)
> +{
> +	entry->src = get_ctr_src_reg(idx);
> +
> +	if (!ctr_record_valid(entry->src))
> +		return false;
> +
> +	entry->src = entry->src;
> +	entry->target = get_ctr_tgt_reg(idx);
> +	entry->ctr_data = get_ctr_data_reg(idx);
> +
> +	return true;
> +}
> +
> +static void set_ctr_regset(struct ctr_regset *entry, unsigned int idx)
> +{
> +	set_ctr_src_reg(idx, entry->src);
> +	set_ctr_tgt_reg(idx, entry->target);
> +	set_ctr_data_reg(idx, entry->ctr_data);
> +}

[Severity: Low]
Each call to get_ctr_*_reg() and set_ctr_*_reg() saves IRQs and writes
CSR_ISELECT, even though selecting CTR_ENTRIES_FIRST + idx once in
CSR_ISELECT exposes source, target and data across CSR_IREG, CSR_IREG2 and
CSR_IREG3 simultaneously.  get_ctr_regset() also has a redundant
entry->src = entry->src assignment.

> +static u64 branch_type_to_ctr(int branch_type)
> +{
> +	u64 config = CTR_BRANCH_FILTERS_INH | CTRCTL_LCOFIFRZ;
> +
> +	if (branch_type & PERF_SAMPLE_BRANCH_USER)
> +		config |= CTRCTL_U_ENABLE;
> +
> +	if (branch_type & PERF_SAMPLE_BRANCH_KERNEL)
> +		config |= CTRCTL_KERNEL_ENABLE;
> +
> +	if (branch_type & PERF_SAMPLE_BRANCH_HV) {
> +		if (riscv_isa_extension_available(NULL, H))
> +			config |= CTRCTL_KERNEL_ENABLE;
> +	}
> +
> +	if (branch_type & PERF_SAMPLE_BRANCH_ANY) {
> +		config &= ~CTR_BRANCH_FILTERS_INH;
> +		return config;
> +	}

[Severity: Medium]
Does setting CTRCTL_KERNEL_ENABLE for PERF_SAMPLE_BRANCH_HV record host
kernel branches even when PERF_SAMPLE_BRANCH_KERNEL is excluded?

Also, returning early on PERF_SAMPLE_BRANCH_ANY skips the
PERF_SAMPLE_BRANCH_CALL_STACK check below, leaving CTRCTL_RASEMU unset when
both flags are specified.

[ ... ]

> +	if (branch_type & PERF_SAMPLE_BRANCH_CALL_STACK)
> +		config |= CTRCTL_RASEMU;

[Severity: Medium]
Does PERF_SAMPLE_BRANCH_CALL_STACK also need to clear CTRCTL_INDCALL_INH,
CTRCTL_DIRCALL_INH and CTRCTL_RET_INH?

When userspace enables LBR call-stack mode (such as perf record
--call-graph lbr), it sets PERF_SAMPLE_BRANCH_CALL_STACK without separate
call or return filter flags, so leaving those inhibit bits set in config
suppresses all call and return records.

[ ... ]

> +bool riscv_pmu_ctr_valid(struct perf_event *event)
> +{
> +	u64 branch_type = event->attr.branch_sample_type;
> +
> +	if (branch_type & ~allowed_filters) {
> +		pr_debug_once("Requested branch filters not supported 0x%llx\n",
> +			      branch_type & ~allowed_filters);
> +		return false;
> +	}
> +
> +	return true;
> +}

[Severity: High]
Does rejecting PERF_SAMPLE_BRANCH_HV when the H extension is absent break
default branch sampling on non-H systems?

When userspace does not specify branch privilege bits, perf_copy_attr()
automatically sets PERF_SAMPLE_BRANCH_HV whenever !attr->exclude_hv, so
check_available_filters() omitting PERF_SAMPLE_BRANCH_HV on systems without
H causes riscv_pmu_ctr_valid() to reject standard commands like perf record
-j any.

[ ... ]

> +static void riscv_pmu_ctr_restore(void *ctx)
> +{
> +	if (task_context(ctx)->stack_state == CTR_STATE_NONE ||
> +	    task_context(ctx)->callstack_users == 0) {
> +		return;
> +	}
> +
> +	riscv_pmu_ctr_reset();
> +	__riscv_pmu_ctr_restore(ctx);
> +
> +	task_context(ctx)->stack_state = CTR_STATE_NONE;
> +}
> +
> +static void __riscv_pmu_ctr_save(void *ctx, unsigned int depth)
> +{
> +	struct riscv_perf_task_context *task_ctx = ctx;
> +	struct ctr_regset *dst;
> +	unsigned int i;
> +
> +	for (i = 0; i < depth; i++) {
> +		dst = &task_ctx->store[i];
> +		if (!get_ctr_regset(dst, i))
> +			break;
> +	}
> +
> +	task_ctx->num_entries = i;
> +
> +	task_ctx->ctr_status = csr_read(CSR_SCTRSTATUS);
> +}

[Severity: Medium]
When riscv_pmu_ctr_restore() returns early because stack_state is
CTR_STATE_NONE or callstack_users is 0, riscv_pmu_ctr_sched_task() returns
immediately without calling riscv_pmu_ctr_reset().  Doesn't that leave the
previous task's CTR records in hardware for the incoming task?

Also, unlike ctr_read_entries(), __riscv_pmu_ctr_save() and
__riscv_pmu_ctr_restore() read and write CTR registers without clearing
CTR_BRANCH_ENABLE_BITS in CSR_CTRCTL, so branches taken inside the
save/restore loops can clobber the CTR entries when kernel recording is
enabled.

[ ... ]

> +void riscv_pmu_ctr_sched_task(struct perf_event_pmu_context *pmu_ctx, struct task_struct *task,
> +			      bool sched_in)
> +{
> +	struct riscv_pmu *rvpmu = to_riscv_pmu(pmu_ctx->pmu);
> +	struct cpu_hw_events *cpuc = this_cpu_ptr(rvpmu->hw_events);
> +	void *task_ctx;
> +
> +	if (!cpuc->ctr_users)
> +		return;
> +
> +	/* Save branch records in task_ctx on sched out */
> +	task_ctx = pmu_ctx ? task->perf_ctx_data : NULL;
> +	if (task_ctx) {
> +		if (sched_in)
> +			riscv_pmu_ctr_restore(task_ctx);
> +		else
> +			riscv_pmu_ctr_save(task_ctx, rvpmu->ctr_depth);
> +		return;
> +	}
> +
> +	/* Reset branch records on sched in */
> +	if (sched_in)
> +		riscv_pmu_ctr_reset();
> +}
> +
> +static inline bool branch_user_callstack(unsigned int br_type)
> +{
> +	return (br_type & PERF_SAMPLE_BRANCH_USER) &&
> +		(br_type & PERF_SAMPLE_BRANCH_CALL_STACK);
> +}
> +
> +void riscv_pmu_ctr_add(struct perf_event *event)
> +{
> +	struct riscv_pmu *rvpmu = to_riscv_pmu(event->pmu);
> +	struct cpu_hw_events *cpuc = this_cpu_ptr(rvpmu->hw_events);
> +
> +	if (branch_user_callstack(event->attr.branch_sample_type) &&
> +	    event->ctx->task->perf_ctx_data)
> +		task_context(event->ctx->task->perf_ctx_data)->callstack_users++;
> +
> +	perf_sched_cb_inc(event->pmu);
> +
> +	if (!cpuc->ctr_users++)
> +		riscv_pmu_ctr_reset();
> +}
> +
> +void riscv_pmu_ctr_del(struct perf_event *event)
> +{
> +	struct riscv_pmu *rvpmu = to_riscv_pmu(event->pmu);
> +	struct cpu_hw_events *cpuc = this_cpu_ptr(rvpmu->hw_events);
> +
> +	if (branch_user_callstack(event->attr.branch_sample_type) &&
> +	    event->ctx->task->perf_ctx_data)
> +		task_context(event->ctx->task->perf_ctx_data)->callstack_users--;

[Severity: Critical]
Isn't task->perf_ctx_data an RCU-protected pointer to struct perf_ctx_data,
whose ->data member holds the struct riscv_perf_task_context allocated from
pmu->task_ctx_cache?

Passing task->perf_ctx_data directly to task_context(),
riscv_pmu_ctr_save() and riscv_pmu_ctr_restore() without rcu_dereference()
or dereferencing cd->data treats the 40-byte struct perf_ctx_data wrapper
as a 6168-byte struct riscv_perf_task_context.  Updating callstack_users
corrupts cd->rcu_head, and __riscv_pmu_ctr_save() writes up to 256
ctr_regset entries past the end of struct perf_ctx_data into adjacent slab
objects.

[Severity: High]
Can event->ctx->task be NULL in riscv_pmu_ctr_add() and
riscv_pmu_ctr_del()?

For per-CPU events (pid == -1) configured with PERF_SAMPLE_BRANCH_USER |
PERF_SAMPLE_BRANCH_CALL_STACK, event->ctx->task is NULL, so dereferencing
event->ctx->task->perf_ctx_data causes a NULL pointer dereference when the
event is scheduled.

> +
> +	perf_sched_cb_dec(event->pmu);
> +	cpuc->ctr_users--;
> +	WARN_ON_ONCE(cpuc->ctr_users < 0);
> +}
> +
> +void riscv_pmu_ctr_enable(struct perf_event *event)
> +{
> +	u64 branch_type = event->attr.branch_sample_type;
> +	u64 ctr;
> +
> +	ctr = branch_type_to_ctr(branch_type);
> +	csr_write(CSR_CTRCTL, ctr);
> +}
> +
> +void riscv_pmu_ctr_disable(struct perf_event *event)
> +{
> +	/* Clear CTRCTL to disable the recording. */
> +	csr_write(CSR_CTRCTL, 0);
> +}

[Severity: High]
What happens when multiple CTR events are active on the same CPU?
riscv_pmu_ctr_enable() overwrites CSR_CTRCTL with a single event's filter
and riscv_pmu_ctr_disable() zeroes CSR_CTRCTL even when other CTR events
are still active.  Because ctr_read_entries() does not filter entries in
software by privilege or branch type (and branch_type_to_ctr() clears
CTRCTL_EXCINH, CTRCTL_INTRINH and CTRCTL_TRETINH even without
PERF_SAMPLE_BRANCH_KERNEL), kernel branch addresses recorded for one event
can be copied into a concurrent user-only event's sample buffer.

Also, in ctr_set_perf_entry_type(), CTRDATA_TYPE_CO_ROUTINE_SWAP maps to
PERF_BR_UNKNOWN and triggers an un-ratelimited pr_warn() in hardirq context
(up to 256 times per PMU overflow interrupt) whenever userspace executes
coroutine-swap jalr instructions under PERF_SAMPLE_BRANCH_ANY |
PERF_SAMPLE_BRANCH_TYPE_SAVE.

> +
> +/*
> + * Check for hardware supported perf filters here. To avoid missing
> + * any new added filter in perf, we do a BUILD_BUG_ON check, so make sure
> + * to update CTR_ALLOWED_BRANCH_FILTERS or CTR_EXCLUDE_BRANCH_FILTERS
> + * defines when adding support for it in below function.
> + */
> +static void __init check_available_filters(void)
> +{
> +	u64 ctr_ctl;
> +
> +	/*
> +	 * Ensure both perf branch filter allowed and exclude
> +	 * masks are always in sync with the generic perf ABI.
> +	 */
> +	BUILD_BUG_ON(CTR_PERF_BRANCH_FILTERS != (PERF_SAMPLE_BRANCH_MAX - 1));
> +
> +	allowed_filters = PERF_SAMPLE_BRANCH_USER      |
> +			  PERF_SAMPLE_BRANCH_KERNEL    |
> +			  PERF_SAMPLE_BRANCH_ANY       |
> +			  PERF_SAMPLE_BRANCH_HW_INDEX  |
> +			  PERF_SAMPLE_BRANCH_NO_FLAGS  |
> +			  PERF_SAMPLE_BRANCH_NO_CYCLES |
> +			  PERF_SAMPLE_BRANCH_TYPE_SAVE;
> +
> +	csr_write(CSR_CTRCTL, ~0);
> +	ctr_ctl = csr_read(CSR_CTRCTL);
> +	csr_write(CSR_CTRCTL, 0);

[ ... ]

> +int riscv_pmu_ctr_init(struct riscv_pmu *riscv_pmu)
> +{
> +	size_t size = sizeof(struct riscv_perf_task_context);
> +
> +	if (!riscv_isa_extension_available(NULL, SxCTR) ||
> +	    !riscv_isa_extension_available(NULL, SSCOFPMF))
> +		return 0;
> +
> +	riscv_pmu->pmu.task_ctx_cache =
> +		kmem_cache_create("ctr_task_ctx", size, sizeof(u64), 0, NULL);
> +	if (!riscv_pmu->pmu.task_ctx_cache)
> +		return -ENOMEM;
> +
> +	check_available_filters();
> +
> +	/* Set depth to maximum. */\n> +	csr_write(CSR_SCTRDEPTH, SCTRDEPTH_MASK);
> +	riscv_pmu->ctr_depth = ctr_get_depth(csr_read(CSR_SCTRDEPTH));

[Severity: Medium]
Calling __init check_available_filters() from non-__init
riscv_pmu_ctr_init() causes a section mismatch warning and will execute
freed .init.text if PMU probe is deferred or rebound after boot.

In addition, check_available_filters() and riscv_pmu_ctr_init() write ~0 to
CSR_CTRCTL (temporarily setting CTRCTL_U_ENABLE and CTRCTL_KERNEL_ENABLE)
and probe per-CPU CSRs in preemptible context without disabling preemption
or calling riscv_pmu_ctr_reset().  check_available_filters() also checks
whether each filter's own inhibit bit is writable rather than the
complement inhibit bits that branch_type_to_ctr() relies on, and
riscv_pmu_ctr_valid() never checks that at least one branch type filter is
set in branch_type.

[ ... ]

> diff --git a/include/linux/perf/riscv_pmu.h b/include/linux/perf/riscv_pmu.h
> index 448e0589875e5..f61e1fd364040 100644
> --- a/include/linux/perf/riscv_pmu.h
> +++ b/include/linux/perf/riscv_pmu.h
> @@ -108,6 +108,44 @@ int riscv_pmu_get_hpm_info(u32 *hw_ctr_width, u32 *num_hw_ctr);
>  int riscv_pmu_get_event_info(u32 type, u64 config, u64 *econfig);
>  #endif
>  
> +static inline bool riscv_pmu_ctr_supported(struct riscv_pmu *pmu)
> +{
> +	return !!pmu->ctr_depth;
> +}
> +
>  #endif /* CONFIG_RISCV_PMU */
>  
> +#ifdef CONFIG_RISCV_CTR
> +
> +bool riscv_pmu_ctr_valid(struct perf_event *event);
> +void riscv_pmu_ctr_consume(struct cpu_hw_events *cpuc, struct perf_event *event);
> +void riscv_pmu_ctr_sched_task(struct perf_event_pmu_context *pmu_ctx, struct task_struct *task,
> +			      bool sched_in);
> +void riscv_pmu_ctr_add(struct perf_event *event);
> +void riscv_pmu_ctr_del(struct perf_event *event);
> +void riscv_pmu_ctr_enable(struct perf_event *event);
> +void riscv_pmu_ctr_disable(struct perf_event *event);
> +void riscv_pmu_ctr_dying_cpu(void);
> +void riscv_pmu_ctr_starting_cpu(void);
> +int  riscv_pmu_ctr_init(struct riscv_pmu *riscv_pmu);
> +void riscv_pmu_ctr_finish(struct riscv_pmu *riscv_pmu);
> +
> +#else
> +
> +static inline bool riscv_pmu_ctr_valid(struct perf_event *event) { return false; }
> +static inline void riscv_pmu_ctr_consume(struct cpu_hw_events *cpuc,
> +					 struct perf_event *event) { }
> +static inline void riscv_pmu_ctr_sched_task(struct perf_event_pmu_context *,
> +					    struct task_struct *task, bool sched_in) { }
> +static void riscv_pmu_ctr_add(struct perf_event *event) { }
> +static void riscv_pmu_ctr_del(struct perf_event *event) { }

[Severity: Medium]
Does this build when CONFIG_RISCV_CTR=n or CONFIG_RISCV_PMU=n?

In the !CONFIG_RISCV_CTR stubs, riscv_pmu_ctr_sched_task() omits the first
parameter name (which fails under -std=gnu11), and riscv_pmu_ctr_add() and
riscv_pmu_ctr_del() are missing inline (triggering -Wunused-function
warnings).  Also, placing this block outside #ifdef CONFIG_RISCV_PMU
references struct cpu_hw_events and struct riscv_pmu when they have not
been declared.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125083942.3695072-1-vikram.singh3@oss.qualcomm.com?part=5

  reply	other threads:[~2026-11-25  9:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  8:39 [PATCH v6 0/7] riscv: pmu: Add support for Control Transfer Records Ext Vikram Singh
2026-11-25  8:39 ` [PATCH v6 1/7] perf: Increase the maximum number of branches remove_loops() can process Vikram Singh
2026-11-25  8:39 ` [PATCH v6 2/7] riscv: pmu: Add Control transfer records CSR definations Vikram Singh
2026-11-25  8:39 ` [PATCH v6 3/7] riscv: Add Control Transfer Records extension parsing Vikram Singh
2026-11-25  8:39 ` [PATCH v6 4/7] riscv: pmu: Add infrastructure for Control Transfer Record Vikram Singh
2026-11-25  8:52   ` sashiko-bot
2026-11-25  8:39 ` [PATCH v6 5/7] riscv: pmu: Add driver for Control Transfer Records Ext Vikram Singh
2026-11-25  9:09   ` sashiko-bot [this message]
2026-11-25  8:39 ` [PATCH v6 6/7] riscv: pmu: Integrate CTR Ext support in riscv_pmu_dev driver Vikram Singh
2026-11-25  9:01   ` sashiko-bot
2026-11-25  8:39 ` [PATCH v6 7/7] dt-bindings: riscv: add Sxctr ISA extension description Vikram Singh
2026-11-25  8:55   ` sashiko-bot
2026-11-25  9:09 ` [PATCH v6 0/7] riscv: pmu: Add support for Control Transfer Records Ext sashiko-bot

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=sashiko-outbox-232973@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vikram.singh3@oss.qualcomm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox