linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nitesh Lal <nilal@redhat.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"frederic@kernel.org" <frederic@kernel.org>,
	"juri.lelli@redhat.com" <juri.lelli@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
	jbrandeb@kernel.org, Alex Belits <abelits@marvell.com>,
	"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"sfr@canb.auug.org.au" <sfr@canb.auug.org.au>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>,
	"rppt@linux.vnet.ibm.com" <rppt@linux.vnet.ibm.com>,
	"jinyuqi@huawei.com" <jinyuqi@huawei.com>,
	"zhangshaokun@hisilicon.com" <zhangshaokun@hisilicon.com>,
	netdev@vger.kernel.org, chris.friesen@windriver.com,
	Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint
Date: Mon, 17 May 2021 14:21:47 -0400	[thread overview]
Message-ID: <CAFki+L=LDizBJmFUieMDg9J=U6mn6XxTPPkAaWiyppTouTzaqw@mail.gmail.com> (raw)
In-Reply-To: <bf1d4892-0639-0bbf-443e-ba284a8ed457@arm.com>

On Mon, May 17, 2021 at 1:26 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2021-05-17 17:57, Nitesh Lal wrote:
> > On Tue, May 4, 2021 at 12:25 PM Jesse Brandeburg
> > <jesse.brandeburg@intel.com> wrote:
> >>
> >> Robin Murphy wrote:
> >>
> >>> On 2021-05-01 03:18, Jesse Brandeburg wrote:
> >>>> It was pointed out by Nitesh that the original work I did in 2014
> >>>> to automatically set the interrupt affinity when requesting a
> >>>> mask is no longer necessary. The kernel has moved on and no
> >>>> longer has the original problem, BUT the original patch
> >>>> introduced a subtle bug when booting a system with reserved or
> >>>> excluded CPUs. Drivers calling this function with a mask value
> >>>> that included a CPU that was currently or in the future
> >>>> unavailable would generally not update the hint.
> >>>>
> >>>> I'm sure there are a million ways to solve this, but the simplest
> >>>> one is to just remove a little code that tries to force the
> >>>> affinity, as Nitesh has shown it fixes the bug and doesn't seem
> >>>> to introduce immediate side effects.
> >>>
> >>> Unfortunately, I think there are quite a few other drivers now relying
> >>> on this behaviour, since they are really using irq_set_affinity_hint()
> >>> as a proxy for irq_set_affinity(). Partly since the latter isn't
> >>> exported to modules, but also I have a vague memory of it being said
> >>> that it's nice to update the user-visible hint to match when the
> >>> affinity does have to be forced to something specific.
> >>>
> >>> Robin.
> >>
> >> Thanks for your feedback Robin, but there is definitely a bug here that
> >> is being exposed by this code. The fact that people are using this
> >> function means they're all exposed to this bug.
> >>
> >> Not sure if you saw, but this analysis from Nitesh explains what
> >> happened chronologically to the kernel w.r.t this code, it's a useful
> >> analysis! [1]
> >>
> >> I'd add in addition that irqbalance daemon *stopped* paying attention
> >> to hints quite a while ago, so I'm not quite sure what purpose they
> >> serve.
> >>
> >> [1]
> >> https://lore.kernel.org/lkml/CAFki+Lm0W_brLu31epqD3gAV+WNKOJfVDfX2M8ZM__aj3nv9uA@mail.gmail.com/
> >>
> >
> > Wanted to follow up to see if there are any more objections or even
> > suggestions to take this forward?
>
> Oops, sorry, seems I got distracted before getting round to actually
> typing up my response :)

No worries.

>
> I'm not implying that there isn't a bug, or that this code ever made
> sense in the first place, just that fixing it will unfortunately be a
> bit more involved than a simple revert.

Fair point.

> This patch as-is *will* subtly
> break at least the system PMU drivers currently using
> irq_set_affinity_hint() - those I know require the IRQ affinity to
> follow whichever CPU the PMU context is bound to, in order to meet perf
> core's assumptions about mutual exclusion.

