Skip to content

Conversation

@mashtizadeh
Copy link
Contributor

On AMD processors libpmc was using the topic field (based on filename) to determine the counter's subclass. Unfortunately, the JSON definitions for AMD Zen 1-4 have the L3 counters in files shared with other counters.

This change has libpmc to use the pmu field (which is derived from the Unit field in JSON) to determine the correct counter subclass.

Sponsored by: Netflix

@github-actions
Copy link

github-actions bot commented Jan 23, 2026

Thank you for taking the time to contribute to FreeBSD!

There is an issue that needs to be resolved:

  • Missing Signed-off-by lines (cd8ae05)

Note

Please review CONTRIBUTING.md, then update and push your branch again.

@mashtizadeh
Copy link
Contributor Author

@bsdimp @gallatin

Copy link
Contributor

@mhorne mhorne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a much better approach, thanks.

Comment on lines 527 to 528
printf("PMC pmu '%s' is not supported!\n", pe->pmu);
return (ENODEV);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf("PMC pmu '%s' is not supported!\n", pe->pmu);
return (ENODEV);
printf("PMC pmu '%s' is not supported!\n", pe->pmu);
return (EOPNOTSUPP);

I suggest EOPNOTSUPP as an appropriate error that is already documented in pmc_attach(3).

Printing the error message in this case is not objectionable to me, but is not typical.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the pmc command line I couldn't tell several different errors apart. I believe were the only consumer of libpmc, AMDuProf uses our ioctl's directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the error reporting in libpmc/pmcstat/hwpmc is most sorely needing improvement, as many of the error codes are overloaded. Particularly in the allocation path.

I was not aware that AMDuProf uses the ioctls directly. That is somewhat unfortunate as it forces our hand to maintain these interfaces.

The PMC tools have been in maintenance mode/slow decay for many years. They break easily and subtly. I have a renewed interest in trying to define some kind of strategy here for how we might move forward w.r.t. maintenance and the prioritization of new/missing functionality.

So, let's keep in touch on this to discuss needs/wants when it comes to these tools.

On AMD processors libpmc was using the topic field (based on filename) to
determine the counter's subclass.  Unfortunately, the JSON definitions for
AMD Zen 1-4 have the L3 counters in files shared with other counters.

This change has libpmc to use the pmu field (which is derived from the Unit
field in JSON) to determine the correct counter subclass.

Sponsored by: Netflix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants