io_uring: improve same wq polling
[linux-2.6-microblaze.git] / fs / io_uring.c
index 6f2668b..71d5484 100644 (file)
@@ -5062,8 +5062,13 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt,
        if (unlikely(pt->nr_entries)) {
                struct io_poll_iocb *poll_one = poll;
 
+               /* double add on the same waitqueue head, ignore */
+               if (poll_one->head == head)
+                       return;
                /* already have a 2nd entry, fail a third attempt */
                if (*poll_ptr) {
+                       if ((*poll_ptr)->head == head)
+                               return;
                        pt->error = -EINVAL;
                        return;
                }
@@ -5073,9 +5078,6 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt,
                 */
                if (!(poll_one->events & EPOLLONESHOT))
                        poll_one->events |= EPOLLONESHOT;
-               /* double add on the same waitqueue head, ignore */
-               if (poll_one->head == head)
-                       return;
                poll = kmalloc(sizeof(*poll), GFP_ATOMIC);
                if (!poll) {
                        pt->error = -ENOMEM;