From: Daniel Thompson <daniel.thompson@linaro.org>
To: Sumit Garg <sumit.garg@linaro.org>
Cc: kgdb-bugreport@lists.sourceforge.net, jason.wessel@windriver.com,
dianders@chromium.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] kdb: Get rid of custom debug heap allocator
Date: Fri, 26 Feb 2021 10:59:34 +0000 [thread overview]
Message-ID: <20210226105934.gmppt6kubfadv4uf@maple.lan> (raw)
In-Reply-To: <20210226095306.1236539-1-sumit.garg@linaro.org>
On Fri, Feb 26, 2021 at 03:23:06PM +0530, Sumit Garg wrote:
> Currently the only user for debug heap is kdbnearsym() which can be
> modified to rather ask the caller to supply a buffer for symbol name.
> So do that and modify kdbnearsym() callers to pass a symbol name buffer
> allocated statically and hence remove custom debug heap allocator.
Why make the callers do this?
The LRU buffers were managed inside kdbnearsym() why does switching to
an approach with a single buffer require us to push that buffer out to
the callers?
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 9d69169582c6..6efe9ec53906 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -526,6 +526,7 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
The documentation comment for this function has not been updated to
describe the new contract on callers of this function (e.g. if they
consume the symbol name they must do so before calling kdbgetaddrarg()
(and maybe kdbnearsym() again).
> char symbol = '\0';
> char *cp;
> kdb_symtab_t symtab;
> + static char namebuf[KSYM_NAME_LEN];
>
> /*
> * If the enable flags prohibit both arbitrary memory access
> diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
> index b59aad1f0b55..9b907a84f2db 100644
> --- a/kernel/debug/kdb/kdb_support.c
> +++ b/kernel/debug/kdb/kdb_support.c
> @@ -57,8 +57,6 @@ int kdbgetsymval(const char *symname, kdb_symtab_t *symtab)
> }
> EXPORT_SYMBOL(kdbgetsymval);
>
> -static char *kdb_name_table[100]; /* arbitrary size */
> -
> /*
> * kdbnearsym - Return the name of the symbol with the nearest address
> * less than 'addr'.
Again the documentation comment has not been updated and, in this case,
is now misleading.
If we move the static buffer here then the remarks section on this
function is a really good place to describe what the callers must do to
manage the static buffer safely as well as a convenient place to mention
that we tolerate the reuse of the static buffer if kdb is re-entered
becase a) kdb is broken if that happens and b) we are crash resilient
if if does.
> @@ -79,13 +77,11 @@ static char *kdb_name_table[100]; /* arbitrary size */
> * hold active strings, no kdb caller of kdbnearsym makes more
> * than ~20 later calls before using a saved value.
> */
> -int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
> +int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab, char *namebuf)
As above, I don't understand why we need to add namebuf here. I think
the prototype can remain the same.
Think of it simple that we have reduce the cache from having 100 entries
to having just 1 ;-) .
Daniel.
next prev parent reply other threads:[~2021-02-26 11:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-26 9:53 Sumit Garg
2021-02-26 10:59 ` Daniel Thompson [this message]
2021-02-26 12:42 ` Sumit Garg
2021-02-26 17:37 ` Daniel Thompson
2021-03-01 6:03 ` Sumit Garg
2021-03-19 17:35 ` Daniel Thompson
2021-03-23 6:26 ` Sumit Garg
2021-03-23 6:55 Sumit Garg
2021-06-17 11:25 ` Daniel Thompson
2021-06-17 11:51 ` Sumit Garg
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=20210226105934.gmppt6kubfadv4uf@maple.lan \
--to=daniel.thompson@linaro.org \
--cc=dianders@chromium.org \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sumit.garg@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®