dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Thomas Gleixner" <tglx@linutronix.de>,
	boris.ostrovsky@oracle.com, "Jürgen Groß" <jgross@suse.com>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Karthikeyan Mitran <m.karthikeyan@mobiveil.co.in>,
	Peter Zijlstra <peterz@infradead.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	dri-devel@lists.freedesktop.org,
	Chris Wilson <chris@chris-wilson.co.uk>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	Will Deacon <will@kernel.org>,
	Michal Simek <michal.simek@xilinx.com>,
	linux-s390@vger.kernel.org,
	afzal mohammed <afzal.mohd.ma@gmail.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>,
	Leon Romanovsky <leon@kernel.org>,
	linux-rdma@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	Helge Deller <deller@gmx.de>,
	Russell King <linux@armlinux.org.uk>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org,
	Heiko Carstens <hca@linux.ibm.com>,
	Wambui Karuga <wambui.karugax@gmail.com>,
	Allen Hubbe <allenbh@gmail.com>, David Airlie <airlied@linux.ie>,
	linux-gpio@vger.kernel.org,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Lee Jones <lee.jones@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	linux-parisc@vger.kernel.org,
	Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>,
	Hou Zhiqiang <Zhiqiang.Hou@nxp.com>,
	Tariq Toukan <tariqt@nvidia.com>, Jon Mason <jdmason@kudzu.us>,
	linux-ntb@googlegroups.com, intel-gfx@lists.freedesktop.org,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [patch 27/30] xen/events: Only force affinity mask for percpu interrupts
Date: Fri, 11 Dec 2020 22:21:19 +0000	[thread overview]
Message-ID: <edbedd7a-4463-d934-73c9-fa046c19cf6d@citrix.com> (raw)
In-Reply-To: <877dpoghio.fsf@nanos.tec.linutronix.de>

On 11/12/2020 21:27, Thomas Gleixner wrote:
> On Fri, Dec 11 2020 at 09:29, boris ostrovsky wrote:
>
>> On 12/11/20 7:37 AM, Thomas Gleixner wrote:
>>> On Fri, Dec 11 2020 at 13:10, Jürgen Groß wrote:
>>>> On 11.12.20 00:20, boris.ostrovsky@oracle.com wrote:
>>>>> On 12/10/20 2:26 PM, Thomas Gleixner wrote:
>>>>>> Change the implementation so that the channel is bound to CPU0 at the XEN
>>>>>> level and leave the affinity mask alone. At startup of the interrupt
>>>>>> affinity will be assigned out of the affinity mask and the XEN binding will
>>>>>> be updated.
>>>>> If that's the case then I wonder whether we need this call at all and instead bind at startup time.
>>>> After some discussion with Thomas on IRC and xen-devel archaeology the
>>>> result is: this will be needed especially for systems running on a
>>>> single vcpu (e.g. small guests), as the .irq_set_affinity() callback
>>>> won't be called in this case when starting the irq.
>> On UP are we not then going to end up with an empty affinity mask? Or
>> are we guaranteed to have it set to 1 by interrupt generic code?
> An UP kernel does not ever look on the affinity mask. The
> chip::irq_set_affinity() callback is not invoked so the mask is
> irrelevant.
>
> A SMP kernel on a UP machine sets CPU0 in the mask so all is good.
>
>> This is actually why I brought this up in the first place --- a
>> potential mismatch between the affinity mask and Xen-specific data
>> (e.g. info->cpu and then protocol-specific data in event channel
>> code). Even if they are re-synchronized later, at startup time (for
>> SMP).
> Which is not a problem either. The affinity mask is only relevant for
> setting the affinity, but it's not relevant for delivery and never can
> be.
>
>> I don't see anything that would cause a problem right now but I worry
>> that this inconsistency may come up at some point.
> As long as the affinity mask becomes not part of the event channel magic
> this should never matter.
>
> Look at it from hardware:
>
> interrupt is affine to CPU0
>
>      CPU0 runs:
>      
>      set_affinity(CPU0 -> CPU1)
>         local_irq_disable()
>         
>  --> interrupt is raised in hardware and pending on CPU0
>
>         irq hardware is reconfigured to be affine to CPU1
>
>         local_irq_enable()
>
>  --> interrupt is handled on CPU0
>
> the next interrupt will be raised on CPU1
>
> So info->cpu which is registered via the hypercall binds the 'hardware
> delivery' and whenever the new affinity is written it is rebound to some
> other CPU and the next interrupt is then raised on this other CPU.
>
> It's not any different from the hardware example at least not as far as
> I understood the code.

