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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 18 Mar 2024 13:40:55 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Pasha Tatashin <pasha.tatashin@...een.com>
Cc: 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, shakeel.butt@...ux.dev,
 vbabka@...e.cz, ziy@...dia.com, linux-kernel@...r.kernel.org,
 linux-mm@...ck.org
Subject: Re: [PATCH v2] vmstat: Keep count of the maximum page reached by
 the kernel stack

On Thu, 14 Mar 2024 14:54:57 +0000 Pasha Tatashin <pasha.tatashin@...een.com> wrote:

> CONFIG_DEBUG_STACK_USAGE provides a mechanism to determine the minimum
> amount of memory left in a stack. Every time a new low-memory record is
> reached, a message is printed to the console.
> 
> However, this doesn't reveal how many pages within each stack were
> actually used. Introduce a mechanism that keeps count the number of
> times each of the stack's pages were reached:
> 
> 	$ grep kstack /proc/vmstat
> 	kstack_page_1 19974
> 	kstack_page_2 94
> 	kstack_page_3 0
> 	kstack_page_4 0
> 
> In the above example, out of 20,068 threads that exited on this
> machine, only 94 reached the second page of their stack, and none
> touched pages three or four.
> 
> In fleet environments with millions of machines, this data can help
> optimize kernel stack sizes.

We really should have somewhere to document vmstat things.

> --- a/include/linux/vm_event_item.h
> +++ b/include/linux/vm_event_item.h
> @@ -153,10 +153,39 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
>  		VMA_LOCK_ABORT,
>  		VMA_LOCK_RETRY,
>  		VMA_LOCK_MISS,
> +#endif
> +#ifdef CONFIG_DEBUG_STACK_USAGE
> +		KSTACK_PAGE_1,
> +		KSTACK_PAGE_2,
> +#if THREAD_SIZE >= (4 * PAGE_SIZE)
> +		KSTACK_PAGE_3,
> +		KSTACK_PAGE_4,
> +#endif
> +#if THREAD_SIZE > (4 * PAGE_SIZE)
> +		KSTACK_PAGE_REST,
> +#endif
>  #endif
>  		NR_VM_EVENT_ITEMS
>  };

This seems a rather cumbersome way to produce a kind of histogram.  I
wonder if there should be a separate pseudo file for this.

And there may be a call for extending this.  For example I can forsee
people wanting to know "hey, which process did that", in which case
we'll want to record additional info.  


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