Re: [PATCH v1 1/1] wq: Avoid using isolated cpus' timers on unbounded queue_delayed_work
From: Leonardo Bras
Date: Mon Jan 29 2024 - 14:28:25 EST
On Mon, Jan 29, 2024 at 08:18:15AM -1000, Tejun Heo wrote:
> Hello,
>
> On Fri, Jan 26, 2024 at 07:05:35PM -0300, Leonardo Bras wrote:
> > > if (housekeeping_enabled(HK_TYPE_TIMER)) {
> > > cpu = smp_processor_id();
> > > if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER))
> > > cpu = housekeeping_any_cpu(HK_TYPE_TIMER);
> > > add_timer_on(timer, cpu);
> > > } else {
> > > if (likely(cpu == WORK_CPU_UNBOUND))
> > > add_timer(timer, cpu);
> > > else
> > > add_timer_on(timer, cpu);
> > > }
> > >
> > > Thanks.
> >
> > I am not really against it, but for me it's kind of weird to have that many
> > calls to add_timer_on() if we can avoid it.
> >
> > I would rather go with:
> >
> > ###
> > if (unlikely(cpu != WORK_CPU_UNBOUND)) {
> > add_timer_on(timer, cpu);
> > return;
> > }
> >
> > if (!housekeeping_enabled(HK_TYPE_TIMER)) {
> > add_timer(timer);
> > return;
> > }
> >
> > cpu = smp_processor_id();
> > if (!housekeeping_test_cpu(cpu, HK_TYPE_TIMER))
> > cpu = housekeeping_any_cpu(HK_TYPE_TIMER);
> >
> > add_timer_on(timer, cpu);
> > ###
> >
> > What do you think?
>
> Isn't that still the same number of add_timer[_on]() calls?
Yeah, sorry about this, what I meant was: If we are ok on calling
add_timer_on() multiple times, I would rather go with the above version, as
I think it's better for readability.
>
> Thanks.
Thank you for reviewing!
Leo
>
> --
> tejun
>