From: Andrew Morton prepare_to_wait()/finish_wait() is a little faster that the old-style functions (less cross-CPU traffic). Cc: Jeff Moyer Cc: Zach Brown Cc: Benjamin LaHaise Signed-off-by: Andrew Morton --- fs/aio.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff -puN fs/aio.c~aio-use-prepare_to_wait fs/aio.c --- a/fs/aio.c~aio-use-prepare_to_wait +++ a/fs/aio.c @@ -1112,7 +1112,7 @@ static int read_events(struct kioctx *ct { long start_jiffies = jiffies; struct task_struct *tsk = current; - DECLARE_WAITQUEUE(wait, tsk); + DEFINE_WAIT(wait); int ret; int i = 0; struct io_event ent; @@ -1173,7 +1173,7 @@ retry: while (likely(i < nr)) { add_wait_queue_exclusive(&ctx->wait, &wait); do { - set_task_state(tsk, TASK_INTERRUPTIBLE); + prepare_to_wait(&ctx->wait, &wait, TASK_INTERRUPTIBLE); ret = aio_read_evt(ctx, &ent); if (ret) break; @@ -1188,10 +1188,8 @@ retry: break; } /*ret = aio_read_evt(ctx, &ent);*/ - } while (1) ; - - set_task_state(tsk, TASK_RUNNING); - remove_wait_queue(&ctx->wait, &wait); + } while (1); + finish_wait(&ctx->wait, &wait); if (unlikely(ret <= 0)) break; _