Re: [PATCH v3] vmstat: Kernel stack usage histogram
From: Pasha Tatashin
Date: Thu May 30 2024 - 20:15:04 EST
Hi Shakeel,
> Couple of questions:
>
> 1. In future with your on-demand kstack allocation feature, will these
> metrics still be useful? (I think so but I want to know your take)
It depends on how on-demand allocation is implemented. On hardware
that supports faults on kernel stacks, we will have other metrics that
show the total number of pages allocated for stacks. On hardware where
faults are not supported, we will most likely have some optimization
where only some threads are extended, and for those, these metrics
will still be very useful.
> 2. With on-demand kstack allocation, the stack_not_used() needs to be
> changed to not cause the allocation, right?
This is correct, in my WIP dynamic kernel tasks RFCv2 patch series, I
have an optimized version of stack_not_used() that uses the number of
allocated pages in the partially filled vmap to determine the last
stack address.
> 3. Does the histogram get updated on exit only? What about long running
> kernel threads whose will never exit?
Yes, for performance reasons, the histogram is updated only on exit.
It would be too expensive to calculate for all running tasks. However,
it could be extended to be queried on demand via a debugfs interface
for all running threads. On machines where jobs come and go over time,
this histogram will show the actual stack usage distribution.
Thank you,
Pasha
> thanks,
> Shakeel