* [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated
@ 2020-04-07 0:44 Jason Gunthorpe
2020-04-07 5:16 ` Leon Romanovsky
2020-04-14 19:00 ` Jason Gunthorpe
0 siblings, 2 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2020-04-07 0:44 UTC (permalink / raw)
To: linux-rdma
From: Jason Gunthorpe <jgg@mellanox.com>
If is_closed is set, and the event list is empty, then read() will return
-EIO without blocking. After setting is_closed in
ib_uverbs_free_event_queue(), we do trigger a wake_up on the poll_wait,
but the fops->poll() function does not check it, so poll will continue to
sleep on an empty list.
Fixes: 14e23bd6d221 ("RDMA/core: Fix locking in ib_uverbs_event_read")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
drivers/infiniband/core/uverbs_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 2d4083bf4a0487..8710a3427146e7 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -296,6 +296,8 @@ static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,
spin_lock_irq(&ev_queue->lock);
if (!list_empty(&ev_queue->event_list))
pollflags = EPOLLIN | EPOLLRDNORM;
+ else if (ev_queue->is_closed)
+ pollflags = EPOLLERR;
spin_unlock_irq(&ev_queue->lock);
return pollflags;
--
2.25.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated
2020-04-07 0:44 [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated Jason Gunthorpe
@ 2020-04-07 5:16 ` Leon Romanovsky
2020-04-07 11:51 ` Jason Gunthorpe
2020-04-14 19:00 ` Jason Gunthorpe
1 sibling, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2020-04-07 5:16 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: linux-rdma
On Mon, Apr 06, 2020 at 09:44:26PM -0300, Jason Gunthorpe wrote:
> From: Jason Gunthorpe <jgg@mellanox.com>
>
> If is_closed is set, and the event list is empty, then read() will return
> -EIO without blocking. After setting is_closed in
> ib_uverbs_free_event_queue(), we do trigger a wake_up on the poll_wait,
> but the fops->poll() function does not check it, so poll will continue to
> sleep on an empty list.
>
> Fixes: 14e23bd6d221 ("RDMA/core: Fix locking in ib_uverbs_event_read")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> ---
> drivers/infiniband/core/uverbs_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> index 2d4083bf4a0487..8710a3427146e7 100644
> --- a/drivers/infiniband/core/uverbs_main.c
> +++ b/drivers/infiniband/core/uverbs_main.c
> @@ -296,6 +296,8 @@ static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,
> spin_lock_irq(&ev_queue->lock);
> if (!list_empty(&ev_queue->event_list))
> pollflags = EPOLLIN | EPOLLRDNORM;
> + else if (ev_queue->is_closed)
> + pollflags = EPOLLERR;
> spin_unlock_irq(&ev_queue->lock);
Don't you need to set EPOLLHUP too? Probably, it won't change anything,
just for the sake of the correctness.
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated
2020-04-07 5:16 ` Leon Romanovsky
@ 2020-04-07 11:51 ` Jason Gunthorpe
2020-04-07 12:20 ` Leon Romanovsky
0 siblings, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2020-04-07 11:51 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: linux-rdma
On Tue, Apr 07, 2020 at 08:16:32AM +0300, Leon Romanovsky wrote:
> On Mon, Apr 06, 2020 at 09:44:26PM -0300, Jason Gunthorpe wrote:
> > From: Jason Gunthorpe <jgg@mellanox.com>
> >
> > If is_closed is set, and the event list is empty, then read() will return
> > -EIO without blocking. After setting is_closed in
> > ib_uverbs_free_event_queue(), we do trigger a wake_up on the poll_wait,
> > but the fops->poll() function does not check it, so poll will continue to
> > sleep on an empty list.
> >
> > Fixes: 14e23bd6d221 ("RDMA/core: Fix locking in ib_uverbs_event_read")
> > Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> > drivers/infiniband/core/uverbs_main.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> > index 2d4083bf4a0487..8710a3427146e7 100644
> > +++ b/drivers/infiniband/core/uverbs_main.c
> > @@ -296,6 +296,8 @@ static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,
> > spin_lock_irq(&ev_queue->lock);
> > if (!list_empty(&ev_queue->event_list))
> > pollflags = EPOLLIN | EPOLLRDNORM;
> > + else if (ev_queue->is_closed)
> > + pollflags = EPOLLERR;
> > spin_unlock_irq(&ev_queue->lock);
>
> Don't you need to set EPOLLHUP too? Probably, it won't change anything,
> just for the sake of the correctness.
HUP means read will return 0, in this case read returns -EIO
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated
2020-04-07 11:51 ` Jason Gunthorpe
@ 2020-04-07 12:20 ` Leon Romanovsky
0 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2020-04-07 12:20 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: linux-rdma
On Tue, Apr 07, 2020 at 08:51:15AM -0300, Jason Gunthorpe wrote:
> On Tue, Apr 07, 2020 at 08:16:32AM +0300, Leon Romanovsky wrote:
> > On Mon, Apr 06, 2020 at 09:44:26PM -0300, Jason Gunthorpe wrote:
> > > From: Jason Gunthorpe <jgg@mellanox.com>
> > >
> > > If is_closed is set, and the event list is empty, then read() will return
> > > -EIO without blocking. After setting is_closed in
> > > ib_uverbs_free_event_queue(), we do trigger a wake_up on the poll_wait,
> > > but the fops->poll() function does not check it, so poll will continue to
> > > sleep on an empty list.
> > >
> > > Fixes: 14e23bd6d221 ("RDMA/core: Fix locking in ib_uverbs_event_read")
> > > Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> > > drivers/infiniband/core/uverbs_main.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> > > index 2d4083bf4a0487..8710a3427146e7 100644
> > > +++ b/drivers/infiniband/core/uverbs_main.c
> > > @@ -296,6 +296,8 @@ static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,
> > > spin_lock_irq(&ev_queue->lock);
> > > if (!list_empty(&ev_queue->event_list))
> > > pollflags = EPOLLIN | EPOLLRDNORM;
> > > + else if (ev_queue->is_closed)
> > > + pollflags = EPOLLERR;
> > > spin_unlock_irq(&ev_queue->lock);
> >
> > Don't you need to set EPOLLHUP too? Probably, it won't change anything,
> > just for the sake of the correctness.
>
> HUP means read will return 0, in this case read returns -EIO
I see, it is because we don't have events to read.
Thanks
>
> Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated
2020-04-07 0:44 [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated Jason Gunthorpe
2020-04-07 5:16 ` Leon Romanovsky
@ 2020-04-14 19:00 ` Jason Gunthorpe
1 sibling, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2020-04-14 19:00 UTC (permalink / raw)
To: linux-rdma
On Mon, Apr 06, 2020 at 09:44:26PM -0300, Jason Gunthorpe wrote:
> From: Jason Gunthorpe <jgg@mellanox.com>
>
> If is_closed is set, and the event list is empty, then read() will return
> -EIO without blocking. After setting is_closed in
> ib_uverbs_free_event_queue(), we do trigger a wake_up on the poll_wait,
> but the fops->poll() function does not check it, so poll will continue to
> sleep on an empty list.
>
> Fixes: 14e23bd6d221 ("RDMA/core: Fix locking in ib_uverbs_event_read")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> ---
> drivers/infiniband/core/uverbs_main.c | 2 ++
> 1 file changed, 2 insertions(+)
Applied to for-next
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-14 19:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 0:44 [PATCH] RDMA/uverbs: Make the event_queue fds return POLLERR when disassociated Jason Gunthorpe
2020-04-07 5:16 ` Leon Romanovsky
2020-04-07 11:51 ` Jason Gunthorpe
2020-04-07 12:20 ` Leon Romanovsky
2020-04-14 19:00 ` Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.