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)
Mon, Apr 1, 3:26 AM
Unknown Object (File)
Feb 8 2024, 2:33 AM
Unknown Object (File)
Jan 25 2024, 9:03 AM
Unknown Object (File)
Jan 25 2024, 9:03 AM
Unknown Object (File)
Jan 25 2024, 9:03 AM
Unknown Object (File)
Jan 25 2024, 9:03 AM
Unknown Object (File)
Jan 25 2024, 9:03 AM
Unknown Object (File)
Jan 25 2024, 5:16 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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–79
This revision is now accepted and ready to land.Nov 24 2021, 9:14 PM