Re: [PATCH][2.6-mm] Avoid flushing AIO workqueue on cancel/exit

From: Suparna Bhattacharya
Date: Tue Oct 21 2003 - 06:22:32 EST


On Tue, Oct 21, 2003 at 03:59:00AM -0700, Andrew Morton wrote:
> Suparna Bhattacharya <suparna@xxxxxxxxxx> wrote:
> >
> > When streaming AIO requests are in progress on multiple
> > io context's, flushing the AIO workqueue on i/o cancellation
> > or process exit could potentially end up waiting for a
> > long time as fresh requests from other active ioctx's keep
> > getting queued up.
>
> But flush_workqueue() will ignore any newly-added work requests:
>
> * This function will sample each workqueue's current insert_sequence number and
> * will sleep until the head sequence is greater than or equal to that. This
> * means that we sleep until all works which were queued on entry have been
> * handled, but we are not livelocked by new incoming ones.

True. I must have had an old version of workqueue.c in mind ... which
had a warning of that sort; I didn't realise that had been fixed.

Now that we have included the patch to splice the AIO runlist,
newer requests getting queued up on the ioctx shouldn't livelock us.

So yes this isn't strictly necessary. We still have one ioctx cancellation
waiting for ongoing retries on other ioctx's system wide to get done,
instead of just the io context being cancelled, but that's probably
not so bad. We can wait till that shows up as a real problem.

>
> Now, flush_workqueue() is potentially inefficient on SMP because it flushes
> each CPU's workqueue sequentially. But we can fix that in
> flush_workqueue() by converting it to a two-pass approach:
>
> a) gather each CPU's insert_sequence number into a local array[NR_CPUS]
>
> b) wait until each CPU's remove_sequence number exceeds the previously-gathered
> insert_sequence number.
>

Regards
Suparna

>
> --
> To unsubscribe, send a message with 'unsubscribe linux-aio' in
> the body to majordomo@xxxxxxxxxx For more info on Linux AIO,
> see: http://www.kvack.org/aio/
> Don't email: <a href=mailto:"aart@xxxxxxxxx";>aart@xxxxxxxxx</a>

--
Suparna Bhattacharya (suparna@xxxxxxxxxx)
Linux Technology Center
IBM Software Labs, India

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/