Re: [PATCH] virtio_pci_modern: replace msleep(1) with usleep_range(1000, 2000)

From: Mirza Ishan Beg

Date: Mon Aug 17 2026 - 13:04:29 EST


On Sun, Aug 16, 2026 at 05:38:06PM -0400, Michael S. Tsirkin wrote:
> why do we care?

Hi Michael,

The motivation originally came from a checkpatch.pl warning, but looking directly at Documentation/timers/timers-howto.rst, there is a practical penalty here.

The documentation explicitly notes for the 1-20ms range: "msleep(1~20) may not do what the caller intends, and will often sleep longer (~20 ms actual sleep for any value given in the 1~20ms range)."

In these queue reset loops, using msleep(1) means each iteration may be extended to 10-20ms depending on HZ and timer slack. The document recommends using usleep_range() to avoid this overhead and provide the intended precision.

Let me know if you'd like this explanation folded into a v2 commit message.

--
Mirza