On Mon, Sep 8, 2025 at 9:07 AM Tetsuo Handa
<penguin-ker...@i-love.sakura.ne.jp> wrote:
> On 2025/09/07 16:35, Tetsuo Handa wrote:
> > On 2025/09/05 2:52, Paul Moore wrote:
> >> +               if (!str) {
> >> +                       str = str_tmp;
> >> +                       len = len_tmp - 1;
> >
> > This needs to be
> >
> >                       len = len_tmp - 1;
> >                       mb();
> >                       str = str_tmp;
> >
> > , or concurrent access might reach simple_read_from_buffer()
> > with str != 0 and len == 0. (If you don't want mb(), you can use
> >
> > -     if (unlikely(!str)) {
> > +     if (unlikely(!str || !len)) {

Good catch, thanks.  I'm going to go with the approach above as it is
rather straightforward.

> Well, memory barrier is more complicated; it will be
>
>         len = len_tmp - 1;
>         wmb();
>         str = str_tmp;
>
> and
>
>         }
>         rmb();
>         return simple_read_from_buffer(buf, count, ppos, str, len);
>
> pair.
>
> Just splitting the whole { } block that follows "if (unlikely(!str))"
> out as an initcall function is much simpler ...

I would very much prefer to get the string generation out of the boot,
and generate it on demand.

-- 
paul-moore.com

Reply via email to