Re: [PATCH] lib: stackdepot: Add support to configure STACK_HASH_SIZE

From: Minchan Kim
Date: Tue Nov 17 2020 - 15:42:10 EST


On Thu, Nov 12, 2020 at 02:56:49PM -0800, Andrew Morton wrote:
> On Thu, 12 Nov 2020 18:26:24 +0530 Vijayanand Jitta <vjitta@xxxxxxxxxxxxxx> wrote:
>
> > >> 1. page_owner=off, stackdepot_stack_hash=0 -> no more wasted memory
> > >> when we don't use page_owner
> > >> 2. page_owner=on, stackdepot_stack_hash=8M -> reasonable hash size
> > >> when we use page_owner.
> > >>
> > >>
> > >
> > > This idea looks fine to me. Andrew and others would like to hear your
> > > comments as well on this before implementing.
> > >
> > > Thanks,
> > > Vijay
> > >
> >
> > Awaiting for comments from Andrew and others.
>
> I don't actually understand the problem.
>
> What is it about page-owner that causes stackdepot to consume
> additional memory? As far as I can tell, sizeof(struct stack_record)
> isn't affected by page-owner?
>

Thing is once we build stackdepot due to the dependency from page_owner,
it will consume 8M regardless of using page_owner.

#define STACK_HASH_SIZE (1L << CONFIG_STACK_HASH_ORDER_SHIFT)

static struct stack_record *stack_table[STACK_HASH_SIZE] = {
[0 ... STACK_HASH_SIZE - 1] = NULL
};

So if we decide the size option at build time, we should consume
the memory anyway regardless of page_owner enabling in runtime.