Skip to content

x86: do not use TSC as cycle count - #88

Open
dreamliner787-9 wants to merge 1 commit into
seL4:masterfrom
au-ts:x86_cycle_count
Open

x86: do not use TSC as cycle count#88
dreamliner787-9 wants to merge 1 commit into
seL4:masterfrom
au-ts:x86_cycle_count

Conversation

@dreamliner787-9

Copy link
Copy Markdown

See #87 for more detail.

Test with seL4/seL4_libs#116.

See seL4#87 for more detail.

Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
@dreamliner787-9

Copy link
Copy Markdown
Author

I'm not quite sure on how to deal with this in the kernel though: https://github.com/seL4/seL4/blob/1326364bc9135d9445d936ebc01e38a402c1f4c6/include/arch/x86/arch/benchmark.h#L20

Changing that rdtsc to rdpmc means that the kernel will assume that userspace have set up the PMU accordingly.

@Indanz

Indanz commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

I'm not quite sure on how to deal with this in the kernel though: https://github.com/seL4/seL4/blob/1326364bc9135d9445d936ebc01e38a402c1f4c6/include/arch/x86/arch/benchmark.h#L20

Changing that rdtsc to rdpmc means that the kernel will assume that userspace have set up the PMU accordingly.

If it faults if it isn't set up properly, then it's not an option. Otherwise, the kernel can setup a sane init value at boot and use that. If PMC access is exported to user space, they can change the config later if they want.

But I think we should remove all kernel benchmarking code, is it uses by anyone? Most things you can measure from user space and it's easy to filter out high measurements caused by scheduling. If no one is actively using this, then high chances this isn't working anyway for one reason or the other.

@KurtWu10

Copy link
Copy Markdown

But I think we should remove all kernel benchmarking code, is it uses by anyone?

Yes, sDDF's echo server benchmarking relies on the kernel for kernel utilisation. Or are you referring to RFC-16 on the PMU cap?

@Indanz

Indanz commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Yes, sDDF's echo server benchmarking relies on the kernel for kernel utilisation.

What is it trying to measure? I would expect that the overhead caused by the kernel tracking would make any measurements done there close to useless.

Or are you referring to RFC-16 on the PMU cap?

No, that's unrelated.

Btw, neither of the sel4bench_private_serialize_pmc() implementation have a memory clobber in the asm, so compiler could be free to re-order memory accesses in unexpected ways.

@KurtWu10

Copy link
Copy Markdown

What is it trying to measure?

Per-pd user/kernel cycle counts. For kernel cycle counts, it shows whether the kernel is running on the fastpath.

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.

3 participants