Page MenuHomeFreeBSD

Running the sched_preempt handler in a critical section causes us to acquire the scheduler lock twice in a row. It is not necessary since interrupts aredisabled already in this path.
ClosedPublic

Authored by jeff on Dec 1 2019, 8:35 PM.
Tags
None
Referenced Files
F103471348: D22623.id65102.diff
Mon, Nov 25, 11:21 AM
Unknown Object (File)
Sun, Nov 24, 9:17 AM
Unknown Object (File)
Oct 26 2024, 11:14 AM
Unknown Object (File)
Oct 2 2024, 9:23 PM
Unknown Object (File)
Sep 30 2024, 11:10 PM
Unknown Object (File)
Sep 28 2024, 6:48 AM
Unknown Object (File)
Sep 18 2024, 9:43 AM
Unknown Object (File)
Sep 17 2024, 5:24 PM
Subscribers

Details

Summary

I am working on reducing the diffs in my scheduler locking change branch. https://github.com/freebsd/freebsd/compare/master...jwroberson:schedlock

This is a small change that allows the direct switch optimization in sched_preempt() to work as intended. Otherwise we grab the sched lock, set owepreempt, drop the sched lock, critical_exit, acquire the sched lock, see owepreempt, then switch.

Diff Detail

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

Event Timeline

jeff retitled this revision from Running the sched_preempt handler in a critical section causes us to acquire the scheduler lock twice in a row. It is not necessary since interrupts are disabled already in this path. to Running the sched_preempt handler in a critical section causes us to acquire the scheduler lock twice in a row. It is not necessary since interrupts aredisabled already in this path..Dec 1 2019, 8:37 PM
jeff edited the summary of this revision. (Show Details)
jeff added reviewers: jhb, kib, mav, markj.
jeff set the repository for this revision to rS FreeBSD src repository - subversion.
kib added inline comments.
sys/x86/x86/mp_x86.c
1275 ↗(On Diff #65102)

I must note that having oldframe and td_intr_frame correct in larger region is sometimes useful. I do not mind much about intr_nesting_level.

This revision is now accepted and ready to land.Dec 1 2019, 8:58 PM
sys/x86/x86/mp_x86.c
1275 ↗(On Diff #65102)

I can move it back out. I just wanted to be precise about what the different handlers required.

markj added inline comments.
sys/x86/x86/mp_x86.c
1275 ↗(On Diff #65102)

I've found td_intr_frame from preempted threads useful as well, FWIW.

sys/x86/x86/mp_x86.c
1275 ↗(On Diff #65102)

I will move this code back in the committed patch after testing.

I suspect the original critical section was only for hardclock() (wanted all of hardclock() to finish before preempting to run softclock()) and that sched_preempt ended up under it due to inertia.