All of lore.kernel.org
 help / color / mirror / Atom feed
From: imran.f.khan@oracle.com
To: Vlastimil Babka <vbabka@suse.cz>,
	cl@linux.com, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	David Rientjes <rientjes@google.com>,
	Pekka Enberg <penberg@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Oliver Glitta <glittao@gmail.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [RFC PATCH 1/2] lib, stackdepot: Add input prompt for STACKDEPOT option.
Date: Wed, 1 Sep 2021 16:28:58 +1000	[thread overview]
Message-ID: <b136043d-9585-0d57-4c8f-510a754a8df3@oracle.com> (raw)
In-Reply-To: <ac61af5a-f6f3-315a-59a8-7beed8de2aac@suse.cz>



On 31/8/21 9:25 pm, Vlastimil Babka wrote:
> 
> +CC rest of slab maintainers (please use get_maintainers.pl next time)
> 
> On 8/31/21 08:25, Imran Khan wrote:
>> So far CONFIG_STACKDEPOT option was being selected by
>> features that need STACKDEPOT support for their operations,
[...]
>>
>> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> 
> Right so you're probably not aware, but switching slub to stackdepot was
> just recently attempted by 788691464c29 ("mm/slub: use stackdepot to save
> stack trace in objects"), but Linus reverted it in ae14c63a9f20. Enabling
> stackdepot unconditionally was one of the reasons as there's memory overhead.
> 
Indeed I was not aware of this earlier attempt. I checked tip of 
linux-next and saw presence of array in struct track and then went ahead 
with my attempt.
>> ---
>>   lib/Kconfig | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/Kconfig b/lib/Kconfig
>> index 6a6ae5312fa0..7e4b54f48af7 100644
>> --- a/lib/Kconfig
>> +++ b/lib/Kconfig
>> @@ -665,8 +665,9 @@ config ARCH_STACKWALK
>>          bool
>>   
>>   config STACKDEPOT
>> -	bool
>> +	def_bool n
>>   	select STACKTRACE
>> +	prompt "Enable stackdepot support"
>>   
>>   config STACK_HASH_ORDER
>>   	int "stack depot hash size (12 => 4KB, 20 => 1024KB)"
>>
> 
> I'm not a big fan of a solution that throws another prompt at the person
> configuring the kernel, especially if there's nothing to help decide how to
> answer it.
> 
> Incidentally just yesterday I was trying locally to resolve this in a
> different way, where stackdepot would be enabled if both CONFIG_SLUB_DEBUG
> and CONFIG_STACKTRACE is enabled. That could be enough, unless there are
> systems that would like to have STACKTRACE enabled for other reasons,
> SLUB_DEBUG also for other reasons but still not want to pay the memory
> overhead of stackdepot. At that point it could be more useful to investigate
> if it's possible to optimize stackdepot to not make memblock allocations
> unconditionally on init, but normal buddy allocations only when actually used.

My main intention of making STACKDEPOT explicitly configurable was to 
use it as substitute of STACKTRACE as far as storing user info was 
concerned. But now I realize this approach was wrong mainly because 
STACKTRACE does not have any memory overhead of its own whereas 
STACKDEPOT has memory overhead of it's own. So if someone enables 
STACKDEPOT but never enables slub_debug=U, STACKDEPOT
memory will remain useless.
Probably the most acceptable way forward in this scenario would be 
optimize STACKDEPOT memory usage, as you have suggested.
I will do some more digging in this regard.
> 
> Thoughts on the below?
> 
> ----8<----
> commit d3582a7c54b26f6fd3a44f1327a26c383e6b951c
> Author: Vlastimil Babka <vbabka@suse.cz>
> Date:   Mon Aug 30 17:26:15 2021 +0200
> 
>      Rework stackdepot deps
> 
> diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
> index 80b57e7f4947..8c25b27014ee 100644
> --- a/arch/x86/Kconfig.debug
> +++ b/arch/x86/Kconfig.debug
> @@ -267,7 +267,6 @@ config UNWINDER_FRAME_POINTER
>   config UNWINDER_GUESS
>   	bool "Guess unwinder"
>   	depends on EXPERT
> -	depends on !STACKDEPOT
>   	help
>   	  This option enables the "guess" unwinder for unwinding kernel stack
>   	  traces.  It scans the stack and reports every kernel text address it
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 7ff89690a976..4638c4ece8f2 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -47,7 +47,8 @@ config DRM_DEBUG_MM
>   	bool "Insert extra checks and debug info into the DRM range managers"
>   	default n
>   	depends on DRM=y
> -	depends on STACKTRACE_SUPPORT
> +	depends on STACKDEPOT_SUPPORT
> +	select STACKTRACE
>   	select STACKDEPOT
>   	help
>   	  Enable allocation tracking of memory manager and leak detection on
> diff --git a/drivers/gpu/drm/i915/Kconfig.debug b/drivers/gpu/drm/i915/Kconfig.debug
> index 72a38f28393f..70794c6bb84f 100644
> --- a/drivers/gpu/drm/i915/Kconfig.debug
> +++ b/drivers/gpu/drm/i915/Kconfig.debug
> @@ -21,9 +21,11 @@ config DRM_I915_DEBUG
>   	depends on DRM_I915
>   	depends on EXPERT # only for developers
>   	depends on !COMPILE_TEST # never built by robots
> +	depends on STACKDEPOT_SUPPORT
>   	select DEBUG_FS
>   	select PREEMPT_COUNT
>   	select I2C_CHARDEV
> +	select STACKTRACE
>   	select STACKDEPOT
>   	select DRM_DP_AUX_CHARDEV
>   	select X86_MSR # used by igt/pm_rpm
> diff --git a/init/Kconfig b/init/Kconfig
> index 55f9f7738ebb..f9a4ec802516 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1847,6 +1847,7 @@ config SLUB_DEBUG
>   	default y
>   	bool "Enable SLUB debugging support" if EXPERT
>   	depends on SLUB && SYSFS
> +	select STACKDEPOT if STACKDEPOT_SUPPORT && STACKTRACE
>   	help
>   	  SLUB has extensive debug support features. Disabling these can
>   	  result in significant savings in code size. This also disables
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 5c9c0687f76d..67c388a09b7a 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -661,9 +661,37 @@ config ARCH_HAS_COPY_MC
>   config ARCH_STACKWALK
>          bool
>   
> +# encompasses STACKDEPOT dependencies
> +config STACKDEPOT_SUPPORT
> +	def_bool y
> +	depends on STACKTRACE_SUPPORT && !UNWINDER_GUESS
> +
> +# STACKDEPOT consumes megabytes of memory when compiled in, so we want to make
> +# sure it's only enabled when needed. But we don't want to burden the user with
> +# another choice. STACKTRACE is already configurable (but often selected by
> +# other configs).
> +#
> +# Due to how kconfig dependency resolution  works, it's slightly complicated
> +# as we cannot e.g. change STACKDEPOT to select STACKTRACE. Here are common
> +# scenarios how to use STACKDEPOT with your config options:
> +#
> +# Scenario 1: hard dependency, will select also STACKTRACE, your config will
> +# only be visible when STACKDEPOT_SUPPORT (and thus also STACKTRACE_SUPPORT) is
> +# satisfied:
> +#
> +# 	depends on STACKDEPOT_SUPPORT
> +#	select STACKTRACE
> +#	select STACKDEPOT
> +#
> +# Scenario 2: soft dependency (e.g. for code with #ifdef CONFIG_STACKDEPOT
> +# guards), will select STACKDEPOT only when STACKTRACE was configured by user
> +# (or selected by some other config)
> +#
> +#	select STACKDEPOT if STACKDEPOT_SUPPORT && STACKTRACE
> +#
>   config STACKDEPOT
>   	bool
> -	select STACKTRACE
> +	depends on STACKDEPOT_SUPPORT
>   
>   config STACK_HASH_ORDER
>   	int "stack depot hash size (12 => 4KB, 20 => 1024KB)"
> diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
> index 1e73717802f8..56a248814788 100644
> --- a/mm/Kconfig.debug
> +++ b/mm/Kconfig.debug
> @@ -47,7 +47,7 @@ config DEBUG_PAGEALLOC_ENABLE_DEFAULT
>   
>   config PAGE_OWNER
>   	bool "Track page owner"
> -	depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
> +	depends on DEBUG_KERNEL && STACKDEPOT_SUPPORT
>   	select DEBUG_FS
>   	select STACKTRACE
>   	select STACKDEPOT
> 
This looks good to me but I will wait for feedback from other maintainers.

Thanks again for review and feedback.

-- Imran

  reply	other threads:[~2021-09-01  6:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-31  6:25 [RFC PATCH 0/2] mm, slub: Use stackdepot to store user information for slub object Imran Khan
2021-08-31  6:25 ` [RFC PATCH 1/2] lib, stackdepot: Add input prompt for STACKDEPOT option Imran Khan
2021-08-31 11:25   ` Vlastimil Babka
2021-09-01  6:28     ` imran.f.khan [this message]
2021-08-31 15:54   ` Geert Uytterhoeven
2021-08-31 15:54     ` Geert Uytterhoeven
2021-08-31  6:25 ` [RFC PATCH 2/2] mm, slub: Use stackdepot to store user information for slub object Imran Khan
2021-08-31 12:06   ` Vlastimil Babka
2021-09-01  6:36     ` imran.f.khan

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=b136043d-9585-0d57-4c8f-510a754a8df3@oracle.com \
    --to=imran.f.khan@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=geert@linux-m68k.org \
    --cc=glittao@gmail.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.