All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zi Yan" <ziy@nvidia.com>
To: "Kanishka Solanki" <kanishkasolanki456s@gmail.com>,
	<akpm@linux-foundation.org>, <vbabka@kernel.org>
Cc: <surenb@google.com>, <mhocko@suse.com>,
	<brendan.jackman@linux.dev>, <hannes@cmpxchg.org>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/page_owner: make page_owner stack depth runtime configurable
Date: Sat, 10 Oct 2026 07:42:42 -0400	[thread overview]
Message-ID: <DM14QKTSWM6K.YSJFASLMY53E@nvidia.com> (raw)
In-Reply-To: <20261010093843.103169-1-kanishkasolanki456s@gmail.com>

On Sat Oct 10, 2026 at 5:38 AM EDT, Kanishka Solanki wrote:
> The stack depth for page_owner allocations was previously fixed at
> PAGE_OWNER_STACK_DEPTH (16).
>
> Replace the fixed stack depth constant with a compile-time max ceiling
> (PAGE_OWNER_STACK_DEPTH_MAX = 64) and expose a module parameter
> 'stack_depth' via module_param_named. This allows users to configure
> the stack recording depth between 1 and 64 at boot or runtime via sysfs,
> while preventing unbounded stack usage.

What is your motivation? If you see page owner stack gets cutoff due to
insufficient depth, explain your use cases first.

>
> Signed-off-by: Kanishka <kanishkasolanki456s@gmail.com>
> Signed-off-by: Kanishka Solanki <kanishkasolanki456s@gmail.com>
> ---
>  mm/page_owner.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/mm/page_owner.c b/mm/page_owner.c
> index fbbda7ba914b..fcb584070f1d 100644
> --- a/mm/page_owner.c
> +++ b/mm/page_owner.c
> @@ -15,11 +15,10 @@
>  
>  #include "page_alloc.h"
>  
> -/*
> - * TODO: teach PAGE_OWNER_STACK_DEPTH (__dump_page_owner and save_stack)
> - * to use off stack temporal storage
> - */
> -#define PAGE_OWNER_STACK_DEPTH (16)
> +#define PAGE_OWNER_STACK_DEPTH_MAX (64)

This uses more stack. Do not do this.

> +
> +static unsigned int page_owner_stack_depth = 16;
> +module_param_named(stack_depth, page_owner_stack_depth, uint, 0644);
>  
>  struct page_owner {
>  	unsigned short order;
> @@ -172,15 +171,17 @@ static inline struct page_owner *get_page_owner(struct page_ext *page_ext)
>  
>  static noinline depot_stack_handle_t save_stack(gfp_t flags)
>  {
> -	unsigned long entries[PAGE_OWNER_STACK_DEPTH];
> +	unsigned long entries[PAGE_OWNER_STACK_DEPTH_MAX];
>  	depot_stack_handle_t handle;
>  	unsigned int nr_entries;
> +	unsigned int max_entries;
>  
>  	if (current->in_page_owner)
>  		return dummy_handle;
>  
>  	set_current_in_page_owner();
> -	nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 2);
> +	max_entries = min_t(unsigned int, page_owner_stack_depth, ARRAY_SIZE(entries));
> +	nr_entries = stack_trace_save(entries, max_entries, 2);
>  	handle = stack_depot_save(entries, nr_entries, flags);
>  	if (!handle)
>  		handle = failure_handle;




-- 
Best Regards,
Yan, Zi



  reply	other threads:[~2026-10-10 11:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  9:38 [PATCH] mm/page_owner: make page_owner stack depth runtime configurable Kanishka Solanki
2026-10-10 11:42 ` Zi Yan [this message]
2026-10-12  4:15   ` Kanishka Solanki

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=DM14QKTSWM6K.YSJFASLMY53E@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=brendan.jackman@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=kanishkasolanki456s@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /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.