diff mbox series

[2/7] poll: Add a poll_flags for poll_queue_proc()

Message ID 20230905214235.320571-3-peterx@redhat.com (mailing list archive)
State New, archived
Headers show
Series mm/userfaultfd/poll: Scale userfaultfd wakeups | expand

Commit Message

Peter Xu Sept. 5, 2023, 9:42 p.m. UTC
Allows the poll enqueue function to pass over a flag into it.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 drivers/vfio/virqfd.c     | 4 ++--
 drivers/vhost/vhost.c     | 2 +-
 drivers/virt/acrn/irqfd.c | 2 +-
 fs/aio.c                  | 2 +-
 fs/eventpoll.c            | 2 +-
 fs/select.c               | 4 ++--
 include/linux/poll.h      | 7 +++++--
 io_uring/poll.c           | 4 ++--
 mm/memcontrol.c           | 4 +++-
 net/9p/trans_fd.c         | 3 ++-
 virt/kvm/eventfd.c        | 2 +-
 11 files changed, 21 insertions(+), 15 deletions(-)

Comments

kernel test robot Sept. 5, 2023, 11:21 p.m. UTC | #1
Hi Peter,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Peter-Xu/mm-userfaultfd-Make-uffd-read-wait-event-exclusive/20230906-054430
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20230905214235.320571-3-peterx%40redhat.com
patch subject: [PATCH 2/7] poll: Add a poll_flags for poll_queue_proc()
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230906/202309060752.FQUjUmGA-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230906/202309060752.FQUjUmGA-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309060752.FQUjUmGA-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/9p/trans_fd.c:555: warning: Function parameter or member 'flags' not described in 'p9_pollwait'


vim +555 net/9p/trans_fd.c

8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  542  
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  543  /**
5503ac565998837 Eric Van Hensbergen 2008-10-13  544   * p9_pollwait - add poll task to the wait queue
5503ac565998837 Eric Van Hensbergen 2008-10-13  545   * @filp: file pointer being polled
5503ac565998837 Eric Van Hensbergen 2008-10-13  546   * @wait_address: wait_q to block on
5503ac565998837 Eric Van Hensbergen 2008-10-13  547   * @p: poll state
ee443996a35c1e0 Eric Van Hensbergen 2008-03-05  548   *
5503ac565998837 Eric Van Hensbergen 2008-10-13  549   * called by files poll operation to add v9fs-poll task to files wait queue
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  550   */
ee443996a35c1e0 Eric Van Hensbergen 2008-03-05  551  
5503ac565998837 Eric Van Hensbergen 2008-10-13  552  static void
14649d7d7806aba Peter Xu            2023-09-05  553  p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p,
14649d7d7806aba Peter Xu            2023-09-05  554  	    poll_flags flags)
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06 @555  {
5503ac565998837 Eric Van Hensbergen 2008-10-13  556  	struct p9_conn *m = container_of(p, struct p9_conn, pt);
5503ac565998837 Eric Van Hensbergen 2008-10-13  557  	struct p9_poll_wait *pwait = NULL;
5503ac565998837 Eric Van Hensbergen 2008-10-13  558  	int i;
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  559  
5503ac565998837 Eric Van Hensbergen 2008-10-13  560  	for (i = 0; i < ARRAY_SIZE(m->poll_wait); i++) {
5503ac565998837 Eric Van Hensbergen 2008-10-13  561  		if (m->poll_wait[i].wait_addr == NULL) {
5503ac565998837 Eric Van Hensbergen 2008-10-13  562  			pwait = &m->poll_wait[i];
5503ac565998837 Eric Van Hensbergen 2008-10-13  563  			break;
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  564  		}
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  565  	}
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  566  
5503ac565998837 Eric Van Hensbergen 2008-10-13  567  	if (!pwait) {
5d3851530d6d685 Joe Perches         2011-11-28  568  		p9_debug(P9_DEBUG_ERROR, "not enough wait_address slots\n");
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  569  		return;
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  570  	}
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  571  
5503ac565998837 Eric Van Hensbergen 2008-10-13  572  	pwait->conn = m;
5503ac565998837 Eric Van Hensbergen 2008-10-13  573  	pwait->wait_addr = wait_address;
5503ac565998837 Eric Van Hensbergen 2008-10-13  574  	init_waitqueue_func_entry(&pwait->wait, p9_pollwake);
5503ac565998837 Eric Van Hensbergen 2008-10-13  575  	add_wait_queue(wait_address, &pwait->wait);
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  576  }
8a0dc95fd976a05 Eric Van Hensbergen 2008-02-06  577
kernel test robot Sept. 6, 2023, 5:31 p.m. UTC | #2
Hi Peter,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Peter-Xu/mm-userfaultfd-Make-uffd-read-wait-event-exclusive/20230906-054430
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20230905214235.320571-3-peterx%40redhat.com
patch subject: [PATCH 2/7] poll: Add a poll_flags for poll_queue_proc()
config: x86_64-buildonly-randconfig-005-20230906 (https://download.01.org/0day-ci/archive/20230907/202309070146.47KrWvAH-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230907/202309070146.47KrWvAH-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309070146.47KrWvAH-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/xen/privcmd.c: In function 'privcmd_irqfd_assign':
>> drivers/xen/privcmd.c:965:40: error: passing argument 2 of 'init_poll_funcptr' from incompatible pointer type [-Werror=incompatible-pointer-types]
     965 |         init_poll_funcptr(&kirqfd->pt, irqfd_poll_func);
         |                                        ^~~~~~~~~~~~~~~
         |                                        |
         |                                        void (*)(struct file *, wait_queue_head_t *, poll_table *) {aka void (*)(struct file *, struct wait_queue_head *, struct poll_table_struct *)}
   In file included from drivers/xen/privcmd.c:17:
   include/linux/poll.h:76:70: note: expected 'poll_queue_proc' {aka 'void (*)(struct file *, struct wait_queue_head *, struct poll_table_struct *, unsigned int)'} but argument is of type 'void (*)(struct file *, wait_queue_head_t *, poll_table *)' {aka 'void (*)(struct file *, struct wait_queue_head *, struct poll_table_struct *)'}
      76 | static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
         |                                                      ~~~~~~~~~~~~~~~~^~~~~
   cc1: some warnings being treated as errors


vim +/init_poll_funcptr +965 drivers/xen/privcmd.c

f8941e6c4c7129 Viresh Kumar 2023-08-22   924  
f8941e6c4c7129 Viresh Kumar 2023-08-22   925  static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd)
f8941e6c4c7129 Viresh Kumar 2023-08-22   926  {
f8941e6c4c7129 Viresh Kumar 2023-08-22   927  	struct privcmd_kernel_irqfd *kirqfd, *tmp;
f8941e6c4c7129 Viresh Kumar 2023-08-22   928  	__poll_t events;
f8941e6c4c7129 Viresh Kumar 2023-08-22   929  	struct fd f;
f8941e6c4c7129 Viresh Kumar 2023-08-22   930  	void *dm_op;
f8941e6c4c7129 Viresh Kumar 2023-08-22   931  	int ret;
f8941e6c4c7129 Viresh Kumar 2023-08-22   932  
f8941e6c4c7129 Viresh Kumar 2023-08-22   933  	kirqfd = kzalloc(sizeof(*kirqfd) + irqfd->size, GFP_KERNEL);
f8941e6c4c7129 Viresh Kumar 2023-08-22   934  	if (!kirqfd)
f8941e6c4c7129 Viresh Kumar 2023-08-22   935  		return -ENOMEM;
f8941e6c4c7129 Viresh Kumar 2023-08-22   936  	dm_op = kirqfd + 1;
f8941e6c4c7129 Viresh Kumar 2023-08-22   937  
f8941e6c4c7129 Viresh Kumar 2023-08-22   938  	if (copy_from_user(dm_op, irqfd->dm_op, irqfd->size)) {
f8941e6c4c7129 Viresh Kumar 2023-08-22   939  		ret = -EFAULT;
f8941e6c4c7129 Viresh Kumar 2023-08-22   940  		goto error_kfree;
f8941e6c4c7129 Viresh Kumar 2023-08-22   941  	}
f8941e6c4c7129 Viresh Kumar 2023-08-22   942  
f8941e6c4c7129 Viresh Kumar 2023-08-22   943  	kirqfd->xbufs.size = irqfd->size;
f8941e6c4c7129 Viresh Kumar 2023-08-22   944  	set_xen_guest_handle(kirqfd->xbufs.h, dm_op);
f8941e6c4c7129 Viresh Kumar 2023-08-22   945  	kirqfd->dom = irqfd->dom;
f8941e6c4c7129 Viresh Kumar 2023-08-22   946  	INIT_WORK(&kirqfd->shutdown, irqfd_shutdown);
f8941e6c4c7129 Viresh Kumar 2023-08-22   947  
f8941e6c4c7129 Viresh Kumar 2023-08-22   948  	f = fdget(irqfd->fd);
f8941e6c4c7129 Viresh Kumar 2023-08-22   949  	if (!f.file) {
f8941e6c4c7129 Viresh Kumar 2023-08-22   950  		ret = -EBADF;
f8941e6c4c7129 Viresh Kumar 2023-08-22   951  		goto error_kfree;
f8941e6c4c7129 Viresh Kumar 2023-08-22   952  	}
f8941e6c4c7129 Viresh Kumar 2023-08-22   953  
f8941e6c4c7129 Viresh Kumar 2023-08-22   954  	kirqfd->eventfd = eventfd_ctx_fileget(f.file);
f8941e6c4c7129 Viresh Kumar 2023-08-22   955  	if (IS_ERR(kirqfd->eventfd)) {
f8941e6c4c7129 Viresh Kumar 2023-08-22   956  		ret = PTR_ERR(kirqfd->eventfd);
f8941e6c4c7129 Viresh Kumar 2023-08-22   957  		goto error_fd_put;
f8941e6c4c7129 Viresh Kumar 2023-08-22   958  	}
f8941e6c4c7129 Viresh Kumar 2023-08-22   959  
f8941e6c4c7129 Viresh Kumar 2023-08-22   960  	/*
f8941e6c4c7129 Viresh Kumar 2023-08-22   961  	 * Install our own custom wake-up handling so we are notified via a
f8941e6c4c7129 Viresh Kumar 2023-08-22   962  	 * callback whenever someone signals the underlying eventfd.
f8941e6c4c7129 Viresh Kumar 2023-08-22   963  	 */
f8941e6c4c7129 Viresh Kumar 2023-08-22   964  	init_waitqueue_func_entry(&kirqfd->wait, irqfd_wakeup);
f8941e6c4c7129 Viresh Kumar 2023-08-22  @965  	init_poll_funcptr(&kirqfd->pt, irqfd_poll_func);
f8941e6c4c7129 Viresh Kumar 2023-08-22   966  
f8941e6c4c7129 Viresh Kumar 2023-08-22   967  	mutex_lock(&irqfds_lock);
f8941e6c4c7129 Viresh Kumar 2023-08-22   968  
f8941e6c4c7129 Viresh Kumar 2023-08-22   969  	list_for_each_entry(tmp, &irqfds_list, list) {
f8941e6c4c7129 Viresh Kumar 2023-08-22   970  		if (kirqfd->eventfd == tmp->eventfd) {
f8941e6c4c7129 Viresh Kumar 2023-08-22   971  			ret = -EBUSY;
f8941e6c4c7129 Viresh Kumar 2023-08-22   972  			mutex_unlock(&irqfds_lock);
f8941e6c4c7129 Viresh Kumar 2023-08-22   973  			goto error_eventfd;
f8941e6c4c7129 Viresh Kumar 2023-08-22   974  		}
f8941e6c4c7129 Viresh Kumar 2023-08-22   975  	}
f8941e6c4c7129 Viresh Kumar 2023-08-22   976  
f8941e6c4c7129 Viresh Kumar 2023-08-22   977  	list_add_tail(&kirqfd->list, &irqfds_list);
f8941e6c4c7129 Viresh Kumar 2023-08-22   978  	mutex_unlock(&irqfds_lock);
f8941e6c4c7129 Viresh Kumar 2023-08-22   979  
f8941e6c4c7129 Viresh Kumar 2023-08-22   980  	/*
f8941e6c4c7129 Viresh Kumar 2023-08-22   981  	 * Check if there was an event already pending on the eventfd before we
f8941e6c4c7129 Viresh Kumar 2023-08-22   982  	 * registered, and trigger it as if we didn't miss it.
f8941e6c4c7129 Viresh Kumar 2023-08-22   983  	 */
f8941e6c4c7129 Viresh Kumar 2023-08-22   984  	events = vfs_poll(f.file, &kirqfd->pt);
f8941e6c4c7129 Viresh Kumar 2023-08-22   985  	if (events & EPOLLIN)
f8941e6c4c7129 Viresh Kumar 2023-08-22   986  		irqfd_inject(kirqfd);
f8941e6c4c7129 Viresh Kumar 2023-08-22   987  
f8941e6c4c7129 Viresh Kumar 2023-08-22   988  	/*
f8941e6c4c7129 Viresh Kumar 2023-08-22   989  	 * Do not drop the file until the kirqfd is fully initialized, otherwise
f8941e6c4c7129 Viresh Kumar 2023-08-22   990  	 * we might race against the EPOLLHUP.
f8941e6c4c7129 Viresh Kumar 2023-08-22   991  	 */
f8941e6c4c7129 Viresh Kumar 2023-08-22   992  	fdput(f);
f8941e6c4c7129 Viresh Kumar 2023-08-22   993  	return 0;
f8941e6c4c7129 Viresh Kumar 2023-08-22   994  
f8941e6c4c7129 Viresh Kumar 2023-08-22   995  error_eventfd:
f8941e6c4c7129 Viresh Kumar 2023-08-22   996  	eventfd_ctx_put(kirqfd->eventfd);
f8941e6c4c7129 Viresh Kumar 2023-08-22   997  
f8941e6c4c7129 Viresh Kumar 2023-08-22   998  error_fd_put:
f8941e6c4c7129 Viresh Kumar 2023-08-22   999  	fdput(f);
f8941e6c4c7129 Viresh Kumar 2023-08-22  1000  
f8941e6c4c7129 Viresh Kumar 2023-08-22  1001  error_kfree:
f8941e6c4c7129 Viresh Kumar 2023-08-22  1002  	kfree(kirqfd);
f8941e6c4c7129 Viresh Kumar 2023-08-22  1003  	return ret;
f8941e6c4c7129 Viresh Kumar 2023-08-22  1004  }
f8941e6c4c7129 Viresh Kumar 2023-08-22  1005
kernel test robot Sept. 6, 2023, 8:53 p.m. UTC | #3
Hi Peter,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Peter-Xu/mm-userfaultfd-Make-uffd-read-wait-event-exclusive/20230906-054430
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20230905214235.320571-3-peterx%40redhat.com
patch subject: [PATCH 2/7] poll: Add a poll_flags for poll_queue_proc()
config: hexagon-randconfig-002-20230906 (https://download.01.org/0day-ci/archive/20230907/202309070440.eKzBcg8X-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230907/202309070440.eKzBcg8X-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309070440.eKzBcg8X-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/vhost/vhost.c:14:
   In file included from include/uapi/linux/vhost.h:14:
   In file included from include/uapi/linux/vhost_types.h:16:
   In file included from include/linux/virtio_config.h:7:
   In file included from include/linux/virtio.h:7:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/vhost/vhost.c:14:
   In file included from include/uapi/linux/vhost.h:14:
   In file included from include/uapi/linux/vhost_types.h:16:
   In file included from include/linux/virtio_config.h:7:
   In file included from include/linux/virtio.h:7:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/vhost/vhost.c:14:
   In file included from include/uapi/linux/vhost.h:14:
   In file included from include/uapi/linux/vhost_types.h:16:
   In file included from include/linux/virtio_config.h:7:
   In file included from include/linux/virtio.h:7:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/hexagon/include/asm/io.h:337:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> drivers/vhost/vhost.c:193:41: error: incompatible function pointer types passing 'int (wait_queue_entry_t *, unsigned int, int, void *, poll_flags)' (aka 'int (struct wait_queue_entry *, unsigned int, int, void *, unsigned int)') to parameter of type 'wait_queue_func_t' (aka 'int (*)(struct wait_queue_entry *, unsigned int, int, void *)') [-Werror,-Wincompatible-function-pointer-types]
           init_waitqueue_func_entry(&poll->wait, vhost_poll_wakeup);
                                                  ^~~~~~~~~~~~~~~~~
   include/linux/wait.h:90:80: note: passing argument to parameter 'func' here
   init_waitqueue_func_entry(struct wait_queue_entry *wq_entry, wait_queue_func_t func)
                                                                                  ^
>> drivers/vhost/vhost.c:194:34: error: incompatible function pointer types passing 'void (struct file *, wait_queue_head_t *, poll_table *)' (aka 'void (struct file *, struct wait_queue_head *, struct poll_table_struct *)') to parameter of type 'poll_queue_proc' (aka 'void (*)(struct file *, struct wait_queue_head *, struct poll_table_struct *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types]
           init_poll_funcptr(&poll->table, vhost_poll_func);
                                           ^~~~~~~~~~~~~~~
   include/linux/poll.h:76:70: note: passing argument to parameter 'qproc' here
   static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
                                                                        ^
>> drivers/vhost/vhost.c:215:57: error: too few arguments to function call, expected 5, have 4
                   vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask));
                   ~~~~~~~~~~~~~~~~~                                     ^
   drivers/vhost/vhost.c:164:12: note: 'vhost_poll_wakeup' declared here
   static int vhost_poll_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync,
              ^
   6 warnings and 3 errors generated.


vim +193 drivers/vhost/vhost.c

87d6a412bd1ed8 Michael S. Tsirkin 2010-09-02  187  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  188  /* Init poll structure */
c23f3445e68e1d Tejun Heo          2010-06-02  189  void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn,
493b94bf5ae0f6 Mike Christie      2023-06-26  190  		     __poll_t mask, struct vhost_dev *dev,
493b94bf5ae0f6 Mike Christie      2023-06-26  191  		     struct vhost_virtqueue *vq)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  192  {
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 @193  	init_waitqueue_func_entry(&poll->wait, vhost_poll_wakeup);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 @194  	init_poll_funcptr(&poll->table, vhost_poll_func);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  195  	poll->mask = mask;
c23f3445e68e1d Tejun Heo          2010-06-02  196  	poll->dev = dev;
2b8b328b61c799 Jason Wang         2013-01-28  197  	poll->wqh = NULL;
493b94bf5ae0f6 Mike Christie      2023-06-26  198  	poll->vq = vq;
c23f3445e68e1d Tejun Heo          2010-06-02  199  
87d6a412bd1ed8 Michael S. Tsirkin 2010-09-02  200  	vhost_work_init(&poll->work, fn);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  201  }
6ac1afbf6132df Asias He           2013-05-06  202  EXPORT_SYMBOL_GPL(vhost_poll_init);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  203  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  204  /* Start polling a file. We add ourselves to file's wait queue. The caller must
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  205   * keep a reference to a file until after vhost_poll_stop is called. */
2b8b328b61c799 Jason Wang         2013-01-28  206  int vhost_poll_start(struct vhost_poll *poll, struct file *file)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  207  {
e6c8adca20ba45 Al Viro            2017-07-03  208  	__poll_t mask;
d47effe1be0c4f Krishna Kumar      2011-03-01  209  
70181d51209cbc Jason Wang         2013-04-10  210  	if (poll->wqh)
70181d51209cbc Jason Wang         2013-04-10  211  		return 0;
70181d51209cbc Jason Wang         2013-04-10  212  
9965ed174e7d38 Christoph Hellwig  2018-03-05  213  	mask = vfs_poll(file, &poll->table);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  214  	if (mask)
3ad6f93e98d6df Al Viro            2017-07-03 @215  		vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask));
a9a08845e9acbd Linus Torvalds     2018-02-11  216  	if (mask & EPOLLERR) {
dc6455a71c7fc5 Jason Wang         2018-03-27  217  		vhost_poll_stop(poll);
896fc242bc1d26 Yunsheng Lin       2019-08-20  218  		return -EINVAL;
2b8b328b61c799 Jason Wang         2013-01-28  219  	}
2b8b328b61c799 Jason Wang         2013-01-28  220  
896fc242bc1d26 Yunsheng Lin       2019-08-20  221  	return 0;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  222  }
6ac1afbf6132df Asias He           2013-05-06  223  EXPORT_SYMBOL_GPL(vhost_poll_start);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  224
Peter Xu Sept. 11, 2023, 8 p.m. UTC | #4
On Tue, Sep 05, 2023 at 05:42:30PM -0400, Peter Xu wrote:
> Allows the poll enqueue function to pass over a flag into it.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>

A fixup for this patch (should fix all syzbot errors):

===8<===
From ba55ee0539a7a80b98e7a5e3942c0ee8cabe5f73 Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Tue, 5 Sep 2023 20:05:33 -0400
Subject: [PATCH] fixup! poll: Add a poll_flags for poll_queue_proc()

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 drivers/vhost/vhost.c | 4 ++--
 drivers/xen/privcmd.c | 3 ++-
 net/9p/trans_fd.c     | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 02caad721843..00813db53ff1 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -152,7 +152,7 @@ static void vhost_flush_work(struct vhost_work *work)
 }
 
 static void vhost_poll_func(struct file *file, wait_queue_head_t *wqh,
-			    poll_table *pt)
+			    poll_table *pt, poll_flags flags)
 {
 	struct vhost_poll *poll;
 
@@ -162,7 +162,7 @@ static void vhost_poll_func(struct file *file, wait_queue_head_t *wqh,
 }
 
 static int vhost_poll_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync,
-			     void *key, poll_flags flags)
+			     void *key)
 {
 	struct vhost_poll *poll = container_of(wait, struct vhost_poll, wait);
 	struct vhost_work *work = &poll->work;
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index f00ad5f5f1d4..43e65186f25d 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -914,7 +914,8 @@ irqfd_wakeup(wait_queue_entry_t *wait, unsigned int mode, int sync, void *key)
 }
 
 static void