Thanks for bringing this up.
Please correct me if I am wrong, so the PMU driver(s) is/are written
in a way that
it uses the hint API to overwrite the previously set affinity mask with a
CPU to which the PMU context is bound to?

Is this context information exposed in the userspace and can we modify the
IRQ affinity mask from the userspace based on that?
I do understand that this is a behavior change from the PMU drivers
perspective.

>
> As far as the consistency argument goes, maybe that's just backwards and
> it should be irq_set_affinity() that also sets the hint, to indicate to
> userspace that the affinity has been forced by the kernel? Either way
> we'll need to do a little more diligence to figure out which callers
> actually care about more than just the hint, and sort them out first.
>

We can use irq_set_affinity() to set the hint mask as well, however, maybe
there is a specific reason behind separating those two in the
first place (maybe not?).
But even in this case, we have to either modify the PMU drivers' IRQs
affinity from the userspace or we will have to make changes in the existing
request_irq code path.
I am not sure about the latter because we already have the required controls
to adjust the device IRQ mask (by using default_smp_affinity or by modifying
them manually).

-- 
Thanks
Nitesh


  parent reply	other threads:[~2021-05-17 18:22 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-01  2:18 [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint Jesse Brandeburg
2021-05-04 12:15 ` Robin Murphy
2021-05-04 14:29   ` Nitesh Lal
2021-05-04 16:23   ` Jesse Brandeburg
2021-05-17 16:57     ` Nitesh Lal
2021-05-17 17:26       ` Robin Murphy
2021-05-17 18:08         ` Thomas Gleixner
2021-05-17 18:50           ` Robin Murphy
2021-05-17 19:08             ` Thomas Gleixner
2021-05-17 19:43               ` Thomas Gleixner
2021-05-17 20:18               ` Thomas Gleixner
2021-05-17 18:21         ` Nitesh Lal [this message]
2021-05-17 19:47           ` Thomas Gleixner
2021-05-17 21:13             ` Nitesh Lal
2021-05-17 20:48     ` Thomas Gleixner
2021-05-17 22:44       ` Nitesh Lal
2021-05-18  0:03         ` Thomas Gleixner
2021-05-18  0:23           ` Nitesh Lal
2021-05-20 21:57             ` Nitesh Lal
2021-05-21  0:03               ` Nitesh Lal
2021-05-21 11:56                 ` Thomas Gleixner
2021-05-21 12:03                   ` [PATCH] genirq: Provide new interfaces for affinity hints Thomas Gleixner
2021-05-21 15:45                     ` Lijun Pan
2021-05-21 21:45                       ` Thomas Gleixner
2021-05-21 16:13                     ` Nitesh Lal
2021-05-21 21:48                       ` Thomas Gleixner
2021-06-04 20:35                         ` Nitesh Lal
2021-05-27 10:03                     ` Shung-Hsi Yu
2021-05-27 10:21                       ` Shung-Hsi Yu
2021-05-27 13:06                       ` Nitesh Lal
2021-05-28  7:20                         ` Shung-Hsi Yu
2021-06-07 17:00                     ` Nitesh Lal
2021-06-14 16:12                       ` Nitesh Lal
2021-05-21 13:46                   ` [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint Nitesh Lal
2021-05-21 15:15                     ` Thomas Gleixner
2021-12-10 19:54 ` [tip: irq/core] genirq: Provide new interfaces for affinity hints tip-bot2 for Thomas Gleixner

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='CAFki+L=LDizBJmFUieMDg9J=U6mn6XxTPPkAaWiyppTouTzaqw@mail.gmail.com' \
    --to=nilal@redhat.com \
    --cc=abelits@marvell.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhelgaas@google.com \
    --cc=chris.friesen@windriver.com \
    --cc=davem@davemloft.net \
    --cc=frederic@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jbrandeb@kernel.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=jinyuqi@huawei.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=rppt@linux.vnet.ibm.com \
    --cc=sfr@canb.auug.org.au \
    --cc=stephen@networkplumber.org \
    --cc=tglx@linutronix.de \
    --cc=zhangshaokun@hisilicon.com \
    /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;
as well as URLs for NNTP newsgroup(s).