Implement GET_STACK_USAGE() macro to get the current kernel thread stack usage.

This implemntation made for growing down stack organization like i386/amd64
platforms have, but prefers different machine dependent version if it is present.
This commit is contained in:
Alexander Motin 2008-01-30 21:24:10 +00:00
parent 79e19f08ae
commit cb1f76532c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175835

View file

@ -784,6 +784,20 @@ MALLOC_DECLARE(M_ZOMBIE);
curthread->td_pflags &= ~TDP_NOSLEEPING; \
} while (0)
/*
* Get the current kernel thread stack usage.
* Prefer machine dependent version if present.
*/
#ifndef GET_STACK_USAGE
#define GET_STACK_USAGE(total, used) do { \
struct thread *td = curthread; \
(total) = td->td_kstack_pages * PAGE_SIZE; \
(used) = (char *)td->td_kstack + \
td->td_kstack_pages * PAGE_SIZE - \
(char *)&td; \
} while (0)
#endif /* GET_STACK_USAGE */
#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
extern u_long pidhash;