Stefan Hajnoczi
2019-Sep-06 10:52 UTC
[PATCH 08/18] virtiofs: Drain all pending requests during ->remove time
On Thu, Sep 05, 2019 at 03:48:49PM -0400, Vivek Goyal wrote:> +static void virtio_fs_drain_queue(struct virtio_fs_vq *fsvq) > +{ > + WARN_ON(fsvq->in_flight < 0); > + > + /* Wait for in flight requests to finish.*/ > + while (1) { > + spin_lock(&fsvq->lock); > + if (!fsvq->in_flight) { > + spin_unlock(&fsvq->lock); > + break; > + } > + spin_unlock(&fsvq->lock); > + usleep_range(1000, 2000); > + }I think all contexts that call this allow sleeping so we could avoid usleep here. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20190906/68e571eb/attachment.sig>
Vivek Goyal
2019-Sep-06 14:17 UTC
[PATCH 08/18] virtiofs: Drain all pending requests during ->remove time
On Fri, Sep 06, 2019 at 11:52:10AM +0100, Stefan Hajnoczi wrote:> On Thu, Sep 05, 2019 at 03:48:49PM -0400, Vivek Goyal wrote: > > +static void virtio_fs_drain_queue(struct virtio_fs_vq *fsvq) > > +{ > > + WARN_ON(fsvq->in_flight < 0); > > + > > + /* Wait for in flight requests to finish.*/ > > + while (1) { > > + spin_lock(&fsvq->lock); > > + if (!fsvq->in_flight) { > > + spin_unlock(&fsvq->lock); > > + break; > > + } > > + spin_unlock(&fsvq->lock); > > + usleep_range(1000, 2000); > > + } > > I think all contexts that call this allow sleeping so we could avoid > usleep here.usleep_range() is supposed to be used from non-atomic context. https://github.com/torvalds/linux/blob/master/Documentation/timers/timers-howto.rst What construct you are thinking of? Vivek
Michael S. Tsirkin
2019-Sep-06 14:18 UTC
[PATCH 08/18] virtiofs: Drain all pending requests during ->remove time
On Fri, Sep 06, 2019 at 10:17:05AM -0400, Vivek Goyal wrote:> On Fri, Sep 06, 2019 at 11:52:10AM +0100, Stefan Hajnoczi wrote: > > On Thu, Sep 05, 2019 at 03:48:49PM -0400, Vivek Goyal wrote: > > > +static void virtio_fs_drain_queue(struct virtio_fs_vq *fsvq) > > > +{ > > > + WARN_ON(fsvq->in_flight < 0); > > > + > > > + /* Wait for in flight requests to finish.*/ > > > + while (1) { > > > + spin_lock(&fsvq->lock); > > > + if (!fsvq->in_flight) { > > > + spin_unlock(&fsvq->lock); > > > + break; > > > + } > > > + spin_unlock(&fsvq->lock); > > > + usleep_range(1000, 2000); > > > + } > > > > I think all contexts that call this allow sleeping so we could avoid > > usleep here. > > usleep_range() is supposed to be used from non-atomic context. > > https://github.com/torvalds/linux/blob/master/Documentation/timers/timers-howto.rst > > What construct you are thinking of? > > Vivekcompletion + signal on vq callback? -- MST
Seemingly Similar Threads
- [PATCH 08/18] virtiofs: Drain all pending requests during ->remove time
- [PATCH 08/18] virtiofs: Drain all pending requests during ->remove time
- [PATCH 08/18] virtiofs: Drain all pending requests during ->remove time
- [PATCH 08/18] virtiofs: Drain all pending requests during ->remove time
- [PATCH 0/3] virtiofs: Small Cleanups for 5.5