[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ef0aa660-0cb6-dc21-f2ce-368b34f8af3d@suse.cz>
Date: Tue, 14 Sep 2021 11:01:04 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Imran Khan <imran.f.khan@...cle.com>, geert@...ux-m68k.org,
akpm@...ux-foundation.org, ryabinin.a.a@...il.com,
glider@...gle.com, andreyknvl@...il.com, dvyukov@...gle.com
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2 2/2] lib, stackdepot: Add helper to print stack
entries.
On 9/2/21 02:01, Imran Khan wrote:
> To print a stack entries, users of stackdepot, first
> use stack_depot_fetch to get a list of stack entries
> and then use stack_trace_print to print this list.
> Provide a helper in stackdepot to print stack entries
> based on stackdepot handle.
> Also change above mentioned users to use this helper.
>
> Signed-off-by: Imran Khan <imran.f.khan@...cle.com>
> Suggested-by: Vlastimil Babka <vbabka@...e.cz>
> ---
> include/linux/stackdepot.h | 2 ++
> lib/stackdepot.c | 17 +++++++++++++++++
> mm/kasan/report.c | 15 +++------------
> mm/page_owner.c | 13 ++++---------
> 4 files changed, 26 insertions(+), 21 deletions(-)
>
> diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h
> index 6bb4bc1a5f54..d77a30543dd4 100644
> --- a/include/linux/stackdepot.h
> +++ b/include/linux/stackdepot.h
> @@ -19,6 +19,8 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries,
> unsigned int stack_depot_fetch(depot_stack_handle_t handle,
> unsigned long **entries);
>
> +void stack_depot_print(depot_stack_handle_t stack);
> +
> unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries);
>
> #ifdef CONFIG_STACKDEPOT
> diff --git a/lib/stackdepot.c b/lib/stackdepot.c
> index 67439c082490..873aeb152f52 100644
> --- a/lib/stackdepot.c
> +++ b/lib/stackdepot.c
> @@ -214,6 +214,23 @@ static inline struct stack_record *find_stack(struct stack_record *bucket,
> return NULL;
> }
>
> +/**
> + * stack_depot_print - print stack entries from a depot
> + *
> + * @handle: Stack depot handle which was returned from
> + * stack_depot_save().
> + *
> + */
> +void stack_depot_print(depot_stack_handle_t stack)
> +{
> + unsigned long *entries;
> + unsigned int nr_entries;
> +
> + nr_entries = stack_depot_fetch(stack, &entries);
Maybe this should also skip stack_trace_print when nr_entries is 0, to avoid
the warning. While the callers added by this patch check handle != 0, future
ones might not.
Powered by blists - more mailing lists