public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leonardo Bras <leobras@redhat.com>
To: Leonardo Bras <leobras@redhat.com>
Cc: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/1] wq: Avoid using isolated cpus' timers on unbounded queue_delayed_work
Date: Mon, 29 Jan 2024 18:17:18 -0300	[thread overview]
Message-ID: <ZbgV3kRXqigZ6pW2@LeoBras> (raw)
In-Reply-To: <ZbgQbOqkrWFPW0Mt@LeoBras>

On Mon, Jan 29, 2024 at 05:54:04PM -0300, Leonardo Bras wrote:
> On Mon, Jan 29, 2024 at 10:51:09AM -1000, Tejun Heo wrote:
> > On Mon, Jan 29, 2024 at 04:26:57PM -0300, Leonardo Bras wrote:
> > > > 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.
> > 
> > I don't know. It looks more verbose and less clear to me in that it isn't
> > immediately clear that every branch ends with timer being added. But this is
> > really minor, so unless you have a really strong opinion against the
> > suggested structured, can we just do that?
> 
> Sure, we can go with the one you suggested.

Hello Tejun,

While I was reworking the code with your suggestion, I found out 
that there is a difference in our suggestions:

###
        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);
        }
###

In your suggestion you always check housekeeping to be sure that the timer 
is never handled on an isolated cpu.

In my suggestions, it only checks and use housekeeping cpus only
if (cpu == WORK_CPU_UNBOUND).

I was previously afraid to use the approach of your suggestion due to some 
user having the need to handle the timer on the cpu passed as parameter.

But now thinking on it again, it does make sense that the CPU which handles 
the timer has nothing to do with the one that actually runs the work
(other than possible cacheline optimizations), and your suggestion is much 
better for CPU Isolation than mine.

I will send the v2 soon.

Thanks again,
Leo

> 
> Thanks!
> Leo
> 
> > 
> > Thanks.
> > 
> > -- 
> > tejun
> > 


      reply	other threads:[~2024-01-29 21:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26  1:03 [PATCH v1 1/1] wq: Avoid using isolated cpus' timers on unbounded queue_delayed_work Leonardo Bras
2024-01-26 21:49 ` Tejun Heo
2024-01-26 22:05   ` Leonardo Bras
2024-01-29 18:18     ` Tejun Heo
2024-01-29 19:26       ` Leonardo Bras
2024-01-29 20:51         ` Tejun Heo
2024-01-29 20:54           ` Leonardo Bras
2024-01-29 21:17             ` Leonardo Bras [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZbgV3kRXqigZ6pW2@LeoBras \
    --to=leobras@redhat.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox