diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 13a5d1be06ed..98973397edc3 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -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;