Re: [PATCH 3/4] workqueue: add schedule_on_each_cpumask helper

From: Michal Hocko
Date: Mon Jun 05 2023 - 03:13:18 EST


On Fri 02-06-23 14:04:28, Marcelo Tosatti wrote:
> On Fri, Jun 02, 2023 at 12:48:23PM +0200, Michal Hocko wrote:
[...]
> > > + if (!alloc_cpumask_var(&effmask, GFP_KERNEL)) {
> > > + free_percpu(works);
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + cpumask_and(effmask, cpumask, cpu_online_mask);
> > > +
> > > + cpus_read_lock();
> > > +
> > > + for_each_cpu(cpu, effmask) {
> >
> > Is the cpu_online_mask dance really necessary?
>
> > Why cannot you simply do for_each_online_cpu here?
>
> Are you suggesting to do:
>
> for_each_online_cpu(cpu) {
> if cpu is not in cpumask
> continue;
> ...
> }
>
> This does not seem efficient.

Are you sure this is less sufficient than a memory allocation?
--
Michal Hocko
SUSE Labs