lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ud5csdd23fjb2gin4uuxsocm4hvsy22bk4plfjv5zvqd2egqri@hpavorxrrprw>
Date: Fri, 19 Jul 2024 15:04:40 -0700
From: Shakeel Butt <shakeel.butt@...ux.dev>
To: Pasha Tatashin <pasha.tatashin@...een.com>
Cc: akpm@...ux-foundation.org, jpoimboe@...nel.org, 
	kent.overstreet@...ux.dev, peterz@...radead.org, nphamcs@...il.com, 
	cerasuolodomenico@...il.com, surenb@...gle.com, lizhijian@...itsu.com, willy@...radead.org, 
	vbabka@...e.cz, ziy@...dia.com, linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v4] vmstat: Kernel stack usage histogram

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@...ux.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