Re: [PATCH] PCI: hv: Warn when wait_for_response() waits indefinitely
From: Saurabh Singh Sengar
Date: Thu Aug 27 2026 - 13:35:10 EST
On Thu, Aug 27, 2026 at 04:07:06PM +0000, Michael Kelley wrote:
> From: Long Li <longli@xxxxxxxxxxxxx> Sent: Tuesday, August 25, 2026 10:01 AM
>
> [snip]
>
> > >
> > > Basically something like this:
> > >
> > > #define PCI_RESPONSE_WARN_TIMEOUT_SEC 300
> > >
> > > static int wait_for_response(struct hv_device *hdev,
> > > struct completion *comp) {
> > > unsigned long warn_at =
> > > jiffies + secs_to_jiffies(PCI_RESPONSE_WARN_TIMEOUT_SEC);
> > > bool warned = false;
> > >
> > > while (true) {
> > > if (hdev->channel->rescind) {
> > > dev_warn_once(&hdev->device, "The device is gone.\n");
> > > return -ENODEV;
> > > }
> > >
> > > if (wait_for_completion_timeout(comp, HZ / 10)) {
> > > if (warned || time_after_eq(jiffies, warn_at))
> > > dev_warn(&hdev->device,
> > > "PCI response received after prolonged wait.\n");
> > > return 0;
> > > }
> > >
> > > if (!warned && time_after_eq(jiffies, warn_at)) {
> > > dev_warn(&hdev->device,
> > > "PCI still waiting for response.\n");
> > > warned = true;
> > > }
> > > }
> > > }
> > >
> > > Regards,
> > > Naman
> >
> > This looks better.
> >
>
> I like getting the "response received" message if the response
> eventually does come in. It's a judgment call, but I would be OK
> with outputting the "still waiting" message after each wait interval
> rather than doing it only once. And I would make the interval smaller
> than 300 seconds. Five minutes is a long time to wait and wonder
> what's going on when things are hung. 60 or 120 seconds would
> be OK -- a line in dmesg every 1 or 2 minutes doesn't seem like
> spamming to me when something is fundamentally broken.
> And probably don't expect a VM in this broken state to keep running
> for hours -- the sysadmin or automatic monitoring software will
> reboot it to get it working again.
I will also vote for repeated message as long as interval between two
messages is greater than 60 seconds.
- Saurabh
>
> Just my $.02. Outputting the "still waiting" message only once is
> also OK. Your call.
>
> Michael