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
Unknown Object (File)
Mar 11 2024, 5:01 PM
Unknown Object (File)
Feb 25 2024, 4:52 PM
Unknown Object (File)
Feb 14 2024, 1:39 AM
Unknown Object (File)
Feb 2 2024, 8:21 AM
Unknown Object (File)
Feb 2 2024, 8:21 AM
Unknown Object (File)
Dec 23 2023, 2:23 AM
Unknown Object (File)
Dec 10 2023, 11:22 PM
Unknown Object (File)
Nov 29 2023, 2:40 AM

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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/hwpmc/hwpmc_mod.c
1626 ↗(On Diff #42222)

Why is reload subtraction only done for process counter ?

1680 ↗(On Diff #42222)

Blank line is excessive.

1694 ↗(On Diff #42222)

There too.

2297 ↗(On Diff #42222)

Why freelist_mtx needs to be spinlock ?

2304 ↗(On Diff #42222)

return (pt);

2341 ↗(On Diff #42222)

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 ↗(On Diff #42222)

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 ↗(On Diff #42222)

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 ↗(On Diff #42222)

It's called from sched_switch with the thread_lock held.

sys/dev/hwpmc/hwpmc_mod.c
2357 ↗(On Diff #42542)

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

sys/dev/hwpmc/hwpmc_mod.c
2357 ↗(On Diff #42542)

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.