Re: [PATCH 1/7] buildid: Add method to get running kernel's build ID

From: Stephen Boyd
Date: Wed Mar 03 2021 - 20:10:20 EST


Quoting Stephen Boyd (2021-03-02 15:28:25)
> (HTML mail?)
>
> Quoting Andy Shevchenko (2021-03-01 15:33:06)
> >
> >
> > On Monday, March 1, 2021, Stephen Boyd <swboyd@xxxxxxxxxxxx> wrote:
> > @@ -147,3 +158,31 @@ int build_id_parse(struct vm_area_struct *vma,
> > unsigned char *build_id,
> >         put_page(page);
> >         return ret;
> >  }
> > +
> > +static void build_id2hex(char *dst, const unsigned char *src, __u32 size)
> > +{
> > +       bin2hex(dst, src, size);
> > +       dst[2 * size] = '\0';
> > +}
> > +
> >
> >
> >
> > If you are so only printing this via printf(), just use %20phN. No need for a
> > separate function.
> >
>
> Makes sense. The downside is that we may have to calculate the build ID
> many times then by searching the notes section? Unless we can test the
> whole array very quickly for "not initialized" or stash another bool
> like "build_id_initialized". The kdump code would also need to take a
> printk format then. This seems better as is but let me know if you
> disagree strongly and I can change more code.

I am using memchr_inv() now to check for an all zero array. That seems
fairly cheap so I think it should be OK. We trade-off a small amount of
time for a few more bytes savings.