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

From: Andrew Morton
Date: Tue Oct 21 2003 - 06:00:26 EST


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.

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.


-
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/