Page MenuHomeFreeBSD

Implement GET_STACK_USAGE on remaining archs
ClosedPublic

Authored by mhorne on Oct 20 2021, 3:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 22, 7:03 PM
Unknown Object (File)
Sun, Oct 20, 9:08 AM
Unknown Object (File)
Sun, Oct 20, 9:08 AM
Unknown Object (File)
Sun, Oct 20, 9:08 AM
Unknown Object (File)
Sun, Oct 20, 9:08 AM
Unknown Object (File)
Sun, Oct 20, 8:46 AM
Unknown Object (File)
Wed, Oct 9, 8:35 PM
Unknown Object (File)
Oct 8 2024, 3:48 PM

Details

Summary

This definition enables callers to estimate remaining space on the
kstack, and take action on it. Notably, it enables optimizations in the
GEOM and netgraph subsystems to directly dispatch work items when there
is sufficient stack space, rather than queuing them for a worker thread.

Implement it for riscv, arm, and mips. Remove the #ifdefs, so it will
not go unimplemented elsewhere. As with 6514b4f06180, we exclude
sizeof(pcb) from the usable total, as it is allocated from the bottom of
the kstack on these architectures.

Test Plan

Tested on riscv to verify that direct dispatch of BIOs works as intended. Tested as it relates to PR 259157, where GET_STACK_USAGE mitigates a panic in a netgraph test.

Compiled on arm and mips.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 42962
Build 39850: arc lint + arc unit

Event Timeline

mhorne added a subscriber: trasz.

I am not sure what can I add to this review.

But note that i386 GET_STACK_USAGE() is completely wrong. It does not account neither for pcb nor for the FPU save area, both allocated on the top of the stack.
Since I moved first pcb, then FPU save area from the amd64 stack, suddenly amd64 version appeared to be sane.

In D32580#735395, @kib wrote:

It does not account neither for pcb nor for the FPU save area, both allocated on the top of the stack.

Sure that should be improved, but since free space thresholds in GEOM and Netgraph are set quite safe (50% and 25%), previous code also worked acceptably.

This revision is now accepted and ready to land.Oct 20 2021, 8:45 PM

Oh, I'm impressed that this fixes the "intended break" triggered by the netgraph test.
Please go ahead!

Have used take the pcb into account as well, as otherwise it could exceed the total as the stack approaches its limit. Simplify the calculation of used by using total.

This revision now requires review to proceed.Nov 24 2021, 8:15 PM
This revision is now accepted and ready to land.Nov 24 2021, 9:15 PM
This revision was automatically updated to reflect the committed changes.