Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX support #2

Open
travisdowns opened this issue Jun 1, 2017 · 5 comments
Open

OSX support #2

travisdowns opened this issue Jun 1, 2017 · 5 comments

Comments

@travisdowns
Copy link
Owner

Should be easy to support OSX, in fact perhaps it already works.

We don't have a solution for reading performance counters on OSX, and it isn't clear the effort required to port the libpfc counters to that platform. It seems like PAPI won't work, but maybe we can get a driver from PCM?

@MattPD
Copy link

MattPD commented Jun 2, 2017

Hi!

Although I'm not currently a macOS user, I've noticed that Processor Counter Monitor (PCM; an open source fork of the discontinued Intel Performance Counter Monitor) provides support: https://github.com/opcm/pcm

In particular, its setup docs make a mention of the bundled MacMSRDriver:
https://github.com/opcm/pcm/tree/master/MacMSRDriver
https://github.com/opcm/pcm/blob/master/MAC_HOWTO.txt

@travisdowns
Copy link
Owner Author

Thanks @MattPD - I noticed the same thing: see for example the PCM link in the original comment which points to an Intel SWF thread describing how a user modified the mac driver. I probably wont' get to this for a while, first I'll add Linux support for libpfc, then Windows, then ...

@travisdowns
Copy link
Owner Author

Just linking in some additional comments on OSX support in an otherwise unrelated merge request.

@shinderuk
Copy link

Not sure this is relevant, but macOS supports so called diagnostic calls [1], and one of them, namely dgEnaPMC [2], enables RDPMC from user mode [3]. It can be called via inline assembly as demonstrated in [1], but requires a kernel flag. I haven't tried it yet, but it looks promising. Also, performance counters can be configured via the private kperf.framework. XNU's source contains a useful example [4].

[1] http://newosxbook.com/MOXiI.pdf, page 292
[2] https://github.com/apple/darwin-xnu/blob/main/osfmk/i386/Diagnostics.c#L304
[3] https://github.com/apple/darwin-xnu/blob/main/osfmk/i386/Diagnostics.c#L413
[4] https://github.com/apple/darwin-xnu/blob/main/tests/kpc.c#L120

@shinderuk
Copy link

No, dgEnaPMC call won't help. On my machine cpu_pmc_control is a no-op, probably due to #if !MONOTONIC condition. And I couldn't find any other place in XNU's source, where CR4_PCE is set. Sorry for bothering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants