Re: [PATCH] vmstat: Keep count of the maximum page reached by the kernel stack

From: Pasha Tatashin
Date: Thu Mar 14 2024 - 09:42:55 EST


On Thu, Mar 14, 2024 at 4:19 AM Christophe Leroy
<christophe.leroy@xxxxxxxxxx> wrote:
>
>
>
> Le 13/03/2024 à 04:34, Pasha Tatashin a écrit :
> > CONFIG_DEBUG_STACK_USAGE provides a mechanism to know the minimum amount
> > of memory that was left in stack. Every time the new anti-record is
> > reached a message is printed to the console.
> >
> > However, this is not useful to know how much each page within stack was
> > actually used. Provide a mechanism to count the number of time each
> > stack page was reached throughout the live of the stack:
>
> by "this is not useful to know ", you mean "this does not allow us to
> know" ?

Yes, bad wording from my side, I will change it to you suggestion in
the next version.

>
> >
> > $
> > kstack_page_1 19974
> > kstack_page_2 94
> > kstack_page_3 0
> > kstack_page_4 0
>
> That's probably only usefull when THREAD_SIZE is larger than PAGE_SIZE.

That is right, if THREAD_SIZE <= PAGE_SIZE, only "kstack_page_1" would
be filled.

>
> On powerpc 8xx, THREAD_SIZE is 8k by default and PAGE_SIZE can be either
> 4k or 16k.

With THREAD_SIZE == 8K, and PAGE_SIZE = 4K
There will be two counters in /proc/vmstat, something like this:

kstack_page_1 XXX
kstack_page_2 YYY

With THREAD_SIZE=16K, and PAGE_SIZE = 16K
There will be two counters, but one will always be zero:

kstack_page_1 XXX
kstack_page_2 0

Thanks,
Pasha