Re: [PATCH v5 08/13] coresight: Interpret perf config with ATTR_CFG_GET_FLD()

From: James Clark

Date: Wed Nov 19 2025 - 10:15:42 EST




On 19/11/2025 2:37 pm, Leo Yan wrote:
On Wed, Nov 19, 2025 at 01:55:15PM +0000, James Clark wrote:

[...]

static ssize_t format_attr_contextid_show(struct device *dev,
struct device_attribute *attr,
char *page)
{
#if IS_ENABLED(CONFIG_ARM64)
if (is_kernel_in_hyp_mode())
return contextid2_show(dev, attr, page);
#endif

return contextid1_show(dev, attr, page);

Not having an #else implies that the contextid1_show() part is valid when
!CONFIG_ARM64, but that isn't right. That's why I had the WARN_ON because
it's dead code.

Based on ETMv3/v4 spec, would contextid1 always be valid ? (Though we do
not support context ID for ETMv3 yet).


It's not currently supported for ETMv3 in perf mode, which is the relevant thing here. So format_attr_contextid_show() never gets called for ETMv3 (equivalent to !CONFIG_ARM64).

Based on the spec it may be supported, but that's a different discussion and I doubt anyone wants it so it's unlikely to be added.

Personally I would drop the is_visible(). It makes sense for dynamically
hidden things, but these are all compile time. IMO it's cleaner to just not
include them to begin with, rather than include and then hide them. Then the
extra condition in format_attr_contextid_show() isn't needed because the
function doesn't exist:

This is fine for me, though in general I think the dynamic approach is
readable and extendable than the compile-time approach.

Thanks,
Leo

I agree in a perfect world, but it seems to have caused confusion and wasn't that clean because is_kernel_in_hyp_mode() only exists for arm64.

I'll send a new version without it.