[PATCH v5 13/13] kdump: Use vmlinux_build_id to simplify
Stephen Boyd
swboyd at chromium.org
Thu Apr 29 00:14:43 BST 2021
Quoting Baoquan He (2021-04-28 03:13:55)
> On 04/20/21 at 02:50pm, Stephen Boyd wrote:
> > We can use the vmlinux_build_id array here now instead of open coding
> > it. This mostly consolidates code.
> >
> > Cc: Jiri Olsa <jolsa at kernel.org>
> > Cc: Alexei Starovoitov <ast at kernel.org>
> > Cc: Jessica Yu <jeyu at kernel.org>
> > Cc: Evan Green <evgreen at chromium.org>
> > Cc: Hsin-Yi Wang <hsinyi at chromium.org>
> > Cc: Dave Young <dyoung at redhat.com>
> > Cc: Baoquan He <bhe at redhat.com>
> > Cc: Vivek Goyal <vgoyal at redhat.com>
> > Cc: <kexec at lists.infradead.org>
> > Signed-off-by: Stephen Boyd <swboyd at chromium.org>
> > ---
> > include/linux/crash_core.h | 12 ++++-----
> > kernel/crash_core.c | 50 ++------------------------------------
> > 2 files changed, 8 insertions(+), 54 deletions(-)
> >
> > diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
> > index 206bde8308b2..de62a722431e 100644
> > --- a/include/linux/crash_core.h
> > +++ b/include/linux/crash_core.h
> > @@ -38,8 +38,12 @@ phys_addr_t paddr_vmcoreinfo_note(void);
> >
> > #define VMCOREINFO_OSRELEASE(value) \
> > vmcoreinfo_append_str("OSRELEASE=%s\n", value)
> > -#define VMCOREINFO_BUILD_ID(value) \
> > - vmcoreinfo_append_str("BUILD-ID=%s\n", value)
> > +#define VMCOREINFO_BUILD_ID() \
> > + ({ \
> > + static_assert(sizeof(vmlinux_build_id) == 20); \
> > + vmcoreinfo_append_str("BUILD-ID=%20phN\n", vmlinux_build_id); \
>
> Since there has been static_assert at above, can we remove the magic
> number '20'?
>
> And I checked format_decode(), didn't find which type corresponds to
> 'N', could you tell?
It is documented in Documentation/core-api/printk-formats.rst (see "Raw
buffer as a hex string") where the '20' replaces the '*' to specify a
fixed size buffer to format. We could pass the 20 as an argument instead
of encoding it in the format, but then it would still be there twice. We
could use a #define but then it would have to be passed as an argument.
I don't know of a good way to enforce in printk that the buffer is the
size that matches the format size. Maybe it shouldn't be an option to
have a size in the format string if it's a problem to put the size of
the buffer in there.
>
> Other than these, this patch looks good to me, thanks for the effort.
>
Thanks.
More information about the kexec
mailing list