Page MenuHomeFreeBSD

i386: take pcb into account in GET_STACK_USAGE
ClosedPublic

Authored by mhorne on Oct 20 2021, 3:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 3, 8:42 AM
Unknown Object (File)
Sun, Nov 3, 8:39 AM
Unknown Object (File)
Sep 22 2024, 2:50 AM
Unknown Object (File)
Sep 22 2024, 12:16 AM
Unknown Object (File)
Sep 21 2024, 6:51 PM
Unknown Object (File)
Sep 20 2024, 10:11 AM
Unknown Object (File)
Sep 20 2024, 2:00 AM
Unknown Object (File)
Sep 19 2024, 5:48 AM
Subscribers

Details

Summary

On this platform, the pcb is allocated from the top of the kernel
stack, so it should be excluded from the total size. This makes it
consistent with other implementations.

Diff Detail

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

Event Timeline

As I noted in D32580, the FPU save area is allocated on the stack as well.

Take fpu save area into account as well.

In D32581#735397, @kib wrote:

As I noted in D32580, the FPU save area is allocated on the stack as well.

A silly mistake by me, thanks.

Doesn't this mean that in principle used might become larger than total? I think you need to base both on get_pcb_td() then.

Also did you considered using e.g. __builtin_frame_address(0) instead of &td?

Use get_pcb_td() for used as well.

In D32581#735457, @kib wrote:

Doesn't this mean that in principle used might become larger than total? I think you need to base both on get_pcb_td() then.

Also did you considered using e.g. __builtin_frame_address(0) instead of &td?

I suppose using &td might produce a less consistent result than __builtin_frame_address(0)? Since (I assume) there is no guarantee from the compiler that td is actually the topmost item on the stack.

Still, &td is in use now and I will just stick with this unless there's a compelling reason not to.

I wonder if it is better to do something like this

register u_long esp __asm ("esp");

and then use esp instead of &td.

Apparently this works with gcc but not clang. Sigh.

sys/i386/include/proc.h
78
This revision is now accepted and ready to land.Nov 24 2021, 9:14 PM