From: Shakeel Butt <shakeel.butt@linux.dev>
To: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: akpm@linux-foundation.org, jpoimboe@kernel.org,
kent.overstreet@linux.dev, peterz@infradead.org,
nphamcs@gmail.com, cerasuolodomenico@gmail.com,
surenb@google.com, lizhijian@fujitsu.com, willy@infradead.org,
vbabka@suse.cz, ziy@nvidia.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v4] vmstat: Kernel stack usage histogram
Date: Fri, 19 Jul 2024 15:04:40 -0700 [thread overview]
Message-ID: <ud5csdd23fjb2gin4uuxsocm4hvsy22bk4plfjv5zvqd2egqri@hpavorxrrprw> (raw)
In-Reply-To: <CA+CK2bB4RELLHExbkL444ArTtUnqiYVYKJ1rLQGarLyenY6WxQ@mail.gmail.com>
On Thu, Jul 18, 2024 at 10:55:17PM GMT, Pasha Tatashin wrote:
> On Thu, Jul 18, 2024 at 7:36 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > On Thu, Jul 18, 2024 at 08:26:11PM GMT, Pasha Tatashin wrote:
> > [...]
> > > diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h
> > > index ccd72b978e1f..65e8c9fb7f9b 100644
> > > --- a/include/linux/sched/task_stack.h
> > > +++ b/include/linux/sched/task_stack.h
> > > @@ -95,9 +95,51 @@ static inline int object_is_on_stack(const void *obj)
> > > extern void thread_stack_cache_init(void);
> > >
> > > #ifdef CONFIG_DEBUG_STACK_USAGE
> > > +#ifdef CONFIG_VM_EVENT_COUNTERS
> > > +#include <linux/vm_event_item.h>
> > > +
> > > +/* Count the maximum pages reached in kernel stacks */
> > > +static inline void kstack_histogram(unsigned long used_stack)
> >
> > Any specific reason to add this function in header?
>
> For performance reasons to keep it inlined into stack_not_used() which
> is also defined as inline function in this header.
>
Is this really that performance critical?
> >
> > > +{
> > > + if (used_stack <= 1024)
> > > + this_cpu_inc(vm_event_states.event[KSTACK_1K]);
> >
> > Why not count_vm_event(KSTACK_1K)? Avoiding header include recursion?
>
> I could not include "linux/vmstat.h" into "linux/sched/task_stack.h"
> because it introduces some dependencies such linux/mm.h and
> linux/fs.h, uapi/linux/stat.h, and when all of those are added it
> still fails to compile on some architectures, so it was just simpler
> to stop resolving the conflicts and use this_cpu_inc() directly.
>
The above makes me think it is better to move stack_not_used() and the
new function to C file unless we can show the negative performance
impact.
I have another question. At the moment, the metrics are exposed
conditionally through procfs based on stack size. So, based on the
kernel config someone may not see kstack_16k. Why not just output all of
these metrics irrespective of the config?
Shakeel
next prev parent reply other threads:[~2024-07-19 22:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 20:26 Pasha Tatashin
2024-07-18 21:44 ` Kent Overstreet
2024-07-18 23:36 ` Shakeel Butt
2024-07-19 2:55 ` Pasha Tatashin
2024-07-19 22:04 ` Shakeel Butt [this message]
2024-07-24 0:09 ` Andrew Morton
2024-07-24 0:10 ` Andrew Morton
2024-07-24 6:46 ` Andrew Morton
2024-07-24 14:43 ` Pasha Tatashin
2024-07-24 16:59 ` Shakeel Butt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ud5csdd23fjb2gin4uuxsocm4hvsy22bk4plfjv5zvqd2egqri@hpavorxrrprw \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cerasuolodomenico@gmail.com \
--cc=jpoimboe@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizhijian@fujitsu.com \
--cc=nphamcs@gmail.com \
--cc=pasha.tatashin@soleen.com \
--cc=peterz@infradead.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox