Skip to content

Commit a11e1d4

Browse files
committed
Revert changes to convert to ->poll_mask() and aio IOCB_CMD_POLL
The poll() changes were not well thought out, and completely unexplained. They also caused a huge performance regression, because "->poll()" was no longer a trivial file operation that just called down to the underlying file operations, but instead did at least two indirect calls. Indirect calls are sadly slow now with the Spectre mitigation, but the performance problem could at least be largely mitigated by changing the "->get_poll_head()" operation to just have a per-file-descriptor pointer to the poll head instead. That gets rid of one of the new indirections. But that doesn't fix the new complexity that is completely unwarranted for the regular case. The (undocumented) reason for the poll() changes was some alleged AIO poll race fixing, but we don't make the common case slower and more complex for some uncommon special case, so this all really needs way more explanations and most likely a fundamental redesign. [ This revert is a revert of about 30 different commits, not reverted individually because that would just be unnecessarily messy - Linus ] Cc: Al Viro <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f574943 commit a11e1d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+301
-450
lines changed

Documentation/filesystems/Locking

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,6 @@ prototypes:
441441
int (*iterate) (struct file *, struct dir_context *);
442442
int (*iterate_shared) (struct file *, struct dir_context *);
443443
__poll_t (*poll) (struct file *, struct poll_table_struct *);
444-
struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
445-
__poll_t (*poll_mask) (struct file *, __poll_t);
446444
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
447445
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
448446
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -473,7 +471,7 @@ prototypes:
473471
};
474472

475473
locking rules:
476-
All except for ->poll_mask may block.
474+
All may block.
477475

478476
->llseek() locking has moved from llseek to the individual llseek
479477
implementations. If your fs is not using generic_file_llseek, you
@@ -505,9 +503,6 @@ in sys_read() and friends.
505503
the lease within the individual filesystem to record the result of the
506504
operation
507505

508-
->poll_mask can be called with or without the waitqueue lock for the waitqueue
509-
returned from ->get_poll_head.
510-
511506
--------------------------- dquot_operations -------------------------------
512507
prototypes:
513508
int (*write_dquot) (struct dquot *);

Documentation/filesystems/vfs.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,6 @@ struct file_operations {
857857
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
858858
int (*iterate) (struct file *, struct dir_context *);
859859
__poll_t (*poll) (struct file *, struct poll_table_struct *);
860-
struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
861-
__poll_t (*poll_mask) (struct file *, __poll_t);
862860
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
863861
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
864862
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -903,17 +901,6 @@ otherwise noted.
903901
activity on this file and (optionally) go to sleep until there
904902
is activity. Called by the select(2) and poll(2) system calls
905903

906-
get_poll_head: Returns the struct wait_queue_head that callers can
907-
wait on. Callers need to check the returned events using ->poll_mask
908-
once woken. Can return NULL to indicate polling is not supported,
909-
or any error code using the ERR_PTR convention to indicate that a
910-
grave error occured and ->poll_mask shall not be called.
911-
912-
poll_mask: return the mask of EPOLL* values describing the file descriptor
913-
state. Called either before going to sleep on the waitqueue returned by
914-
get_poll_head, or after it has been woken. If ->get_poll_head and
915-
->poll_mask are implemented ->poll does not need to be implement.
916-
917904
unlocked_ioctl: called by the ioctl(2) system call.
918905

919906
compat_ioctl: called by the ioctl(2) system call when 32 bit system calls

crypto/af_alg.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,12 +1060,19 @@ void af_alg_async_cb(struct crypto_async_request *_req, int err)
10601060
}
10611061
EXPORT_SYMBOL_GPL(af_alg_async_cb);
10621062

1063-
__poll_t af_alg_poll_mask(struct socket *sock, __poll_t events)
1063+
/**
1064+
* af_alg_poll - poll system call handler
1065+
*/
1066+
__poll_t af_alg_poll(struct file *file, struct socket *sock,
1067+
poll_table *wait)
10641068
{
10651069
struct sock *sk = sock->sk;
10661070
struct alg_sock *ask = alg_sk(sk);
10671071
struct af_alg_ctx *ctx = ask->private;
1068-
__poll_t mask = 0;
1072+
__poll_t mask;
1073+
1074+
sock_poll_wait(file, sk_sleep(sk), wait);
1075+
mask = 0;
10691076

10701077
if (!ctx->more || ctx->used)
10711078
mask |= EPOLLIN | EPOLLRDNORM;
@@ -1075,7 +1082,7 @@ __poll_t af_alg_poll_mask(struct socket *sock, __poll_t events)
10751082

10761083
return mask;
10771084
}
1078-
EXPORT_SYMBOL_GPL(af_alg_poll_mask);
1085+
EXPORT_SYMBOL_GPL(af_alg_poll);
10791086

