lkml.org 
[lkml]   [2020]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] eventfd: convert to f_op->read_iter()
From
Date
On 5/1/20 11:43 AM, Al Viro wrote:
> On Fri, May 01, 2020 at 11:18:05AM -0600, Jens Axboe wrote:
>
>> - if (res > 0 && put_user(ucnt, (__u64 __user *)buf))
>> + if (res > 0 && copy_to_iter(&ucnt, res, iov) < res)
>
> *whoa*
>
> It is correct, but only because here res > 0 <=> res == 8.
> And that's not trivial at the first glance.
>
> Please, turn that into something like

Looks good to me, just one minor edit:

> if (iov_iter_count(to) < sizeof(ucnt))
> return -EINVAL;
> spin_lock_irq(&ctx->wqh.lock);
> if (!ctx->count) {
> if (unlikely(file->f_flags & O_NONBLOCK) {
> spin_unlock_irq(&ctx->wqh.lock)
> return -EAGAIN;
> }
> __add_wait_queue(&ctx->wqh, &wait);
> for (;;) {
> set_current_state(TASK_INTERRUPTIBLE);
> if (ctx->count)
> break;
> if (signal_pending(current)) {
> spin_unlock_irq(&ctx->wqh.lock)
> return -ERESTARTSYS;
> }

We need to remove waitq and re-set task state here. I'll run a sanity
check on that and send out a v3.

--
Jens Axboe

\
 
 \ /
  Last update: 2020-05-01 19:49    [W:0.037 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site