Page MenuHomeFreeBSD

Boost thread priority while changing CPU frequency
ClosedPublic

Authored by gallatin on Apr 30 2018, 11:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 21 2024, 6:13 PM
Unknown Object (File)
Dec 23 2023, 11:37 AM
Unknown Object (File)
Dec 18 2023, 11:11 AM
Unknown Object (File)
Dec 3 2023, 12:41 AM
Unknown Object (File)
Sep 7 2023, 2:22 AM
Unknown Object (File)
Sep 7 2023, 2:22 AM
Unknown Object (File)
Sep 7 2023, 2:21 AM
Unknown Object (File)
Sep 7 2023, 2:20 AM
Subscribers

Details

Summary

When powerd tries to adjust the frequency of a core which is CPU bound running a kernel thread (typically a NIC driver ithread, or iflib gtaskq), it can get "stuck" since its lower priority than the kernel thread. Worse, it is stuck holding Giant, which causes many things to seem to "freeze". This leads to the CPU-bound kernel thread continuing to run on a down-clocked core, and terrible performance.

If we temporarily boost powerd's priority for the duration of the frequency adjustment, then the core will get up-clocked immediately, and we'll have much better performance.

PI_NET - 1 was chosen for the boosted prio, as I've seen this most frequently with NIC ithreads and iflib gtaskqs.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This seems sane to me, but my suspend/resume skills aren't what they were in 2005....

This revision is now accepted and ready to land.May 1 2018, 3:05 AM

Adding kib@.

It's not clear to me why to prefer PI_NET - 1 over, say, PRI_MIN in this case. There's nothing about powerd that is network specific.

I've replaced the arbitrary PI_NET - 1 to PRI_MIN, as suggested by John

This revision now requires review to proceed.May 1 2018, 8:25 PM
In D15246#321533, @jhb wrote:

Adding kib@.

It's not clear to me why to prefer PI_NET - 1 over, say, PRI_MIN in this case. There's nothing about powerd that is network specific.

Sorry about that.. That was just the first thing I found that worked in the only scenario where I could easily reproduce it. I've updated the patch to use PRI_MIN.

I am not sure why do you use sched_lend_prio(). This method is supposed to be used when the thread lends priority from another thread, which is not the case there. I would just use sched_prio().

If you do not use sched_lend_prio(), then you can rely on the subr_trap.c:userret() to return the user thread priority reset.

Change to using sched_prio() rather than sched_lend_prio, as suggested by @kib

This revision is now accepted and ready to land.May 2 2018, 4:20 PM
This revision was automatically updated to reflect the committed changes.