10801087
/**
10811088
* af_alg_alloc_areq - allocate struct af_alg_async_req

crypto/algif_aead.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static struct proto_ops algif_aead_ops = {
375375
.sendmsg = aead_sendmsg,
376376
.sendpage = af_alg_sendpage,
377377
.recvmsg = aead_recvmsg,
378-
.poll_mask = af_alg_poll_mask,
378+
.poll = af_alg_poll,
379379
};
380380

381381
static int aead_check_key(struct socket *sock)
@@ -471,7 +471,7 @@ static struct proto_ops algif_aead_ops_nokey = {
471471
.sendmsg = aead_sendmsg_nokey,
472472
.sendpage = aead_sendpage_nokey,
473473
.recvmsg = aead_recvmsg_nokey,
474-
.poll_mask = af_alg_poll_mask,
474+
.poll = af_alg_poll,
475475
};
476476

477477
static void *aead_bind(const char *name, u32 type, u32 mask)

crypto/algif_skcipher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static struct proto_ops algif_skcipher_ops = {
206206
.sendmsg = skcipher_sendmsg,
207207
.sendpage = af_alg_sendpage,
208208
.recvmsg = skcipher_recvmsg,
209-
.poll_mask = af_alg_poll_mask,
209+
.poll = af_alg_poll,
210210
};
211211

212212
static int skcipher_check_key(struct socket *sock)
@@ -302,7 +302,7 @@ static struct proto_ops algif_skcipher_ops_nokey = {
302302
.sendmsg = skcipher_sendmsg_nokey,
303303
.sendpage = skcipher_sendpage_nokey,
304304
.recvmsg = skcipher_recvmsg_nokey,
305-
.poll_mask = af_alg_poll_mask,
305+
.poll = af_alg_poll,
306306
};
307307

308308
static void *skcipher_bind(const char *name, u32 type, u32 mask)

drivers/char/random.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ static struct poolinfo {
402402
/*
403403
* Static global variables
404404
*/
405-
static DECLARE_WAIT_QUEUE_HEAD(random_wait);
405+
static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
406+
static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
406407
static struct fasync_struct *fasync;
407408

408409
static DEFINE_SPINLOCK(random_ready_list_lock);
@@ -721,8 +722,8 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
721722

722723
/* should we wake readers? */
723724
if (entropy_bits >= random_read_wakeup_bits &&
724-
wq_has_sleeper(&random_wait)) {
725-
wake_up_interruptible_poll(&random_wait, POLLIN);
725+
wq_has_sleeper(&random_read_wait)) {
726+
wake_up_interruptible(&random_read_wait);
726727
kill_fasync(&fasync, SIGIO, POLL_IN);
727728
}
728729
/* If the input pool is getting full, send some
@@ -1396,7 +1397,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
13961397
trace_debit_entropy(r->name, 8 * ibytes);
13971398
if (ibytes &&
13981399
(r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) {
1399-
wake_up_interruptible_poll(&random_wait, POLLOUT);
1400+
wake_up_interruptible(&random_write_wait);
14001401
kill_fasync(&fasync, SIGIO, POLL_OUT);
14011402
}
14021403

@@ -1838,7 +1839,7 @@ _random_read(int nonblock, char __user *buf, size_t nbytes)
18381839
if (nonblock)
18391840
return -EAGAIN;
18401841

1841-
wait_event_interruptible(random_wait,
1842+
wait_event_interruptible(random_read_wait,
18421843
ENTROPY_BITS(&input_pool) >=
18431844
random_read_wakeup_bits);
18441845
if (signal_pending(current))
@@ -1875,17 +1876,14 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
18751876
return ret;
18761877
}
18771878

1878-
static struct wait_queue_head *
1879-
random_get_poll_head(struct file *file, __poll_t events)
1880-
{
1881-
return &random_wait;
1882-
}
1883-
18841879
static __poll_t
1885-
random_poll_mask(struct file *file, __poll_t events)
1880+
random_poll(struct file *file, poll_table * wait)
18861881
{
1887-
__poll_t mask = 0;
1882+
__poll_t mask;
18881883

1884+
poll_wait(file, &random_read_wait, wait);
1885+
poll_wait(file, &random_write_wait, wait);
1886+
mask = 0;
18891887
if (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits)
18901888
mask |= EPOLLIN | EPOLLRDNORM;
18911889
if (ENTROPY_BITS(&input_pool) < random_write_wakeup_bits)
@@ -1992,8 +1990,7 @@ static int random_fasync(int fd, struct file *filp, int on)
19921990
const struct file_operations random_fops = {
19931991
.read = random_read,
19941992
.write = random_write,
1995-
.get_poll_head = random_get_poll_head,
1996-
.poll_mask = random_poll_mask,
1993+
.poll = random_poll,
19971994
.unlocked_ioctl = random_ioctl,
19981995
.fasync = random_fasync,
19991996
.llseek = noop_llseek,
@@ -2326,7 +2323,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
23262323
* We'll be woken up again once below random_write_wakeup_thresh,
23272324
* or when the calling thread is about to terminate.
23282325
*/
2329-
wait_event_interruptible(random_wait, kthread_should_stop() ||
2326+
wait_event_interruptible(random_write_wait, kthread_should_stop() ||
23302327
ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits);
23312328
mix_pool_bytes(poolp, buffer, count);
23322329
credit_entropy_bits(poolp, entropy);

drivers/isdn/mISDN/socket.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static const struct proto_ops data_sock_ops = {
588588
.getname = data_sock_getname,
589589
.sendmsg = mISDN_sock_sendmsg,
590590
.recvmsg = mISDN_sock_recvmsg,
591-
.poll_mask = datagram_poll_mask,
591+
.poll = datagram_poll,
592592
.listen = sock_no_listen,
593593
.shutdown = sock_no_shutdown,
594594
.setsockopt = data_sock_setsockopt,

drivers/net/ppp/pppoe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ static const struct proto_ops pppoe_ops = {
11071107
.socketpair = sock_no_socketpair,
11081108
.accept = sock_no_accept,
11091109
.getname = pppoe_getname,
1110-
.poll_mask = datagram_poll_mask,
1110+
.poll = datagram_poll,
11111111
.listen = sock_no_listen,
11121112
.shutdown = sock_no_shutdown,
11131113
.setsockopt = sock_no_setsockopt,

0 commit comments

Comments
 (0)