Xen's event channels do have a couple of quirks.

Binding an event channel always results in one spurious event being
delivered.  This is to cover notifications which can get lost during the
bidirectional setup, or re-setups in certain configurations.

Binding an interdomain or pirq event channel always defaults to vCPU0. 
There is no way to atomically set the affinity while binding.  I believe
the API predates SMP guest support in Xen, and noone has fixed it up since.

As a consequence, the guest will observe the event raised on vCPU0 as
part of setting up the event, even if it attempts to set a different
affinity immediately afterwards.  A little bit of care needs to be taken
when binding an event channel on vCPUs other than 0, to ensure that the
callback is safe with respect to any remaining state needing initialisation.

Beyond this, there is nothing magic I'm aware of.

We have seen soft lockups before in certain scenarios, simply due to the
quantity of events hitting vCPU0 before irqbalance gets around to
spreading the load.  This is why there is an attempt to round-robin the
userspace event channel affinities by default, but I still don't see why
this would need custom affinity logic itself.

Thanks,

~Andrew
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-12-14  8:18 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 19:25 [patch 00/30] genirq: Treewide hunt for irq descriptor abuse and assorted fixes Thomas Gleixner
2020-12-10 19:25 ` [patch 01/30] genirq: Move irq_has_action() into core code Thomas Gleixner
2020-12-10 19:25 ` [patch 02/30] genirq: Move status flag checks to core Thomas Gleixner
2020-12-27 19:20   ` Guenter Roeck
2021-01-11 10:14     ` Thomas Gleixner
2020-12-10 19:25 ` [patch 03/30] genirq: Move irq_set_lockdep_class() " Thomas Gleixner
2020-12-11 17:53   ` Andy Shevchenko
2020-12-11 21:08     ` Thomas Gleixner
2020-12-11 22:07       ` Thomas Gleixner
2020-12-12 13:22         ` Andy Shevchenko
2020-12-10 19:25 ` [patch 04/30] genirq: Provide irq_get_effective_affinity() Thomas Gleixner
2020-12-10 19:25 ` [patch 05/30] genirq: Annotate irq stats data races Thomas Gleixner
2020-12-10 19:25 ` [patch 06/30] parisc/irq: Simplify irq count output for /proc/interrupts Thomas Gleixner
2020-12-10 19:25 ` [patch 07/30] genirq: Make kstat_irqs() static Thomas Gleixner
2020-12-10 19:25 ` [patch 08/30] genirq: Provide kstat_irqdesc_cpu() Thomas Gleixner
2020-12-10 19:25 ` [patch 09/30] ARM: smp: Use irq_desc_kstat_cpu() in show_ipi_list() Thomas Gleixner
2020-12-11 18:08   ` Marc Zyngier
2020-12-10 19:25 ` [patch 10/30] arm64/smp: Use irq_desc_kstat_cpu() in arch_show_interrupts() Thomas Gleixner
2020-12-11 18:08   ` Marc Zyngier
2020-12-10 19:25 ` [patch 11/30] parisc/irq: Use irq_desc_kstat_cpu() in show_interrupts() Thomas Gleixner
2020-12-10 19:25 ` [patch 12/30] s390/irq: Use irq_desc_kstat_cpu() in show_msi_interrupt() Thomas Gleixner
2020-12-10 20:31   ` Heiko Carstens
2020-12-10 19:25 ` [patch 13/30] drm/i915/lpe_audio: Remove pointless irq_to_desc() usage Thomas Gleixner
2020-12-10 19:48   ` [Intel-gfx] " Ville Syrjälä
2020-12-11  9:51     ` Jani Nikula
2020-12-10 19:25 ` [patch 14/30] drm/i915/pmu: Replace open coded kstat_irqs() copy Thomas Gleixner
2020-12-11  9:54   ` Jani Nikula
2020-12-11 10:13   ` Tvrtko Ursulin
2020-12-11 12:57     ` Thomas Gleixner
2020-12-11 14:19       ` David Laight
2020-12-11 21:10         ` Thomas Gleixner
2020-12-11 22:06           ` David Laight
2020-12-10 19:25 ` [patch 15/30] pinctrl: nomadik: Use irq_has_action() Thomas Gleixner
2020-12-12  0:45   ` Linus Walleij
2020-12-10 19:25 ` [patch 16/30] mfd: ab8500-debugfs: Remove the racy fiddling with irq_desc Thomas Gleixner
2020-12-11  8:22   ` Linus Walleij
2020-12-11 10:04   ` Lee Jones
2020-12-11 18:12   ` Andy Shevchenko
2020-12-10 19:25 ` [patch 17/30] NTB/msi: Use irq_has_action() Thomas Gleixner
2020-12-10 20:33   ` Logan Gunthorpe
2020-12-10 19:25 ` [patch 18/30] PCI: xilinx-nwl: Use irq_data_get_irq_chip_data() Thomas Gleixner
2020-12-10 22:56   ` Rob Herring
2020-12-10 19:25 ` [patch 19/30] PCI: mobiveil: " Thomas Gleixner
2020-12-10 22:56   ` Rob Herring
2020-12-10 19:25 ` [patch 20/30] net/mlx4: Replace irq_to_desc() abuse Thomas Gleixner
2020-12-13 11:24   ` Tariq Toukan
2020-12-10 19:25 ` [patch 21/30] net/mlx4: Use effective interrupt affinity Thomas Gleixner
2020-12-13 11:31   ` Tariq Toukan
2020-12-10 19:25 ` [patch 22/30] net/mlx5: Replace irq_to_desc() abuse Thomas Gleixner
2020-12-13 11:34   ` Tariq Toukan
2020-12-14 21:13   ` Saeed Mahameed
2020-12-10 19:25 ` [patch 23/30] net/mlx5: Use effective interrupt affinity Thomas Gleixner
2020-12-13 11:35   ` Tariq Toukan
2020-12-14 20:58   ` Saeed Mahameed
2020-12-10 19:26 ` [patch 24/30] xen/events: Remove unused bind_evtchn_to_irq_lateeoi() Thomas Gleixner
2020-12-10 23:19   ` boris.ostrovsky
2020-12-11  0:04     ` Thomas Gleixner
2020-12-10 19:26 ` [patch 25/30] xen/events: Remove disfunct affinity spreading Thomas Gleixner
2020-12-10 19:26 ` [patch 26/30] xen/events: Use immediate affinity setting Thomas Gleixner
2020-12-10 19:26 ` [patch 27/30] xen/events: Only force affinity mask for percpu interrupts Thomas Gleixner
2020-12-10 23:20   ` boris.ostrovsky
2020-12-11  0:06     ` Thomas Gleixner
2020-12-11  6:17     ` Jürgen Groß
     [not found]       ` <874kksiras.fsf@nanos.tec.linutronix.de>
2020-12-11 10:23         ` Jürgen Groß
2020-12-11 12:10     ` Jürgen Groß
2020-12-11 12:37       ` Thomas Gleixner
2020-12-11 14:29         ` boris.ostrovsky
2020-12-11 21:27           ` Thomas Gleixner
2020-12-11 22:21             ` Andrew Cooper [this message]
2020-12-11 22:56               ` Thomas Gleixner
2020-12-10 19:26 ` [patch 28/30] xen/events: Reduce irq_info::spurious_cnt storage size Thomas Gleixner
2020-12-10 19:26 ` [patch 29/30] xen/events: Implement irq distribution Thomas Gleixner
2020-12-10 19:26 ` [patch 30/30] genirq: Remove export of irq_to_desc() 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=edbedd7a-4463-d934-73c9-fa046c19cf6d@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=Zhiqiang.Hou@nxp.com \
    --cc=afzal.mohd.ma@gmail.com \
    --cc=airlied@linux.ie \
    --cc=allenbh@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=borntraeger@de.ibm.com \
    --cc=catalin.marinas@arm.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dave.jiang@intel.com \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hca@linux.ibm.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jdmason@kudzu.us \
    --cc=jgross@suse.com \
    --cc=kuba@kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=leon@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntb@googlegroups.com \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=m.karthikeyan@mobiveil.co.in \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.laxminarayan.bharadiya@intel.com \
    --cc=peterz@infradead.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=saeedm@nvidia.com \
    --cc=sstabellini@kernel.org \
    --cc=tariqt@nvidia.com \
    --cc=tglx@linutronix.de \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=wambui.karugax@gmail.com \
    --cc=will@kernel.org \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).