[PATCH v5] erofs: lazily initialize per-CPU workers and CPU hotplug hooks

Sandeep Dhavale dhavale at google.com
Wed May 7 09:02:47 AEST 2025


Hi Gao,
> >   #ifdef CONFIG_EROFS_FS_PCPU_KTHREAD
> >   static struct kthread_worker __rcu **z_erofs_pcpu_workers;
> > +static atomic_t erofs_percpu_workers_initialized = ATOMIC_INIT(0);
> > +static int erofs_cpu_hotplug_init(void);
> > +static void erofs_cpu_hotplug_destroy(void);
>
> We could move downwards to avoid those forward declarations;
>
Sure, I ended up moving the CONFIG_HOTPLUG_CPU block inside
CONFIG_EROFS_FS_PCPU_KTHREAD. That gets rid of forward declaration and
also much readable.
> >
> >   static void erofs_destroy_percpu_workers(void)
> >   {
> > @@ -336,9 +339,45 @@ static int erofs_init_percpu_workers(void)
> >       }
> >       return 0;
> >   }
> > +
> > +static int z_erofs_init_pcpu_workers(void)
>
> How about passing in `struct super_block *` here?
> Since print messages are introduced, it's much better to
> know which instance caused the error/info.
>
Sounds good. Log message now looks like this

[    8.724634] erofs (device loop0): initialized per-cpu workers successfully.
[    8.726133] erofs (device loop0): mounted with root inode @ nid 40.

Thanks for the review.
v6 addressing this is available at:
https://lore.kernel.org/linux-erofs/20250506225743.308517-1-dhavale@google.com/

Thanks,
Sandeep.

> > +{
> > +     int err;
> > +
> > +     if (atomic_xchg(&erofs_percpu_workers_initialized, 1))
> > +             return 0;
> > +
> > +     err = erofs_init_percpu_workers();
> > +     if (err) {
> > +             erofs_err(NULL, "per-cpu workers: failed to allocate.");
> > +             goto err_init_percpu_workers;
> > +     }
> > +
> > +     err = erofs_cpu_hotplug_init();
> > +     if (err < 0) {
> > +             erofs_err(NULL, "per-cpu workers: failed CPU hotplug init.");
> > +             goto err_cpuhp_init;
> > +     }
> > +     erofs_info(NULL, "initialized per-cpu workers successfully.");
>
>
> Otherwise it looks good to me know.
>
> Thanks,
> Gao Xiang


More information about the Linux-erofs mailing list