From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kent Overstreet Subject: Re: [PATCH 13/25] aio: Convert read_events() to hrtimers Date: Wed, 28 Nov 2012 17:05:16 -0800 Message-ID: <20121129010516.GB15094@google.com> References: <1354121029-1376-1-git-send-email-koverstreet@google.com> <1354121029-1376-14-git-send-email-koverstreet@google.com> <20121129002436.GI18574@lenny.home.zabbo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, bcrl@kvack.org, jmoyer@redhat.com, axboe@kernel.dk, viro@zeniv.linux.org.uk To: Zach Brown Return-path: Content-Disposition: inline In-Reply-To: <20121129002436.GI18574@lenny.home.zabbo.net> Sender: owner-linux-aio@kvack.org List-Id: linux-fsdevel.vger.kernel.org On Wed, Nov 28, 2012 at 04:24:36PM -0800, Zach Brown wrote: > > - int i = 0; > > + DEFINE_WAIT(wait); > > + struct hrtimer_sleeper t; > > + size_t i = 0; > > Changing i to size_t is kind of surprising. Is that on purpose? I doubt it matters due to limits on ringbuffer size elsewhere but size_t is more correct, since we're counting objects in an array. > > - set_task_state(tsk, TASK_RUNNING); > > - remove_wait_queue(&ctx->wait, &wait); > > - > > if (unlikely(ret <= 0)) > > break; > > > > @@ -879,11 +844,10 @@ static int read_events(struct kioctx *ctx, > > event ++; > > i ++; > > } > > - > > - if (timeout) > > - clear_timeout(&to); > > out: > > - destroy_timer_on_stack(&to.timer); > > + hrtimer_cancel(&t.timer); > > + destroy_hrtimer_on_stack(&t.timer); > > + finish_wait(&ctx->wait, &wait); > > I'd move the finish_wait() up to where TASK_RUNNING was set previously > so that we can't call copy_to_user() while still set to > TASK_INTERRUPTIBLE. Slightly less efficient, but yeah that's more correct and this code all changes later anyways. -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: aart@kvack.org