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
Unknown Object (File)
Dec 20 2023, 1:10 AM
Unknown Object (File)
Dec 17 2023, 10:37 PM
Unknown Object (File)
Sep 3 2023, 4:26 AM
Unknown Object (File)
Jul 28 2023, 9:32 AM
Unknown Object (File)
Jun 30 2023, 4:09 AM
Unknown Object (File)
May 17 2023, 5:46 AM
Unknown Object (File)
May 8 2023, 2:25 AM
Unknown Object (File)
Dec 30 2022, 5:32 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.