From: Vlastimil Babka <vbabka@suse.cz>
To: Imran Khan <imran.f.khan@oracle.com>,
geert@linux-m68k.org, akpm@linux-foundation.org,
ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com,
dvyukov@google.com, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie,
daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
intel-gfx@lists.freedesktop.org, linux-mm@kvack.org
Subject: Re: [PATCH 1/1] lib, stackdepot: Add helper to print stack entries into buffer.
Date: Mon, 13 Sep 2021 10:51:12 +0200 [thread overview]
Message-ID: <464d76e2-37f0-87f3-a9d5-2101367a8ca3@suse.cz> (raw)
In-Reply-To: <20210910141001.1622130-2-imran.f.khan@oracle.com>
On 9/10/21 16:10, Imran Khan wrote:
> To print stack entries into a buffer, users of stackdepot,
> first get a list of stack entries using stack_depot_fetch
> and then print this list into a buffer using stack_trace_snprint.
> Provide a helper in stackdepot for this purpose.
> Also change above mentioned users to use this helper.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> Suggested-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
A comment below:
> --- a/lib/stackdepot.c
> +++ b/lib/stackdepot.c
> @@ -214,6 +214,29 @@ static inline struct stack_record *find_stack(struct stack_record *bucket,
> return NULL;
> }
>
> +/**
> + * stack_depot_snprint - print stack entries from a depot into a buffer
> + *
> + * @handle: Stack depot handle which was returned from
> + * stack_depot_save().
> + * @buf: Pointer to the print buffer
> + *
> + * @size: Size of the print buffer
> + *
> + * @spaces: Number of leading spaces to print
> + *
> + * Return: Number of bytes printed.
> + */
> +int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size,
> + int spaces)
> +{
> + unsigned long *entries;
> + unsigned int nr_entries;
> +
> + nr_entries = stack_depot_fetch(handle, &entries);
> + return stack_trace_snprint(buf, size, entries, nr_entries, 0);
stack_trace_snprint() has a WARN_ON(!entries).
So maybe we should not call it if nr_entries is 0 (because e.g. handle was
0) as the warnings are not useful in that case.
next prev parent reply other threads:[~2021-09-13 8:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-10 14:10 [PATCH 0/1] lib, stackdepot: Add helper to print stack entries into buffer Imran Khan
2021-09-10 14:10 ` [PATCH 1/1] " Imran Khan
2021-09-13 8:51 ` Vlastimil Babka [this message]
2021-09-14 4:26 ` imran.f.khan
2021-09-15 10:06 ` Jani Nikula
2021-09-14 9:03 ` [PATCH 0/1] " Vlastimil Babka
2021-09-15 3:33 ` 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=464d76e2-37f0-87f3-a9d5-2101367a8ca3@suse.cz \
--to=vbabka@suse.cz \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=dvyukov@google.com \
--cc=geert@linux-m68k.org \
--cc=glider@google.com \
--cc=imran.f.khan@oracle.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=tzimmermann@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).