Page MenuHomeFreeBSD

Implement per-thread counters for PMC sampling --- redux
ClosedPublic

Authored by mmacy on May 7 2018, 5:06 AM.
Tags
None
Referenced Files
F110364366: D15335.diff
Mon, Feb 17, 9:06 AM
Unknown Object (File)
Wed, Jan 22, 4:07 AM
Unknown Object (File)
Jan 5 2025, 8:11 PM
Unknown Object (File)
Dec 11 2024, 4:24 PM
Unknown Object (File)
Dec 6 2024, 12:09 PM
Unknown Object (File)
Nov 27 2024, 5:22 AM
Unknown Object (File)
Nov 21 2024, 2:36 PM
Unknown Object (File)
Nov 20 2024, 8:48 PM

Details

Summary

This is D4227 with the changes requested by @jhb plus some additional bug fixes exposed on a cursory review. Not entirely sure how to test this until I bring in D7350.

Depends on D15155

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/dev/hwpmc/hwpmc_mod.c
1626

Why is reload subtraction only done for process counter ?

1680

Blank line is excessive.

1694

There too.

2297

Why freelist_mtx needs to be spinlock ?

2304

return (pt);

2341

So if some other consumer drain the pool in parallel, you can end up allocating the entries only to free them. Why not chomp the head of the list of needed length under the freelist_mtx, and then free the entries after unlock ? This also removes lock/unlock for each free.

sys/kern/kern_thr.c
270

Why not simply check PMC_PROC_IS_USING_PMCS() after the unlock, without else ? You call pmc hook after the unlock anyway, so it gives the same race.

Apply review suggestions

sys/dev/hwpmc/hwpmc_mod.c
1626

We automatically reset the counter on read. For processes we need to keep track of updates across all threads and then track the delta until the next reload. For threads the value won't exceed reloadcount.

2297

It's called from sched_switch with the thread_lock held.

sys/dev/hwpmc/hwpmc_mod.c
2346

Don't you need to remove pt from pmc_threadfreelist first ?

sys/dev/hwpmc/hwpmc_mod.c
2346

DOH

This revision is now accepted and ready to land.May 16 2018, 7:40 PM
This revision was automatically updated to reflect the committed changes.