mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Naman Jain <namjain@linux.microsoft.com>
To: "Michael Kelley" <mhklinux@outlook.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Wei Liu" <wei.liu@kernel.org>,
	"Dexuan Cui" <decui@microsoft.com>,
	"Long Li" <longli@microsoft.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] PCI: hv: Probe vPCI buses asynchronously
Date: Wed, 23 Sep 2026 09:50:03 +0530	[thread overview]
Message-ID: <fabfdde6-9b9a-4879-9de0-c6ff18045e02@linux.microsoft.com> (raw)
In-Reply-To: <SN6PR02MB41574C84E56157D1FC2E4F86D4832@SN6PR02MB4157.namprd02.prod.outlook.com>



On 9/22/2026 8:12 PM, Michael Kelley wrote:
> From: Naman Jain <namjain@linux.microsoft.com> Sent: Tuesday, September 22, 2026 2:09 AM
>>
>> On 9/22/2026 2:39 AM, Michael Kelley wrote:
>>> From: Naman Jain <namjain@linux.microsoft.com> Sent: Sunday, September 6, 2026 10:48 PM
>>>>
>>>> On Hyper-V guests each virtual PCI bus is enumerated by its own
>>>> hv_pci_probe() call. The probe performs several synchronous host
>>>> request/response exchanges while negotiating the protocol, querying bus
>>>> relations, entering D0, and reporting allocated resources. These waits
>>>> are latency-bound rather than CPU-bound.
>>>>
>>>> hv_pci registers as an ordinary VMBus driver, so driver_register() walks
>>>> matching vPCI buses and probes them sequentially while the driver's
>>>> initcall runs. On guests that expose several devices, each through its
>>>> own vPCI bus, this serialization adds the host round-trip latencies to
>>>> device initialization.
>>>>
>>>> Each bus is described by its own struct hv_pcibus_device, so
>>>> independent buses can be probed concurrently. Request asynchronous
>>>> probing via PROBE_PREFER_ASYNCHRONOUS, causing the driver core to
>>>> schedule matching buses for asynchronous probe work.
>>>>
>>>> On an Azure Standard_L32s_v3 guest with five vPCI targets (four NVMe
>>>> controllers and one Mellanox VF), Linux 7.2.3 was tested with one warm-up
>>>> and three measured boots per variant. The median interval from the first
>>>> hv_pci_probe() entry to the last return decreased from 2847.968 ms to
>>>> 2786.709 ms, a 61.259 ms (2.15%) improvement.
>>>
>>> The elapsed time improvement is rather disappointing given the
>>> complexity of the probing sequence and the number of interactions
>>> with the Hyper-V host. Do you have any insight into why there isn't a
>>> larger reduction? Is something mostly serializing the work even though
>>> PROBE_PREFER_ASYNCHRONOUS is specified?
>>>
>>> Michael
>>>
>>
>> I can see these reasons for not seeing great improvements:
>> 1. Timing of device offers from the host is beyond the control of guest
>> and the Hyper-V host may also be serializing the requests from the host.
> 
> Ah, right. This is probably the key factor.
> 
>> 2. Shared locks that needs to be handled separately:
>>      * hyperv_mmio_lock during VMBus MMIO allocation.
> 
> This probably has minimal impact. While there's a decent amount
> of code protected by the lock, I don't think there's any interaction
> with the host (even via traps), so it should run quickly.
> 
>>      * pci_rescan_remove_lock during PCI resource assignment and device
>> addition.
> 
> OK. I don’t know about this one.
> 
>>
>>
>> I digged more into it, and it is indeed because of late offers from
>> Hyper-V. I was considering the start of first probe to the last return,
>> for time calculations.
>>
>> For the 4 PCI devices on my setup whose offers were delivered together,
>> the performance improvement was about 24%. However with the last offer
>> coming late for MLX PCI device, overall improvement in time was lesser
>> in terms of percentage.
> 
> For traditional configs where the VF NIC is paired with a netvsc
> instance, the host doesn't offer the VF NIC to the guest until the
> corresponding netvsc instance has been probed and the netvsc
> driver has told the host it will accept a VF NIC. In these cases, the
> Mellanox or MANA VF NIC device is always "late" and probably
> shouldn't be included when determining the speed-up of doing
> hv_pci probing asynchronously.
> 
>>
>> Dexuan had removed pci_rescan_remove_lock in his previous upstream
>> attempt, but I ommitted it intentionally this time because from AI
>> review, I saw a potential race condition that we would introduce if we
>> remove it. Secondly, I did not observe any benefits of removing this
>> lock. But I am going to revisit it again.
> 
> Thanks for the discussion. Using PROBE_PREFER_ASYNCHRONOUS
> is still a good thing to use, but the benefit will accrue the most when
> there are a significant number of NVMe devices and when Hyper-V
> is quick about offering them. As I described above, it will be harder
> to get parallelism with the VF NIC.
> 
> Michael

Thanks Michael, this makes sense now. I'm glad that you asked.

Regards,
Naman

      reply	other threads:[~2026-09-23  4:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  5:47 Naman Jain
2026-09-17  5:31 ` Sahil Chandna
2026-09-19 23:09   ` Wei Liu
2026-09-21 21:09 ` Michael Kelley
2026-09-22  9:08   ` Naman Jain
2026-09-22 14:42     ` Michael Kelley
2026-09-23  4:20       ` Naman Jain [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=fabfdde6-9b9a-4879-9de0-c6ff18045e02@linux.microsoft.com \
    --to=namjain@linux.microsoft.com \
    --cc=bhelgaas@google.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kwilczynski@kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=robh@kernel.org \
    --cc=wei.liu@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

all inboxes | Powered by JetHome®