RE: [PATCH v2] PCI: hv: Only reuse existing IRTE allocation for Multi-MSI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Michael Kelley (LINUX) <mikelley@xxxxxxxxxxxxx>
> Sent: Tuesday, October 25, 2022 11:18 AM
> > ...
> > -static u32 hv_compose_msi_req_v2(
> > -	struct pci_create_interrupt2 *int_pkt, const struct cpumask *affinity,
> > -	u32 slot, u8 vector, u8 vector_count)
> > +/*
> > + * Make sure the dummy vCPU values for multi-MSI don't all point to vCPU0.
> > + */
> > +static int hv_compose_multi_msi_req_get_cpu(void)
> >  {
> > +	static DEFINE_SPINLOCK(multi_msi_cpu_lock);
> > +
> > +	/* -1 means starting with CPU 0 */
> > +	static int cpu_next = -1;
> > +
> > +	unsigned long flags;
> >  	int cpu;
> >
> > +	spin_lock_irqsave(&multi_msi_cpu_lock, flags);
> > +
> > +	cpu_next = cpumask_next_wrap(cpu_next, cpu_online_mask,
> nr_cpu_ids,
> > +				     false);
> 
> I have a modest concern about using cpu_online_mask.  The CPUs in this
> mask
> can change if a CPU is taken online or offline in Linux. I don't think there's
> a requirement to pick on an online CPU, especially since if we pick a CPU that's
> online now, it might not be online later.  Using cpu_present_mask would be
> more correct.  That's the CPUs that are present in the VM, which won't
> change
> over time since Hyper-V doesn't hot-add or hot-remove CPUs in a VM.
> 
> A similar concern applies to hv_compose_msi_req_get_cpu().
> 
> Michael

Here cpu_online_mask is better than cpu_present_mask.
It doesn't matter an online target CPU becomes offline later, because when
the CPU is brought offline, the kernel should automatically migrate the
interrupt to a different online CPU.

hv_compose_multi_msi_req_get_cpu() is called when a PCI devic driver's
.probe() function is called, and the .probe() is called from the context
of pci_call_probe(), where CPU hotplug is temporarily disabled/enabled, so
here cpu_online_mask should not be an issue.

Thanks,
Dexuan





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux