Skip to content

Commit ee5daa1

Browse files
committed
Merge branch 'work.poll2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more poll annotation updates from Al Viro: "This is preparation to solving the problems you've mentioned in the original poll series. After this series, the kernel is ready for running for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'` for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done done as a for bulk search-and-replace. After that, the kernel is ready to apply the patch to unify {de,}mangle_poll(), and then get rid of kernel-side POLL... uses entirely, and we should be all done with that stuff. Basically, that's what you suggested wrt KPOLL..., except that we can use EPOLL... instead - they already are arch-independent (and equal to what is currently kernel-side POLL...). After the preparations (in this series) switch to returning EPOLL... from ->poll() instances is completely mechanical and kernel-side POLL... can go away. The last step (killing kernel-side POLL... and unifying {de,}mangle_poll() has to be done after the search-and-replace job, since we need userland-side POLL... for unified {de,}mangle_poll(), thus the cherry-pick at the last step. After that we will have: - POLL{IN,OUT,...} *not* in __poll_t, so any stray instances of ->poll() still using those will be caught by sparse. - eventpoll.c and select.c warning-free wrt __poll_t - no more kernel-side definitions of POLL... - userland ones are visible through the entire kernel (and used pretty much only for mangle/demangle) - same behavior as after the first series (i.e. sparc et.al. epoll(2) working correctly)" * 'work.poll2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: annotate ep_scan_ready_list() ep_send_events_proc(): return result via esed->res preparation to switching ->poll() to returning EPOLL... add EPOLLNVAL, annotate EPOLL... and event_poll->event use linux/poll.h instead of asm/poll.h xen: fix poll misannotation smc: missing poll annotations
2 parents 3fc928d + d85e2aa commit ee5daa1

File tree

8 files changed

+47
-40
lines changed

8 files changed

+47
-40
lines changed

drivers/xen/pvcalls-front.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int pvcalls_front_recvmsg(struct socket *sock,
2020
struct msghdr *msg,
2121
size_t len,
2222
int flags);
23-
unsigned int pvcalls_front_poll(struct file *file,
23+
__poll_t pvcalls_front_poll(struct file *file,
2424
struct socket *sock,
2525
poll_table *wait);
2626
int pvcalls_front_release(struct socket *sock);

fs/coda/psdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <linux/device.h>
4040
#include <linux/pid_namespace.h>
4141
#include <asm/io.h>
42-
#include <asm/poll.h>
42+
#include <linux/poll.h>
4343
#include <linux/uaccess.h>
4444

4545
#include <linux/coda.h>

fs/debugfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <linux/slab.h>
1919
#include <linux/atomic.h>
2020
#include <linux/device.h>
21-
#include <asm/poll.h>
21+
#include <linux/poll.h>
2222

2323
#include "internal.h"
2424

fs/eventpoll.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ struct ep_pqueue {
260260
struct ep_send_events_data {
261261
int maxevents;
262262
struct epoll_event __user *events;
263+
int res;
263264
};
264265

265266
/*
@@ -660,12 +661,13 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi)
660661
*
661662
* Returns: The same integer error code returned by the @sproc callback.
662663
*/
663-
static int ep_scan_ready_list(struct eventpoll *ep,
664-
int (*sproc)(struct eventpoll *,
664+
static __poll_t ep_scan_ready_list(struct eventpoll *ep,
665+
__poll_t (*sproc)(struct eventpoll *,
665666
struct list_head *, void *),
666667
void *priv, int depth, bool ep_locked)
667668
{
668-
int error, pwake = 0;
669+
__poll_t res;
670+
int pwake = 0;
669671
unsigned long flags;
670672
struct epitem *epi, *nepi;
671673
LIST_HEAD(txlist);
@@ -694,7 +696,7 @@ static int ep_scan_ready_list(struct eventpoll *ep,
694696
/*
695697
* Now call the callback function.
696698
*/
697-
error = (*sproc)(ep, &txlist, priv);
699+
res = (*sproc)(ep, &txlist, priv);
698700

699701
spin_lock_irqsave(&ep->lock, flags);
700702
/*
@@ -747,7 +749,7 @@ static int ep_scan_ready_list(struct eventpoll *ep,
747749
if (pwake)
748750
ep_poll_safewake(&ep->poll_wait);
749751

750-
return error;
752+
return res;
751753
}
752754

753755
static void epi_rcu_free(struct rcu_head *head)
@@ -864,7 +866,7 @@ static int ep_eventpoll_release(struct inode *inode, struct file *file)
864866
return 0;
865867
}
866868

867-
static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
869+
static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
868870
void *priv);
869871
static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
870872
poll_table *pt);
@@ -874,7 +876,7 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
874876
* the ep->mtx so we need to start from depth=1, such that mutex_lock_nested()
875877
* is correctly annotated.
876878
*/
877-
static unsigned int ep_item_poll(const struct epitem *epi, poll_table *pt,
879+
static __poll_t ep_item_poll(const struct epitem *epi, poll_table *pt,
878880
int depth)
879881
{
880882
struct eventpoll *ep;
@@ -894,7 +896,7 @@ static unsigned int ep_item_poll(const struct epitem *epi, poll_table *pt,
894896
locked) & epi->event.events;
895897
}
896898

897-
static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
899+
static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
898900
void *priv)
899901
{
900902
struct epitem *epi, *tmp;
@@ -1414,7 +1416,8 @@ static noinline void ep_destroy_wakeup_source(struct epitem *epi)
14141416
static int ep_insert(struct eventpoll *ep, const struct epoll_event *event,
14151417
struct file *tfile, int fd, int full_check)
14161418
{
1417-
int error, revents, pwake = 0;
1419+
int error, pwake = 0;
1420+
__poll_t revents;
14181421
unsigned long flags;
14191422
long user_watches;
14201423
struct epitem *epi;
@@ -1612,12 +1615,11 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi,
16121615
return 0;
16131616
}
16141617

1615-
static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
1618+
static __poll_t ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
16161619
void *priv)
16171620
{
16181621
struct ep_send_events_data *esed = priv;
1619-
int eventcnt;
1620-
unsigned int revents;
1622+
__poll_t revents;
16211623
struct epitem *epi;
16221624
struct epoll_event __user *uevent;
16231625
struct wakeup_source *ws;
@@ -1630,8 +1632,8 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
16301632
* Items cannot vanish during the loop because ep_scan_ready_list() is
16311633
* holding "mtx" during this call.
16321634
*/
1633-
for (eventcnt = 0, uevent = esed->events;
1634-
!list_empty(head) && eventcnt < esed->maxevents;) {
1635+
for (esed->res = 0, uevent = esed->events;
1636+
!list_empty(head) && esed->res < esed->maxevents;) {
16351637
epi = list_first_entry(head, struct epitem, rdllink);
16361638

16371639
/*
@@ -1665,9 +1667,11 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
16651667
__put_user(epi->event.data, &uevent->data)) {
16661668
list_add(&epi->rdllink, head);
16671669
ep_pm_stay_awake(epi);
1668-
return eventcnt ? eventcnt : -EFAULT;
1670+
if (!esed->res)
1671+
esed->res = -EFAULT;
1672+
return 0;
16691673
}
1670-
eventcnt++;
1674+
esed->res++;
16711675
uevent++;
16721676
if (epi->event.events & EPOLLONESHOT)
16731677
epi->event.events &= EP_PRIVATE_BITS;
@@ -1689,7 +1693,7 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
16891693
}
16901694
}
16911695

1692-
return eventcnt;
1696+
return 0;
16931697
}
16941698

16951699
static int ep_send_events(struct eventpoll *ep,
@@ -1700,7 +1704,8 @@ static int ep_send_events(struct eventpoll *ep,
17001704
esed.maxevents = maxevents;
17011705
esed.events = events;
17021706

1703-
return ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false);
1707+
ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false);
1708+
return esed.res;
17041709
}
17051710

17061711
static inline struct timespec64 ep_set_mstimeout(long ms)

fs/fcntl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <linux/shmem_fs.h>
2727
#include <linux/compat.h>
2828

29-
#include <asm/poll.h>
29+
#include <linux/poll.h>
3030
#include <asm/siginfo.h>
3131
#include <linux/uaccess.h>
3232

include/linux/poll.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/sysctl.h>
1212
#include <linux/uaccess.h>
1313
#include <uapi/linux/poll.h>
14+
#include <uapi/linux/eventpoll.h>
1415

1516
extern struct ctl_table epoll_table[]; /* for sysctl */
1617
/* ~832 bytes of stack space used max in sys_select/sys_poll before allocating
@@ -22,7 +23,7 @@ extern struct ctl_table epoll_table[]; /* for sysctl */
2223
#define WQUEUES_STACK_ALLOC (MAX_STACK_ALLOC - FRONTEND_STACK_ALLOC)
2324
#define N_INLINE_POLL_ENTRIES (WQUEUES_STACK_ALLOC / sizeof(struct poll_table_entry))
2425

25-
#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
26+
#define DEFAULT_POLLMASK (EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM)
2627

2728
struct poll_table_struct;
2829

include/uapi/linux/eventpoll.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@
2828
#define EPOLL_CTL_MOD 3
2929

3030
/* Epoll event masks */
31-
#define EPOLLIN 0x00000001
32-
#define EPOLLPRI 0x00000002
33-
#define EPOLLOUT 0x00000004
34-
#define EPOLLERR 0x00000008
35-
#define EPOLLHUP 0x00000010
36-
#define EPOLLRDNORM 0x00000040
37-
#define EPOLLRDBAND 0x00000080
38-
#define EPOLLWRNORM 0x00000100
39-
#define EPOLLWRBAND 0x00000200
40-
#define EPOLLMSG 0x00000400
41-
#define EPOLLRDHUP 0x00002000
31+
#define EPOLLIN (__force __poll_t)0x00000001
32+
#define EPOLLPRI (__force __poll_t)0x00000002
33+
#define EPOLLOUT (__force __poll_t)0x00000004
34+
#define EPOLLERR (__force __poll_t)0x00000008
35+
#define EPOLLHUP (__force __poll_t)0x00000010
36+
#define EPOLLNVAL (__force __poll_t)0x00000020
37+
#define EPOLLRDNORM (__force __poll_t)0x00000040
38+
#define EPOLLRDBAND (__force __poll_t)0x00000080
39+
#define EPOLLWRNORM (__force __poll_t)0x00000100
40+
#define EPOLLWRBAND (__force __poll_t)0x00000200
41+
#define EPOLLMSG (__force __poll_t)0x00000400
42+
#define EPOLLRDHUP (__force __poll_t)0x00002000
4243

4344
/* Set exclusive wakeup mode for the target file descriptor */
44-
#define EPOLLEXCLUSIVE (1U << 28)
45+
#define EPOLLEXCLUSIVE (__force __poll_t)(1U << 28)
4546

4647
/*
4748
* Request the handling of system wakeup events so as to prevent system suspends
@@ -53,13 +54,13 @@
5354
*
5455
* Requires CAP_BLOCK_SUSPEND
5556
*/
56-
#define EPOLLWAKEUP (1U << 29)
57+
#define EPOLLWAKEUP (__force __poll_t)(1U << 29)
5758

5859
/* Set the One Shot behaviour for the target file descriptor */
59-
#define EPOLLONESHOT (1U << 30)
60+
#define EPOLLONESHOT (__force __poll_t)(1U << 30)
6061

6162
/* Set the Edge Triggered behaviour for the target file descriptor */
62-
#define EPOLLET (1U << 31)
63+
#define EPOLLET (__force __poll_t)(1U << 31)
6364

6465
/*
6566
* On x86-64 make the 64bit structure have the same alignment as the
@@ -74,7 +75,7 @@
7475
#endif
7576

7677
struct epoll_event {
77-
__u32 events;
78+
__poll_t events;
7879
__u64 data;
7980
} EPOLL_PACKED;
8081

net/smc/af_smc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ static int smc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
11411141
static __poll_t smc_accept_poll(struct sock *parent)
11421142
{
11431143
struct smc_sock *isk = smc_sk(parent);
1144-
int mask = 0;
1144+
__poll_t mask = 0;
11451145

11461146
spin_lock(&isk->accept_q_lock);
11471147
if (!list_empty(&isk->accept_q))

0 commit comments

Comments
 (0)