[PATCH v6] arm64: perf: Add support caps in sysfs

Shaokun Zhang zhangshaokun at hisilicon.com
Tue Sep 8 03:28:25 EDT 2020


Hi Will,

在 2020/9/7 18:30, Will Deacon 写道:
> On Thu, Jul 23, 2020 at 07:56:52PM +0800, Shaokun Zhang wrote:
>> ARMv8.4-PMU introduces the PMMIR_EL1 registers and some new PMU events,
>> like STALL_SLOT etc, are related to it. Let's add a caps directory to
>> /sys/bus/event_source/devices/armv8_pmuv3_0/ and support slots from
>> PMMIR_EL1 registers in this entry. The user programs can get the slots
>> from sysfs directly.
>>
>> /sys/bus/event_source/devices/armv8_pmuv3_0/caps/slots is exposed
>> through sysfs. Both ARMv8.4-PMU and STALL_SLOT event are implemented,
>> it returns the slots from PMMIR_EL1, otherwise it will return an empty
>> string.
> 
> Returning an empty string seems a little hostile for parsing code here.
> Wouldn't we be better off either returning 0 or not exposing the file at

Since you have given comments[1] to get ride of armv8pmu_caps_attr_is_visible,
I will return 0 when cpu_pmu->reg_pmmir stores the ZERO.

+static ssize_t slots_show(struct device *dev, struct device_attribute *attr,
+                         char *page)
+{
+       struct pmu *pmu = dev_get_drvdata(dev);
+       struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu);
+       int slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK;
+
+       return snprintf(page, PAGE_SIZE, "0x%02x\n", slots);
+}

If you are ok, I will fix it in next version.

[1] https://www.spinics.net/lists/arm-kernel/msg824289.html

Thanks,
Shaokun


> all in the case that the feature is not supported?
> 
> Will
> 
> .
> 




More information about the linux-arm-kernel mailing list