-irqfd_poll_func(struct file *file, wait_queue_head_t *wqh, poll_table *pt)
+irqfd_poll_func(struct file *file, wait_queue_head_t *wqh, poll_table *pt,
+		poll_flags flags)
 {
 	struct privcmd_kernel_irqfd *kirqfd =
 		container_of(pt, struct privcmd_kernel_irqfd, pt);
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 91f9f474ab01..2912c4b086a2 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -545,6 +545,7 @@ static int p9_pollwake(wait_queue_entry_t *wait, unsigned int mode, int sync, vo
  * @filp: file pointer being polled
  * @wait_address: wait_q to block on
  * @p: poll state
+ * @flags: poll flags
  *
  * called by files poll operation to add v9fs-poll task to files wait queue
  */
diff mbox series

Patch

diff --git a/drivers/vfio/virqfd.c b/drivers/vfio/virqfd.c
index 29c564b7a6e1..4b817a6f4f72 100644
--- a/drivers/vfio/virqfd.c
+++ b/drivers/vfio/virqfd.c
@@ -75,8 +75,8 @@  static int virqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void
 	return 0;
 }
 
-static void virqfd_ptable_queue_proc(struct file *file,
-				     wait_queue_head_t *wqh, poll_table *pt)
+static void virqfd_ptable_queue_proc(struct file *file, wait_queue_head_t *wqh,
+				     poll_table *pt, poll_flags flags)
 {
 	struct virqfd *virqfd = container_of(pt, struct virqfd, pt);
 	add_wait_queue(wqh, &virqfd->wait);
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index c71d573f1c94..02caad721843 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -162,7 +162,7 @@  static void vhost_poll_func(struct file *file, wait_queue_head_t *wqh,
 }
 
 static int vhost_poll_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync,
-			     void *key)
+			     void *key, poll_flags flags)
 {
 	struct vhost_poll *poll = container_of(wait, struct vhost_poll, wait);
 	struct vhost_work *work = &poll->work;
diff --git a/drivers/virt/acrn/irqfd.c b/drivers/virt/acrn/irqfd.c
index d4ad211dce7a..9b79e4e76e49 100644
--- a/drivers/virt/acrn/irqfd.c
+++ b/drivers/virt/acrn/irqfd.c
@@ -94,7 +94,7 @@  static int hsm_irqfd_wakeup(wait_queue_entry_t *wait, unsigned int mode,
 }
 
 static void hsm_irqfd_poll_func(struct file *file, wait_queue_head_t *wqh,
-				poll_table *pt)
+				poll_table *pt, poll_flags flags)
 {
 	struct hsm_irqfd *irqfd;
 
diff --git a/fs/aio.c b/fs/aio.c
index a4c2a6bac72c..abb5b22f4fdf 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1823,7 +1823,7 @@  struct aio_poll_table {
 
 static void
 aio_poll_queue_proc(struct file *file, struct wait_queue_head *head,
-		struct poll_table_struct *p)
+		    struct poll_table_struct *p, poll_flags flags)
 {
 	struct aio_poll_table *pt = container_of(p, struct aio_poll_table, pt);
 
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 1d9a71a0c4c1..c74d6a083fd1 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1270,7 +1270,7 @@  static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v
  * target file wakeup lists.
  */
 static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
-				 poll_table *pt)
+				 poll_table *pt, poll_flags flags)
 {
 	struct ep_pqueue *epq = container_of(pt, struct ep_pqueue, pt);
 	struct epitem *epi = epq->epi;
diff --git a/fs/select.c b/fs/select.c
index 0ee55af1a55c..0433448481e9 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -117,7 +117,7 @@  struct poll_table_page {
  * poll table.
  */
 static void __pollwait(struct file *filp, wait_queue_head_t *wait_address,
-		       poll_table *p);
+		       poll_table *p, poll_flags flags);
 
 void poll_initwait(struct poll_wqueues *pwq)
 {
@@ -220,7 +220,7 @@  static int pollwake(wait_queue_entry_t *wait, unsigned mode, int sync, void *key
 
 /* Add a new entry */
 static void __pollwait(struct file *filp, wait_queue_head_t *wait_address,
-				poll_table *p)
+		       poll_table *p, poll_flags flags)
 {
 	struct poll_wqueues *pwq = container_of(p, struct poll_wqueues, pt);
 	struct poll_table_entry *entry = poll_get_entry(pwq);
diff --git a/include/linux/poll.h b/include/linux/poll.h
index a9e0e1c2d1f2..cbad520fc65c 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -27,12 +27,15 @@ 
 
 #define DEFAULT_POLLMASK (EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM)
 
+typedef unsigned int poll_flags;
+
 struct poll_table_struct;
 
 /* 
  * structures and helpers for f_op->poll implementations
  */
-typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
+typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *,
+				struct poll_table_struct *, poll_flags);
 
 /*
  * Do not touch the structure directly, use the access functions
@@ -46,7 +49,7 @@  typedef struct poll_table_struct {
 static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
 {
 	if (p && p->_qproc && wait_address)
-		p->_qproc(filp, wait_address, p);
+		p->_qproc(filp, wait_address, p, 0);
 }
 
 /*
diff --git a/io_uring/poll.c b/io_uring/poll.c
index 4c360ba8793a..c3b41e963a8d 100644
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -533,7 +533,7 @@  static void __io_queue_proc(struct io_poll *poll, struct io_poll_table *pt,
 }
 
 static void io_poll_queue_proc(struct file *file, struct wait_queue_head *head,
-			       struct poll_table_struct *p)
+			       struct poll_table_struct *p, poll_flags flags)
 {
 	struct io_poll_table *pt = container_of(p, struct io_poll_table, pt);
 	struct io_poll *poll = io_kiocb_to_cmd(pt->req, struct io_poll);
@@ -644,7 +644,7 @@  static int __io_arm_poll_handler(struct io_kiocb *req,
 }
 
 static void io_async_queue_proc(struct file *file, struct wait_queue_head *head,
-			       struct poll_table_struct *p)
+				struct poll_table_struct *p, poll_flags flags)
 {
 	struct io_poll_table *pt = container_of(p, struct io_poll_table, pt);
 	struct async_poll *apoll = pt->req->apoll;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ecc07b47e813..97b03ab30d5e 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4877,7 +4877,9 @@  static int memcg_event_wake(wait_queue_entry_t *wait, unsigned mode,
 }
 
 static void memcg_event_ptable_queue_proc(struct file *file,
-		wait_queue_head_t *wqh, poll_table *pt)
+					  wait_queue_head_t *wqh,
+					  poll_table *pt,
+					  poll_flags flags)
 {
 	struct mem_cgroup_event *event =
 		container_of(pt, struct mem_cgroup_event, pt);
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index c4015f30f9fa..91f9f474ab01 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -550,7 +550,8 @@  static int p9_pollwake(wait_queue_entry_t *wait, unsigned int mode, int sync, vo
  */
 
 static void
-p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
+p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p,
+	    poll_flags flags)
 {
 	struct p9_conn *m = container_of(p, struct p9_conn, pt);
 	struct p9_poll_wait *pwait = NULL;
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 89912a17f5d5..645b5d155386 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -246,7 +246,7 @@  irqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void *key)
 
 static void
 irqfd_ptable_queue_proc(struct file *file, wait_queue_head_t *wqh,
-			poll_table *pt)
+			poll_table *pt, poll_flags flags)
 {
 	struct kvm_kernel_irqfd *irqfd =
 		container_of(pt, struct kvm_kernel_irqfd, pt);