5.15-stable io_uring backport
Subsystems (39)
Jens Axboe
maintainerHi Greg,
Here's the series we discussed before the break, no changes since then. Last 3 patches are new stable backports, the rest is backporting the 5.15.85 io_uring codebase to 5.10-stable. This is done to make 5.10 maintainable wrt io_uring, and importantly, to bring back the native io workers to 5.10-stable.
Signature · 1 line
Jens Axboe
From 4029c28b8d6792778bdadc4e431be30302ff4a3b Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 23 Dec 2022 07:04:49 -0700
Subject: [PATCH 63/63] io_uring: pass in EPOLL_URING_WAKE for eventfd
signaling and wakeups
[ Upstream commit 4464853277d0ccdb9914608dd1332f0fa2f9846f ]
Pass in EPOLL_URING_WAKE when signaling eventfd or doing poll related wakups, so that we can check for a circular event dependency between eventfd and epoll. If this flag is set when our wakeup handlers are called, then we know we have a dependency that needs to terminate multishot requests.
eventfd and epoll are the only such possible dependencies.
--- io_uring/io_uring.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
io_uring/io_uring.c +20 -7
@@ -1626,13 +1626,15 @@ static void io_cqring_ev_posted(struct io_ring_ctx *ctx)* wake as many waiters as we need to. */ if (wq_has_sleeper (&ctx->cq_wait)) -wake_up_all (&ctx->cq_wait); +__wake_up (&ctx->cq_wait,TASK_NORMAL ,0 , +poll_to_key (EPOLL_URING_WAKE |EPOLLIN ));if (ctx->sq_data &&waitqueue_active (&ctx->sq_data->wait))wake_up (&ctx->sq_data->wait);if (io_should_trigger_evfd (ctx)) -eventfd_signal (ctx->cq_ev_fd,1 ); +eventfd_signal_mask (ctx->cq_ev_fd,1 ,EPOLL_URING_WAKE );if (waitqueue_active (&ctx->poll_wait)) -wake_up_interruptible (&ctx->poll_wait); +__wake_up (&ctx->poll_wait,TASK_INTERRUPTIBLE ,0 , +poll_to_key (EPOLL_URING_WAKE |EPOLLIN )); }static void io_cqring_ev_posted_iopoll (struct io_ring_ctx *ctx)
@@ -1642,12 +1644,14 @@ static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx)if (ctx->flags &IORING_SETUP_SQPOLL ) {if (waitqueue_active (&ctx->cq_wait)) -wake_up_all (&ctx->cq_wait); +__wake_up (&ctx->cq_wait,TASK_NORMAL ,0 , +poll_to_key (EPOLL_URING_WAKE |EPOLLIN )); }if (io_should_trigger_evfd (ctx)) -eventfd_signal (ctx->cq_ev_fd,1 ); +eventfd_signal_mask (ctx->cq_ev_fd,1 ,EPOLL_URING_WAKE );if (waitqueue_active (&ctx->poll_wait)) -wake_up_interruptible (&ctx->poll_wait); +__wake_up (&ctx->poll_wait,TASK_INTERRUPTIBLE ,0 , +poll_to_key (EPOLL_URING_WAKE |EPOLLIN )); }/* Returns true if there are no backlogged entries after the flush */
@@ -5477,8 +5481,17 @@ static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,if (mask && !(mask & poll->events))return 0 ; -if (io_poll_get_ownership (req)) +if (io_poll_get_ownership (req)) { +/* +* If we trigger a multishot poll off our own wakeup path, +* disable multishot as there is a circular dependency between +* CQ posting and triggering the event. +*/ +if (mask &EPOLL_URING_WAKE ) + poll->events |=EPOLLONESHOT ; +__io_poll_execute (req, mask); + }return 1 ; }
Signature · 1 line
2.39.0
From 53270319f184c35499cf2ffeac8a75078b94934a Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Sun, 20 Nov 2022 10:13:44 -0700
Subject: [PATCH 62/63] eventfd: provide a eventfd_signal_mask() helper
[ Upstream commit 03e02acda8e267a8183e1e0ed289ff1ef9cd7ed8 ]
This is identical to eventfd_signal(), but it allows the caller to pass in a mask to be used for the poll wakeup key. The use case is avoiding repeated multishot triggers if we have a dependency between eventfd and io_uring.
If we setup an eventfd context and register that as the io_uring eventfd, and at the same time queue a multishot poll request for the eventfd context, then any CQE posted will repeatedly trigger the multishot request until it terminates when the CQ ring overflows.
In preparation for io_uring detecting this circular dependency, add the mentioned helper so that io_uring can pass in EPOLL_URING as part of the poll wakeup key.
--- fs/eventfd.c | 37 +++++++++++++++++++++---------------- include/linux/eventfd.h | 7 +++++++ 2 files changed, 28 insertions(+), 16 deletions(-)
fs/eventfd.c +21 -16
@@ -45,21 +45,7 @@ struct eventfd_ctx {int id; }; -/** -* eventfd_signal - Adds @n to the eventfd counter. -* @ctx: [in] Pointer to the eventfd context. -* @n: [in] Value of the counter to be added to the eventfd internal counter. -* The value cannot be negative. -* -* This function is supposed to be called by the kernel in paths that do not -* allow sleeping. In this function we allow the counter to reach the ULLONG_MAX -* value, and we signal this as overflow condition by returning a EPOLLERR -* to poll(2). -* -* Returns the amount by which the counter was incremented. This will be less -* than @n if the counter has overflowed. -*/ -__u64 eventfd_signal (struct eventfd_ctx *ctx,__u64 n) +__u64 eventfd_signal_mask (struct eventfd_ctx *ctx,__u64 n,unsigned mask) {unsigned long flags;
@@ -80,12 +66,31 @@ __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n) n =ULLONG_MAX - ctx->count; ctx->count += n;if (waitqueue_active (&ctx->wqh)) -wake_up_locked_poll (&ctx->wqh,EPOLLIN ); +wake_up_locked_poll (&ctx->wqh,EPOLLIN | mask);this_cpu_dec (eventfd_wake_count);spin_unlock_irqrestore (&ctx->wqh.lock, flags);return n; } + +/** +* eventfd_signal - Adds @n to the eventfd counter. +* @ctx: [in] Pointer to the eventfd context. +* @n: [in] Value of the counter to be added to the eventfd internal counter. +* The value cannot be negative. +* +* This function is supposed to be called by the kernel in paths that do not +* allow sleeping. In this function we allow the counter to reach the ULLONG_MAX +* value, and we signal this as overflow condition by returning a EPOLLERR +* to poll(2). +* +* Returns the amount by which the counter was incremented. This will be less +* than @n if the counter has overflowed. +*/ +__u64 eventfd_signal (struct eventfd_ctx *ctx,__u64 n) +{ +return eventfd_signal_mask (ctx, n,0 ); +}EXPORT_SYMBOL_GPL (eventfd_signal);static void eventfd_free_ctx (struct eventfd_ctx *ctx)
include/linux/eventfd.h +7 -0
@@ -39,6 +39,7 @@ struct file *eventfd_fget(int fd);struct eventfd_ctx *eventfd_ctx_fdget (int fd);struct eventfd_ctx *eventfd_ctx_fileget (struct file *file);__u64 eventfd_signal (struct eventfd_ctx *ctx,__u64 n); +__u64 eventfd_signal_mask (struct eventfd_ctx *ctx,__u64 n,unsigned mask);int eventfd_ctx_remove_wait_queue (struct eventfd_ctx *ctx,wait_queue_entry_t *wait,__u64 *cnt);
@@ -66,6 +67,12 @@ static inline int eventfd_signal(struct eventfd_ctx *ctx, int n)return -ENOSYS ; } +static inline int eventfd_signal_mask (struct eventfd_ctx *ctx,__u64 n, +unsigned mask) +{ +return -ENOSYS ; +} +static inline void eventfd_ctx_put (struct eventfd_ctx *ctx) {
Signature · 1 line
2.39.0
From 5d0d6c3d70a751ae214e471989fc729956c6fccb Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Sun, 20 Nov 2022 10:10:53 -0700
Subject: [PATCH 61/63] eventpoll: add EPOLL_URING_WAKE poll wakeup flag
[ Upstream commit caf1aeaffc3b09649a56769e559333ae2c4f1802 ]
We can have dependencies between epoll and io_uring. Consider an epoll context, identified by the epfd file descriptor, and an io_uring file descriptor identified by iofd. If we add iofd to the epfd context, and arm a multishot poll request for epfd with iofd, then the multishot poll request will repeatedly trigger and generate events until terminated by CQ ring overflow. This isn't a desired behavior.
Add EPOLL_URING so that io_uring can pass it in as part of the poll wakeup key, and io_uring can check for that to detect a potential recursive invocation.
--- fs/eventpoll.c | 18 ++++++++++-------- include/uapi/linux/eventpoll.h | 6 ++++++ 2 files changed, 16 insertions(+), 8 deletions(-)
fs/eventpoll.c +10 -8
@@ -548,7 +548,8 @@ static int ep_call_nested(struct nested_calls *ncalls,*/ #ifdef CONFIG_DEBUG_LOCK_ALLOC -static void ep_poll_safewake (struct eventpoll *ep,struct epitem *epi) +static void ep_poll_safewake (struct eventpoll *ep,struct epitem *epi, +unsigned pollflags) {struct eventpoll *ep_src;unsigned long flags;
@@ -579,16 +580,17 @@ static void ep_poll_safewake(struct eventpoll *ep, struct epitem *epi) }spin_lock_irqsave_nested (&ep->poll_wait.lock, flags, nests); ep->nests = nests +1 ; -wake_up_locked_poll (&ep->poll_wait,EPOLLIN ); +wake_up_locked_poll (&ep->poll_wait,EPOLLIN | pollflags); ep->nests =0 ;spin_unlock_irqrestore (&ep->poll_wait.lock, flags); }#else -static void ep_poll_safewake (struct eventpoll *ep,struct epitem *epi) +static void ep_poll_safewake (struct eventpoll *ep,struct epitem *epi, +unsigned pollflags) { -wake_up_poll (&ep->poll_wait,EPOLLIN ); +wake_up_poll (&ep->poll_wait,EPOLLIN | pollflags); }#endif
@@ -815,7 +817,7 @@ static void ep_free(struct eventpoll *ep)/* We need to release all tasks waiting for these file */ if (waitqueue_active (&ep->poll_wait)) -ep_poll_safewake (ep,NULL ); +ep_poll_safewake (ep,NULL ,0 );/* * We need to lock this because we could be hit by
@@ -1284,7 +1286,7 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v/* We have to call this outside the lock */ if (pwake) -ep_poll_safewake (ep, epi); +ep_poll_safewake (ep, epi, pollflags &EPOLL_URING_WAKE );if (!(epi->event.events &EPOLLEXCLUSIVE )) ewake =1 ;
@@ -1589,7 +1591,7 @@ static int ep_insert(struct eventpoll *ep, const struct epoll_event *event,/* We have to call this outside the lock */ if (pwake) -ep_poll_safewake (ep,NULL ); +ep_poll_safewake (ep,NULL ,0 );return 0 ;
@@ -1692,7 +1694,7 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi,/* We have to call this outside the lock */ if (pwake) -ep_poll_safewake (ep,NULL ); +ep_poll_safewake (ep,NULL ,0 );return 0 ; }
include/uapi/linux/eventpoll.h +6 -0
@@ -41,6 +41,12 @@#define EPOLLMSG (__force __poll_t)0x00000400#define EPOLLRDHUP (__force __poll_t)0x00002000 +/* +* Internal flag - wakeup generated by io_uring, used to detect recursion back +* into the io_uring poll handler. +*/ +#define EPOLL_URING_WAKE ((__force __poll_t)(1U << 27)) +/* Set exclusive wakeup mode for the target file descriptor */ #define EPOLLEXCLUSIVE ((__force __poll_t)(1U << 28))
Signature · 1 line
2.39.0
From 2d7b7e632050476301e4fdfaf7a55751c97e6a83 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 15 Feb 2021 13:42:42 -0700
Subject: [PATCH 60/63] Revert "proc: don't allow async path resolution of
/proc/self components"
[ Upstream commit 9e8d9e829c2142cf1d7756e9ed2e0b4c7569d84c ]
This reverts commit 8d4c3e76e3be11a64df95ddee52e99092d42fc19.
No longer needed, as the io-wq worker threads have the right identity.
--- fs/proc/self.c | 7 ------- 1 file changed, 7 deletions(-)
fs/proc/self.c +0 -7
@@ -16,13 +16,6 @@ static const char *proc_self_get_link(struct dentry *dentry,pid_t tgid =task_tgid_nr_ns (current, ns);char *name; -/* -* Not currently supported. Once we can inherit all of struct pid, -* we can allow this. -*/ -if (current->flags &PF_KTHREAD ) -return ERR_PTR (-EOPNOTSUPP ); -if (!tgid)return ERR_PTR (-ENOENT );/* max length of unsigned int in decimal + NULL term */
Signature · 1 line
2.39.0
From 361b2a5293b998f8903a5d343ad5cf683a2970fa Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 15 Feb 2021 13:42:18 -0700
Subject: [PATCH 59/63] Revert "proc: don't allow async path resolution of
/proc/thread-self components"
[ Upstream commit 2587890b5e2892dfecaa5e5126bdac8076a4e6f7 ]
This reverts commit 0d4370cfe36b7f1719123b621a4ec4d9c7a25f89.
No longer needed, as the io-wq worker threads have the right identity.
--- fs/proc/self.c | 2 +- fs/proc/thread_self.c | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-)
fs/proc/self.c +1 -1
@@ -20,7 +20,7 @@ static const char *proc_self_get_link(struct dentry *dentry,* Not currently supported. Once we can inherit all of struct pid, * we can allow this. */ -if (current->flags &PF_IO_WORKER ) +if (current->flags &PF_KTHREAD )return ERR_PTR (-EOPNOTSUPP );if (!tgid)
fs/proc/thread_self.c +0 -7
@@ -17,13 +17,6 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,pid_t pid =task_pid_nr_ns (current, ns);char *name; -/* -* Not currently supported. Once we can inherit all of struct pid, -* we can allow this. -*/ -if (current->flags &PF_IO_WORKER ) -return ERR_PTR (-EOPNOTSUPP ); -if (!pid)return ERR_PTR (-ENOENT ); name =kmalloc (10 +6 +10 +1 , dentry ?GFP_KERNEL :GFP_ATOMIC );
Signature · 1 line
2.39.0
From 89a29005f595d929d8d784f3422fb6a350f4b05f Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Wed, 17 Feb 2021 10:14:21 -0700
Subject: [PATCH 58/63] net: remove cmsg restriction from io_uring based
send/recvmsg calls
[ Upstream commit e54937963fa249595824439dc839c948188dea83 ]
No need to restrict these anymore, as the worker threads are direct clones of the original task. Hence we know for a fact that we can support anything that the regular task can.
Since the only user of proto_ops->flags was to flag PROTO_CMSG_DATA_ONLY, kill the member and the flag definition too.
--- include/linux/net.h | 3 --- net/ipv4/af_inet.c | 1 - net/ipv6/af_inet6.c | 1 - net/socket.c | 10 ---------- 4 files changed, 15 deletions(-)
include/linux/net.h +0 -3
@@ -42,8 +42,6 @@ struct net;#define SOCK_PASSCRED 3#define SOCK_PASSSEC 4 -#define PROTO_CMSG_DATA_ONLY 0x0001 -#ifndef ARCH_HAS_SOCKET_TYPES /** * enum sock_type - Socket types
@@ -138,7 +136,6 @@ typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,struct proto_ops {int family; -unsigned int flags;struct module *owner;int (*release) (struct socket *sock); int (*bind) (struct socket *sock,
net/ipv4/af_inet.c +0 -1
@@ -1017,7 +1017,6 @@ static int inet_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned lonconst struct proto_ops inet_stream_ops = { .family =PF_INET , - .flags =PROTO_CMSG_DATA_ONLY , .owner =THIS_MODULE , .release = inet_release, .bind = inet_bind,
net/ipv6/af_inet6.c +0 -1
@@ -661,7 +661,6 @@ int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,const struct proto_ops inet6_stream_ops = { .family =PF_INET6 , - .flags =PROTO_CMSG_DATA_ONLY , .owner =THIS_MODULE , .release = inet6_release, .bind = inet6_bind,
net/socket.c +0 -10
@@ -2419,10 +2419,6 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,long __sys_sendmsg_sock (struct socket *sock,struct msghdr *msg,unsigned int flags) { -/* disallow ancillary data requests from this path */ -if (msg->msg_control || msg->msg_controllen) -return -EINVAL ; -return ____sys_sendmsg (sock, msg, flags,NULL ,0 ); }
@@ -2631,12 +2627,6 @@ long __sys_recvmsg_sock(struct socket *sock, struct msghdr *msg,struct user_msghdr __user *umsg, struct sockaddr __user *uaddr, unsigned int flags) { - if (msg->msg_control || msg->msg_controllen) { - /* disallow ancillary data reqs unless cmsg is plain data */ - if (!(sock->ops->flags & PROTO_CMSG_DATA_ONLY)) - return -EINVAL; - } - return ____sys_recvmsg(sock, msg, umsg, uaddr, flags, 0); }
Signature · 1 line
2.39.0
From 0f315fd4143c1591a7f902fa08b71b83764f4fa0 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Tue, 5 Jan 2021 11:32:43 -0700
Subject: [PATCH 57/63] task_work: unconditionally run task_work from
get_signal()
[ Upstream commit 35d0b389f3b23439ad15b610d6e43fc72fc75779 ]
Song reported a boot regression in a kvm image with 5.11-rc, and bisected it down to the below patch. Debugging this issue, turns out that the boot stalled when a task is waiting on a pipe being released. As we no longer run task_work from get_signal() unless it's queued with TWA_SIGNAL, the task goes idle without running the task_work. This prevents ->release() from being called on the pipe, which another boot task is waiting on.
For now, re-instate the unconditional task_work run from get_signal(). For 5.12, we'll collapse TWA_RESUME and TWA_SIGNAL, as it no longer makes sense to have a distinction between the two. This will turn task_work notification into a simple boolean, whether to notify or not.
--- kernel/signal.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/signal.c +3 -0
@@ -2520,6 +2520,9 @@ bool get_signal(struct ksignal *ksig)struct signal_struct *signal = current->signal;int signr; +if (unlikely (current->task_works)) +task_work_run (); +/* * For non-generic architectures, check for TIF_NOTIFY_SIGNAL so * that the arch handlers don't all have to do it. If we get here
Signature · 1 line
2.39.0
From 450fb0845804e4245b90eb155d7ac34cda11429f Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 16:03:01 -0600
Subject: [PATCH 56/63] signal: kill JOBCTL_TASK_WORK
[ Upstream commit 98b89b649fce39dacb9dc036d6d0fdb8caff73f7 ]
It's no longer used, get rid of it.
--- include/linux/sched/jobctl.h | 4 +--- kernel/signal.c | 20 -------------------- 2 files changed, 1 insertion(+), 23 deletions(-)
include/linux/sched/jobctl.h +1 -3
@@ -19,7 +19,6 @@ struct task_struct;#define JOBCTL_TRAPPING_BIT 21/* switching to TRACED */ #define JOBCTL_LISTENING_BIT 22/* ptracer is listening for events */ #define JOBCTL_TRAP_FREEZE_BIT 23/* trap for cgroup freezer */ -#define JOBCTL_TASK_WORK_BIT 24/* set by TWA_SIGNAL */ #define JOBCTL_STOP_DEQUEUED (1UL << JOBCTL_STOP_DEQUEUED_BIT)#define JOBCTL_STOP_PENDING (1UL << JOBCTL_STOP_PENDING_BIT)
@@ -29,10 +28,9 @@ struct task_struct;#define JOBCTL_TRAPPING (1UL << JOBCTL_TRAPPING_BIT)#define JOBCTL_LISTENING (1UL << JOBCTL_LISTENING_BIT)#define JOBCTL_TRAP_FREEZE (1UL << JOBCTL_TRAP_FREEZE_BIT) -#define JOBCTL_TASK_WORK (1UL << JOBCTL_TASK_WORK_BIT)#define JOBCTL_TRAP_MASK (JOBCTL_TRAP_STOP | JOBCTL_TRAP_NOTIFY) -#define JOBCTL_PENDING_MASK (JOBCTL_STOP_PENDING | JOBCTL_TRAP_MASK | JOBCTL_TASK_WORK) +#define JOBCTL_PENDING_MASK (JOBCTL_STOP_PENDING | JOBCTL_TRAP_MASK)extern bool task_set_jobctl_pending (struct task_struct *task,unsigned long mask);extern void task_clear_jobctl_trapping (struct task_struct *task);
kernel/signal.c +0 -20
@@ -2544,26 +2544,6 @@ bool get_signal(struct ksignal *ksig) relock:spin_lock_irq (&sighand->siglock); -/* -* Make sure we can safely read ->jobctl() in task_work add. As Oleg -* states: -* -* It pairs with mb (implied by cmpxchg) before READ_ONCE. So we -* roughly have -* -* task_work_add: get_signal: -* STORE(task->task_works, new_work); STORE(task->jobctl); -* mb(); mb(); -* LOAD(task->jobctl); LOAD(task->task_works); -* -* and we can rely on STORE-MB-LOAD [ in task_work_add]. -*/ -smp_store_mb (current->jobctl, current->jobctl & ~JOBCTL_TASK_WORK ); -if (unlikely (current->task_works)) { -spin_unlock_irq (&sighand->siglock); -task_work_run (); - goto relock; - }/* * Every stopped thread goes here after wakeup. Check to see if
Signature · 1 line
2.39.0
From ab51127cad79fdc5ff972e04acb2287c0799efc4 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 22 Dec 2022 14:30:11 -0700
Subject: [PATCH 55/63] io_uring: import 5.15-stable io_uring
No upstream commit exists.
This imports the io_uring codebase from 5.15.85, wholesale. Changes from that code base:
- Drop IOCB_ALLOC_CACHE, we don't have that in 5.10.
- Drop MKDIRAT/SYMLINKAT/LINKAT. Would require further VFS backports, and we don't support these in 5.10 to begin with.
- sock_from_file() old style calling convention.
- Use compat_get_bitmap() only for CONFIG_COMPAT=y
---
Makefile | 2 +-
fs/Makefile | 2 -
fs/io-wq.c | 1242 -----
include/linux/io_uring.h | 46 +-
include/linux/sched.h | 3 +
include/linux/syscalls.h | 2 +-
include/trace/events/io_uring.h | 121 +-
include/uapi/linux/io_uring.h | 115 +-
io_uring/Makefile | 6 +
io_uring/io-wq.c | 1398 +++++
{fs => io_uring}/io-wq.h | 47 +-
{fs => io_uring}/io_uring.c | 9206 +++++++++++++++++--------------
kernel/exit.c | 2 +-
kernel/fork.c | 1 +
kernel/sched/core.c | 2 +-
15 files changed, 6714 insertions(+), 5481 deletions(-)
delete mode 100644 fs/io-wq.c
create mode 100644 io_uring/Makefile
create mode 100644 io_uring/io-wq.c
rename {fs => io_uring}/io-wq.h (81%)
rename {fs => io_uring}/io_uring.c (51%)Makefile +1 -1
@@ -1128,7 +1128,7 @@ export MODORDER := $(extmod-prefix)modules.order export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps ifeq ($(KBUILD_EXTMOD),) -core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ +core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ io_uring/ vmlinux-dirs := $(patsubst %/,%,$(filter %/, \ $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
fs/Makefile +0 -2
@@ -32,8 +32,6 @@ obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o obj-$(CONFIG_USERFAULTFD) += userfaultfd.o obj-$(CONFIG_AIO) += aio.o -obj-$(CONFIG_IO_URING) += io_uring.o -obj-$(CONFIG_IO_WQ) += io-wq.o obj-$(CONFIG_FS_DAX) += dax.o obj-$(CONFIG_FS_ENCRYPTION) += crypto/ obj-$(CONFIG_FS_VERITY) += verity/
fs/io-wq.c deleted +0 -1242
1,242 lines not on this page · raw message
include/linux/io_uring.h +8 -38
65 lines not on this page · raw message
include/linux/sched.h +3 -0
@@ -885,6 +885,9 @@ struct task_struct {/* CLONE_CHILD_CLEARTID: */ int __user *clear_child_tid; +/* PF_IO_WORKER */ +void *pf_io_worker; +u64 utime;u64 stime;#ifdef CONFIG_ARCH_HAS_SCALED_CPUTIME
include/linux/syscalls.h +1 -1
@@ -341,7 +341,7 @@ asmlinkage long sys_io_uring_setup(u32 entries, struct io_uring_params __user *p);asmlinkage long sys_io_uring_enter (unsigned int fd,u32 to_submit,u32 min_complete,u32 flags, -const sigset_t __user *sig,size_t sigsz); +const void __user *argp,size_t argsz);asmlinkage long sys_io_uring_register (unsigned int fd,unsigned int op,void __user *arg,unsigned int nr_args);
include/trace/events/io_uring.h +79 -42
275 lines not on this page · raw message
include/uapi/linux/io_uring.h +100 -15
183 lines not on this page · raw message
io_uring/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for io_uring + +obj-$(CONFIG_IO_URING) += io_uring.o +obj-$(CONFIG_IO_WQ) += io-wq.o
io_uring/io-wq.c new file +1398 -0
859 lines not on this page · raw message
io_uring/io-wq.h renamed from fs/io-wq.h +25 -22
47 lines not on this page · raw message
io_uring/io_uring.c renamed from fs/io_uring.c +5090 -4116
9,206 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From c5b30836e6c6e2db663421c3e33cc83f234fa0c5 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 1 Apr 2021 19:53:29 -0600
Subject: [PATCH 54/63] task_work: add helper for more targeted task_work
canceling
[ Upstream commit c7aab1a7c52b82d9afd7e03c398eb03dc2aa0507 ]
The only exported helper we have right now is task_work_cancel(), which cancels any task_work from a given task where func matches the queued work item. This is a bit too coarse for some use cases. Add a task_work_cancel_match() that allows to more specifically target individual work items outside of purely the callback function used.
task_work_cancel() can be trivially implemented on top of that, hence do so.
--- include/linux/task_work.h | 2 ++ kernel/task_work.c | 35 ++++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From e11f9f61752f252ee19e9c0dee22218f9078a75b Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 26 Mar 2021 08:57:10 -0600
Subject: [PATCH 53/63] kernel: don't call do_exit() for PF_IO_WORKER threads
[ Upstream commit 10442994ba195efef6fdcc0c3699e4633cb5161b ]
Right now we're never calling get_signal() from PF_IO_WORKER threads, but in preparation for doing so, don't handle a fatal signal for them. The workers have state they need to cleanup when exiting, so just return instead of calling do_exit() on their behalf. The threads themselves will detect a fatal signal and do proper shutdown.
--- kernel/signal.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 3ba2de08db37474986cabdd4e675b8e3bfc5df5a Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 26 Mar 2021 09:05:22 -0600
Subject: [PATCH 52/63] kernel: stop masking signals in create_io_thread()
[ Upstream commit b16b3855d89fba640996fefdd3a113c0aa0e380d ]
This is racy - move the blocking into when the task is created and we're marking it as PF_IO_WORKER anyway. The IO threads are now prepared to handle signals like SIGSTOP as well, so clear that from the mask to allow proper stopping of IO threads.
--- kernel/fork.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From f757cc1efe0ec578f54dc857f1684dcd6541b464 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <[email protected]>
Date: Wed, 5 May 2021 13:03:10 +0200
Subject: [PATCH 51/63] x86/process: setup io_threads more like normal user
space threads
[ Upstream commit 50b7b6f29de3e18e9d6c09641256a0296361cfee ]
As io_threads are fully set up USER threads it's clearer to separate the code path from the KTHREAD logic.
The only remaining difference to user space threads is that io_threads never return to user space again. Instead they loop within the given worker function.
The fact that they never return to user space means they don't have an user space thread stack. In order to indicate that to tools like gdb we reset the stack and instruction pointers to 0.
This allows gdb attach to user space processes using io-uring, which like means that they have io_threads, without printing worrying message like this:
warning: Selected architecture i386:x86-64 is not compatible with reported target architecture i386
warning: Architecture rejected target-supplied description
The output will be something like this:
(gdb) info threads
Id Target Id Frame
* 1 LWP 4863 "io_uring-cp-for" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
2 LWP 4864 "iou-mgr-4863" 0x0000000000000000 in ?? ()
3 LWP 4865 "iou-wrk-4863" 0x0000000000000000 in ?? () (gdb) thread 3
[Switching to thread 3 (LWP 4865)]
#0 0x0000000000000000 in ?? ()
(gdb) bt
#0 0x0000000000000000 in ?? ()
Backtrace stopped: Cannot access memory at address 0x0
--- arch/x86/kernel/process.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From b9634adab82019ff70e445c09a7c26a209f6d010 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Tue, 23 Feb 2021 11:57:20 -0700
Subject: [PATCH 50/63] arch: ensure parisc/powerpc handle PF_IO_WORKER in
copy_thread()
[ Upstream commit 0100e6bbdbb79404e56939313662b42737026574 ]
In the arch addition of PF_IO_WORKER, I missed parisc and powerpc for some reason. Fix that up, ensuring they handle PF_IO_WORKER like they do PF_KTHREAD in copy_thread().
--- arch/parisc/kernel/process.c | 2 +- arch/powerpc/kernel/process.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 50b21feb5a0272a0a8cb620d27d4c5e698cc1d21 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Wed, 17 Feb 2021 08:48:00 -0700
Subject: [PATCH 49/63] arch: setup PF_IO_WORKER threads like PF_KTHREAD
[ Upstream commit 4727dc20e0422211a0e0c72b1ace4ed6096df8a6 ]
PF_IO_WORKER are kernel threads too, but they aren't PF_KTHREAD in the sense that we don't assign ->set_child_tid with our own structure. Just ensure that every arch sets up the PF_IO_WORKER threads like kthreads in the arch implementation of copy_thread().
--- arch/alpha/kernel/process.c | 2 +- arch/arc/kernel/process.c | 2 +- arch/arm/kernel/process.c | 2 +- arch/arm64/kernel/process.c | 2 +- arch/csky/kernel/process.c | 2 +- arch/h8300/kernel/process.c | 2 +- arch/hexagon/kernel/process.c | 2 +- arch/ia64/kernel/process.c | 2 +- arch/m68k/kernel/process.c | 2 +- arch/microblaze/kernel/process.c | 2 +- arch/mips/kernel/process.c | 2 +- arch/nds32/kernel/process.c | 2 +- arch/nios2/kernel/process.c | 2 +- arch/openrisc/kernel/process.c | 2 +- arch/riscv/kernel/process.c | 2 +- arch/s390/kernel/process.c | 2 +- arch/sh/kernel/process_32.c | 2 +- arch/sparc/kernel/process_32.c | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/um/kernel/process.c | 2 +- arch/x86/kernel/process.c | 2 +- arch/xtensa/kernel/process.c | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 963feaebdd2ec09424d8d7dda014c4859cce19c5 Mon Sep 17 00:00:00 2001
From: Seth Forshee <[email protected]>
Date: Wed, 4 May 2022 13:08:40 -0500
Subject: [PATCH 48/63] entry/kvm: Exit to user mode when TIF_NOTIFY_SIGNAL is
set
[ Upstream commit 3e684903a8574ffc9475fdf13c4780a7adb506ad ]
A livepatch transition may stall indefinitely when a kvm vCPU is heavily loaded. To the host, the vCPU task is a user thread which is spending a very long time in the ioctl(KVM_RUN) syscall. During livepatch transition, set_notify_signal() will be called on such tasks to interrupt the syscall so that the task can be transitioned. This interrupts guest execution, but when xfer_to_guest_mode_work() sees that TIF_NOTIFY_SIGNAL is set but not TIF_SIGPENDING it concludes that an exit to user mode is unnecessary, and guest execution is resumed without transitioning the task for the livepatch.
This handling of TIF_NOTIFY_SIGNAL is incorrect, as set_notify_signal() is expected to break tasks out of interruptible kernel loops and cause them to return to userspace. Change xfer_to_guest_mode_work() to handle TIF_NOTIFY_SIGNAL the same as TIF_SIGPENDING, signaling to the vCPU run loop that an exit to userpsace is needed. Any pending task_work will be run when get_signal() is called from exit_to_user_mode_loop(), so there is no longer any need to run task work from xfer_to_guest_mode_work().
Message-Id: <[email protected]>
--- kernel/entry/kvm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From b6ea49a1293ab63ef65553c576b8d919bdd3d42e Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 22 Mar 2021 09:39:12 -0600
Subject: [PATCH 47/63] kernel: allow fork with TIF_NOTIFY_SIGNAL pending
[ Upstream commit 66ae0d1e2d9fe6ec70e73fcfdcf4b390e271c1ac ]
fork() fails if signal_pending() is true, but there are two conditions that can lead to that:
1) An actual signal is pending. We want fork to fail for that one, like we always have.
2) TIF_NOTIFY_SIGNAL is pending, because the task has pending task_work. We don't need to make it fail for that case.
Allow fork() to proceed if just task_work is pending, by changing the signal_pending() check to task_sigpending().
--- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 428760d101b98af1e7675882337dcad7c6786d87 Mon Sep 17 00:00:00 2001
From: "Eric W. Biederman" <[email protected]>
Date: Thu, 10 Jun 2021 15:11:11 -0500
Subject: [PATCH 46/63] coredump: Limit what can interrupt coredumps
[ Upstream commit 06af8679449d4ed282df13191fc52d5ba28ec536 ]
Olivier Langlois has been struggling with coredumps being incompletely written in processes using io_uring.
Quoted 10 lines · Olivier Langlois
io_uringis a big user oftask_workand any event thatio_uringmade a task waiting for that occurs during the core dump generation will generate aTIF_NOTIFY_SIGNAL.Here are the detailed steps of the problem:
1.io_uringcallsvfs_poll()to install a task to a file wait queue withio_async_wake()as the wakeup function cb fromio_arm_poll_handler()
2. wakeup function ends up callingtask_work_add()withTWA_SIGNAL
3.task_work_add()sets theTIF_NOTIFY_SIGNALbit by callingset_notify_signal()
The coredump code deliberately supports being interrupted by SIGKILL,
and depends upon prepare_signal to filter out all other signals. Now
that signal_pending includes wake ups for TIF_NOTIFY_SIGNAL this hack in dump_emitted by the coredump code no longer works.
Make the coredump code more robust by explicitly testing for all of the wakeup conditions the coredump code supports. This prevents new wakeup conditions from breaking the coredump code, as well as fixing the current issue.
The filesystem code that the coredump code uses already limits itself to only aborting on fatal_signal_pending. So it should not develop surprising wake-up reasons either.
v2: Don't remove the now unnecessary code in prepare_signal.
--- fs/coredump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 16021acf95cec0ada90dae2b8409ac234c678f3b Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 16:04:39 -0600
Subject: [PATCH 45/63] kernel: remove checking for TIF_NOTIFY_SIGNAL
[ Upstream commit e296dc4996b8094ccde45d19090d804c4103513e ]
It's available everywhere now, no need to check or add dummy defines.
--- include/linux/entry-common.h | 4 ---- include/linux/sched/signal.h | 2 -- include/linux/tracehook.h | 4 ---- kernel/signal.c | 2 -- 4 files changed, 12 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 3e7b055854f9ff08f3c7015c44229147dad5dd08 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 16:01:33 -0600
Subject: [PATCH 44/63] task_work: remove legacy TWA_SIGNAL path
[ Upstream commit 03941ccfda161c2680147fa5ab92aead2a79cac1 ]
All archs now support TIF_NOTIFY_SIGNAL.
--- kernel/task_work.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From cab753b61fc699aa92f8150f71dd9458e8858b3b Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Sat, 18 Sep 2021 18:08:56 -0400
Subject: [PATCH 43/63] alpha: fix TIF_NOTIFY_SIGNAL handling
[ Upstream commit e2c7554cc6d85f95e3c6635f270ec839ab9fe05e ]
it needs to be added to _TIF_WORK_MASK, or we might not reach do_work_pending() in the first place...
--- arch/alpha/include/asm/thread_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From ec98073a6e28f5b0e962b801d1a706479a770e71 Mon Sep 17 00:00:00 2001
From: Vineet Gupta <[email protected]>
Date: Wed, 6 Jan 2021 12:34:36 -0800
Subject: [PATCH 42/63] ARC: unbork 5.11 bootup: fix snafu in
_TIF_NOTIFY_SIGNAL handling
[ Upstream commit bb12433bf56e76789c6b08b36c546f745a6aa6e1 ]
Linux 5.11.rcX was failing to boot on ARC HSDK board. Turns out we have a couple of issues, this being the first one, and I'm to blame as I didn't pay attention during review.
TIF_NOTIFY_SIGNAL support requires checking multiple TIF_* bits in kernel return code path. Old code only needed to check a single bit so BBIT0 <TIF_SIGPENDING> worked. New code needs to check multiple bits so AND <bit-mask> instruction. So needs to use bit mask variant _TIF_SIGPENDING
--- arch/arc/kernel/entry.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 621649af8b9db1666b299d6b8c1bd384f01c4e23 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Tue, 2 Mar 2021 17:22:11 -0700
Subject: [PATCH 41/63] ia64: don't call handle_signal() unless there's
actually a signal queued
[ Upstream commit f5f4fc4649ae542b1a25670b17aaf3cbb6187acc ]
Sergei and John both reported that ia64 failed to boot in 5.11, and it was related to signals. Turns out the ia64 signal handling is a bit odd, it doesn't check the return value of get_signal() for whether there's a signal to deliver or not. With the introduction of TIF_NOTIFY_SIGNAL, then task_work could trigger it.
Fix it by only calling handle_signal() if we actually have a real signal to deliver. This brings it in line with all other archs, too.
--- arch/ia64/kernel/signal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 12d81984f0d70ca40c14f319ceea586b9351b2cb Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:44:37 -0600
Subject: [PATCH 40/63] sparc: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit f50a7052f5e70ee7a6a5e2ed08660994dc3df2a5 ]
Wire up TIF_NOTIFY_SIGNAL handling for sparc.
--- arch/sparc/include/asm/thread_info_32.h | 4 +++- arch/sparc/include/asm/thread_info_64.h | 6 ++++-- arch/sparc/kernel/signal_32.c | 2 +- arch/sparc/kernel/signal_64.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-)
arch/sparc/include/asm/thread_info_32.h +3 -1
Lines of this file are not shown. View the raw message.
arch/sparc/include/asm/thread_info_64.h +4 -2
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 34a226ec555bf65f3b49bd173889554a04b5882a Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 14:29:17 -0600
Subject: [PATCH 39/63] riscv: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 24a31b81e38309b1604f24520110aae1f83f3cbf ]
Wire up TIF_NOTIFY_SIGNAL handling for riscv.
--- arch/riscv/include/asm/thread_info.h | 5 ++++- arch/riscv/kernel/signal.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 1922b65de0ad6f969b02530b9ced9c255b7ecb1b Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:18:43 -0600
Subject: [PATCH 38/63] nds32: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit b13e8bf615fe26fb6a6dfe1b5a1c65e1624dfee2 ]
Wire up TIF_NOTIFY_SIGNAL handling for nds32.
--- arch/nds32/include/asm/thread_info.h | 2 ++ arch/nds32/kernel/ex-exit.S | 2 +- arch/nds32/kernel/signal.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 4732812234a886b6e508d15ebb8ba1f61cb82c87 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 14:49:43 -0600
Subject: [PATCH 37/63] ia64: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit b269c229b0e89aedb7943c06673b56b6052cf5e5 ]
Wire up TIF_NOTIFY_SIGNAL handling for ia64.
--- arch/ia64/include/asm/thread_info.h | 4 +++- arch/ia64/kernel/process.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From b83ee681e7dd713540f41cadb6217784083b38ec Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 14:42:33 -0600
Subject: [PATCH 36/63] h8300: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 2f9799ad0111ee742ccc02dd2ea2c87646746fc1 ]
Wire up TIF_NOTIFY_SIGNAL handling for h8300.
--- arch/h8300/include/asm/thread_info.h | 4 +++- arch/h8300/kernel/signal.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From bc746e497c6c8bcda6bb30d58a2502db4eaaf600 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 14:35:34 -0600
Subject: [PATCH 35/63] c6x: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 6d665a4d8b4264def0fbb72da3a500d9904ffe3e ]
Wire up TIF_NOTIFY_SIGNAL handling for c6x.
--- arch/c6x/include/asm/thread_info.h | 1 + arch/c6x/kernel/asm-offsets.c | 1 + arch/c6x/kernel/signal.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From f85a5fbc85e3edbfa86d83f163307c9ef597eece Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 8 Oct 2020 09:11:42 -0600
Subject: [PATCH 34/63] alpha: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 5a9a8897c253a075805401d38d987ec1ac1824b6 ]
Wire up TIF_NOTIFY_SIGNAL handling for alpha.
--- arch/alpha/include/asm/thread_info.h | 2 ++ arch/alpha/kernel/entry.S | 2 +- arch/alpha/kernel/signal.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 4a20887d142c23ea4f6e0dc1d7c39756ec71d327 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:56:07 -0600
Subject: [PATCH 33/63] xtensa: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit bec58f40d6c5372d812c93cc3947f3bc97440e57 ]
Wire up TIF_NOTIFY_SIGNAL handling for xtensa.
Thanks to Max Filippov <[email protected]> for making the asm correct.
--- arch/xtensa/include/asm/thread_info.h | 5 ++++- arch/xtensa/kernel/entry.S | 4 ++-- arch/xtensa/kernel/signal.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 4548cba5ff2a7b81495b7c109b48972655715142 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 16:00:49 -0600
Subject: [PATCH 32/63] arm: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 32d59773da38cd83e497a70eb9754d4bbae3aeae ]
Wire up TIF_NOTIFY_SIGNAL handling for arm.
--- arch/arm/include/asm/thread_info.h | 7 ++++++- arch/arm/kernel/entry-common.S | 6 +++--- arch/arm/kernel/entry-v7m.S | 2 +- arch/arm/kernel/signal.c | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From ab74702d525c52cbb5dea9fa5169f3f6f5eae2d7 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:13:57 -0600
Subject: [PATCH 31/63] microblaze: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit f4ea089e429e0d366cd1a34a2cbe3c7b13d98d75 ]
Wire up TIF_NOTIFY_SIGNAL handling for microblaze.
--- arch/microblaze/include/asm/thread_info.h | 2 ++ arch/microblaze/kernel/signal.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
arch/microblaze/include/asm/thread_info.h +2 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From ba4b24618290c7ee52180aa3706729e4fb2fd4e4 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 14:45:22 -0600
Subject: [PATCH 30/63] hexagon: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit aeec8193578a71d0aee21218351849d38121ce90 ]
Wire up TIF_NOTIFY_SIGNAL handling for hexagon.
--- arch/hexagon/include/asm/thread_info.h | 2 ++ arch/hexagon/kernel/process.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 9f7678180bf6ff85fbd32bd83ff287a7eb4a6602 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 14:39:00 -0600
Subject: [PATCH 29/63] csky: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit f3924d763c8af4c5d441b666c01f4de03ac9449e ]
Wire up TIF_NOTIFY_SIGNAL handling for csky.
--- arch/csky/include/asm/thread_info.h | 5 ++++- arch/csky/kernel/signal.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 64cef01754a4419e13f0f5f14ec4a9e181bffbe8 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:24:46 -0600
Subject: [PATCH 28/63] openrisc: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit e181c0aa2e532af2b17128fbde699f8578cc0562 ]
Wire up TIF_NOTIFY_SIGNAL handling for openrisc.
--- arch/openrisc/include/asm/thread_info.h | 2 ++ arch/openrisc/kernel/signal.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
arch/openrisc/include/asm/thread_info.h +2 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 1469cd034b065cbe06c2382a0d2aace50e3dc854 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:36:35 -0600
Subject: [PATCH 27/63] sh: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 6d3a273355e3c8471ddf9e8ce9a7cc4472bf1ccc ]
Wire up TIF_NOTIFY_SIGNAL handling for sh.
--- arch/sh/include/asm/thread_info.h | 4 +++- arch/sh/kernel/signal_32.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 9b4d7860ca092440b774c82827455f53e649ee0f Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:47:28 -0600
Subject: [PATCH 26/63] um: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit a5b3cd32ff238b87e94d47b927aff117e22d13c0 ]
Wire up TIF_NOTIFY_SIGNAL handling for um.
--- arch/um/include/asm/thread_info.h | 2 ++ arch/um/kernel/process.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 832028e42ad081b88ee7a72c8c9bcdea6eed3f97 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:34:12 -0600
Subject: [PATCH 25/63] s390: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 75309018a24ddfb930c51bad8f4070b9bc2c923b ]
Wire up TIF_NOTIFY_SIGNAL handling for s390.
--- arch/s390/include/asm/thread_info.h | 2 ++ arch/s390/kernel/entry.S | 11 ++++++----- arch/s390/kernel/signal.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 60559f867bc926e5595c13e4b85ea2fea168ecf8 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:16:02 -0600
Subject: [PATCH 24/63] mips: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit f45c184bce15f4a314c0210519bc3b4aab408838 ]
Wire up TIF_NOTIFY_SIGNAL handling for mips.
--- arch/mips/include/asm/thread_info.h | 4 +++- arch/mips/kernel/signal.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 616d38f834d91a5af2e3afb08f12ecb8b32e4a96 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 22 Oct 2020 20:11:56 -0600
Subject: [PATCH 23/63] powerpc: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 900f0713fdd730fab0f0bfa4a8ca4db2a8985bbe ]
Wire up TIF_NOTIFY_SIGNAL handling for powerpc.
--- arch/powerpc/include/asm/thread_info.h | 5 ++++- arch/powerpc/kernel/signal.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 99f442791761b9b7f4796f926779310d5a5e84ca Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:27:02 -0600
Subject: [PATCH 22/63] parisc: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 18cb3281285d2190c0605d2e53543802319bd1a1 ]
Wire up TIF_NOTIFY_SIGNAL handling for parisc.
--- arch/parisc/include/asm/thread_info.h | 4 +++- arch/parisc/kernel/signal.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From ad18cba50dbe1fbc8e57c4e96f4a952efe212eb3 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:21:21 -0600
Subject: [PATCH 21/63] nios32: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 42020064274c235d720d9c4b7d9a678b133e59cf ]
Wire up TIF_NOTIFY_SIGNAL handling for nios32.
--- arch/nios2/include/asm/thread_info.h | 2 ++ arch/nios2/kernel/signal.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From da81a523c0a6278891e020596edc7a32cb593922 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 9 Oct 2020 15:10:55 -0600
Subject: [PATCH 20/63] m68k: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit e660653cd9f2df470d156c249631f68b9dee51ee ]
Wire up TIF_NOTIFY_SIGNAL handling for m68k.
--- arch/m68k/include/asm/thread_info.h | 1 + arch/m68k/kernel/signal.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From eaa379f10805fdf0f096bfd32d3697f7af0dc185 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 22 Oct 2020 20:09:23 -0600
Subject: [PATCH 19/63] arm64: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 192caabd4dd92c98d23ed4334d7596af05af2fb4 ]
Wire up TIF_NOTIFY_SIGNAL handling for arm64.
--- arch/arm64/include/asm/thread_info.h | 5 ++++- arch/arm64/kernel/signal.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From b71f35bd26a9b588d59894e542c48b4360be52fc Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 12 Oct 2020 07:15:37 -0600
Subject: [PATCH 18/63] arc: add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 53855e12588743ea128ee31f913d1c6e2f1d32c8 ]
Wire up TIF_NOTIFY_SIGNAL handling for arc.
--- arch/arc/include/asm/thread_info.h | 4 +++- arch/arc/kernel/entry.S | 3 ++- arch/arc/kernel/signal.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From f8f5fdc79f0e480230c501bc5d744bc08defec6c Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 26 Oct 2020 14:32:29 -0600
Subject: [PATCH 17/63] x86: Wire up TIF_NOTIFY_SIGNAL
[ Upstream commit c8d5ed67936fddbe2ae845fc80397718006322d7 ]
The generic entry code has support for TIF_NOTIFY_SIGNAL already. Just provide the TIF bit.
[ tglx: Adopted to other TIF changes in x86 ]
--- arch/x86/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From fd7614eb55ed1cd0017baea8a7621586d44089be Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 26 Oct 2020 14:32:30 -0600
Subject: [PATCH 16/63] task_work: Use TIF_NOTIFY_SIGNAL if available
[ Upstream commit 114518eb6430b832d2f9f5a008043b913ccf0e24 ]
If the arch supports TIF_NOTIFY_SIGNAL, then use that for TWA_SIGNAL as it's more efficient than using the signal delivery method. This is especially true on threaded applications, where ->sighand is shared across threads, but it's also lighter weight on non-shared cases.
io_uring is a heavy consumer of TWA_SIGNAL based task_work. A test with threads shows a nice improvement running an io_uring based echo server.
stock kernel:
0.01% <= 0.1 milliseconds
95.86% <= 0.2 milliseconds
98.27% <= 0.3 milliseconds
99.71% <= 0.4 milliseconds
100.00% <= 0.5 milliseconds
100.00% <= 0.6 milliseconds
100.00% <= 0.7 milliseconds
100.00% <= 0.8 milliseconds
100.00% <= 0.9 milliseconds
100.00% <= 1.0 milliseconds
100.00% <= 1.1 milliseconds
100.00% <= 2 milliseconds
100.00% <= 3 milliseconds
100.00% <= 3 milliseconds
1378930.00 requests per second
~1600% CPU
1.38M requests/second, and all 16 CPUs are maxed out.
patched kernel:
0.01% <= 0.1 milliseconds
98.24% <= 0.2 milliseconds
99.47% <= 0.3 milliseconds
99.99% <= 0.4 milliseconds
100.00% <= 0.5 milliseconds
100.00% <= 0.6 milliseconds
100.00% <= 0.7 milliseconds
100.00% <= 0.8 milliseconds
100.00% <= 0.9 milliseconds
100.00% <= 1.2 milliseconds
1666111.38 requests per second
~1450% CPU
1.67M requests/second, and we're no longer just hammering on the sighand lock. The original reporter states:
"For 5.7.15 my benchmark achieves 1.6M qps and system cpu is at ~80%.
for 5.7.16 or later it achieves only 1M qps and the system cpu is is at ~100%"
with the only difference there being that TWA_SIGNAL is used unconditionally in 5.7.16, since it's required to be able to handle the inability to run task_work if the application is waiting in the kernel already on an event that needs task_work run to be satisfied. Also see commit 0ba9c9edcd15.
--- kernel/task_work.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-)
kernel/task_work.c +29 -12
41 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From d02e3fa856542e39531f7f0910389b334cd9b1f3 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 26 Oct 2020 14:32:28 -0600
Subject: [PATCH 15/63] entry: Add support for TIF_NOTIFY_SIGNAL
[ Upstream commit 12db8b690010ccfadf9d0b49a1e1798e47dbbe1a ]
Add TIF_NOTIFY_SIGNAL handling in the generic entry code, which if set, will return true if signal_pending() is used in a wait loop. That causes an exit of the loop so that notify_signal tracehooks can be run. If the wait loop is currently inside a system call, the system call is restarted once task_work has been processed.
In preparation for only having arch_do_signal() handle syscall restarts if _TIF_SIGPENDING isn't set, rename it to arch_do_signal_or_restart(). Pass in a boolean that tells the architecture specific signal handler if it should attempt to get a signal, or just process a potential syscall restart.
For !CONFIG_GENERIC_ENTRY archs, add the TIF_NOTIFY_SIGNAL handling to get_signal(). This is done to minimize the needed architecture changes to support this feature.
--- arch/x86/kernel/signal.c | 4 ++-- include/linux/entry-common.h | 11 ++++++++--- include/linux/entry-kvm.h | 4 ++-- include/linux/sched/signal.h | 11 ++++++++++- include/linux/tracehook.h | 27 +++++++++++++++++++++++++++ kernel/entry/common.c | 14 +++++++++++--- kernel/entry/kvm.c | 3 +++ kernel/signal.c | 14 ++++++++++++++ 8 files changed, 77 insertions(+), 11 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 369d83e272a9f1a316ce79b1236f1f3265e40efe Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Tue, 19 Jan 2021 15:41:52 -0700
Subject: [PATCH 14/63] fs: provide locked helper variant of
close_fd_get_file()
[ Upstream commit 53dec2ea74f2ef360e8455439be96a780baa6097 ]
Assumes current->files->file_lock is already held on invocation. Helps the caller check the file before removing the fd, if it needs to.
--- fs/file.c | 36 +++++++++++++++++++++++++----------- fs/internal.h | 1 + 2 files changed, 26 insertions(+), 11 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From ba51a050af49c1df47fe79687d5f14256620d508 Mon Sep 17 00:00:00 2001
From: "Eric W. Biederman" <[email protected]>
Date: Fri, 20 Nov 2020 17:14:40 -0600
Subject: [PATCH 13/63] file: Rename __close_fd_get_file close_fd_get_file
[ Upstream commit 9fe83c43e71cdb8e5b9520bcb98706a2b3c680c8 ]
The function close_fd_get_file is explicitly a variant of __close_fd[1]. Now that __close_fd has been renamed close_fd, rename close_fd_get_file to be consistent with close_fd.
When __alloc_fd, __close_fd and __fd_install were introduced the double underscore indicated that the function took a struct files_struct parameter. The function __close_fd_get_file never has so the naming has always been inconsistent. This just cleans things up so there are not any lingering mentions or references __close_fd left in the code.
[1] 80cd795630d6 ("binder: fix use-after-free due to ksys_close() during fdget()")
--- drivers/android/binder.c | 2 +- fs/file.c | 4 ++-- fs/io_uring.c | 2 +- include/linux/fdtable.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From aa359e48cc999513b0167703009d3db363818540 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Sat, 26 Sep 2020 17:20:17 -0600
Subject: [PATCH 12/63] fs: make do_renameat2() take struct filename
[ Upstream commit e886663cfd029b64a1d8da7efae7014526d884e9 ]
Pass in the struct filename pointers instead of the user string, and update the three callers to do the same.
This behaves like do_unlinkat(), which also takes a filename struct and puts it when it is done. Converting callers is then trivial.
--- fs/internal.h | 2 ++ fs/namei.c | 40 ++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From a70e1337ccd380cbb8b647c1645ded7f3bf7a136 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Mon, 26 Oct 2020 14:32:27 -0600
Subject: [PATCH 11/63] signal: Add task_sigpending() helper
[ Upstream commit 5c251e9dc0e127bac6fc5b8e6696363d2e35f515 ]
This is in preparation for maintaining signal_pending() as the decider of whether or not a schedule() loop should be broken, or continue sleeping. This is different than the core signal use cases, which really need to know whether an actual signal is pending or not. task_sigpending() returns non-zero if TIF_SIGPENDING is set.
Only core kernel use cases should care about the distinction between the two, make sure those use the task_sigpending() helper.
--- include/linux/sched/signal.h | 9 +++++++-- kernel/events/uprobes.c | 2 +- kernel/signal.c | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From ab96e6863470dd3f13f9a894455b802cde9bcefc Mon Sep 17 00:00:00 2001
From: Pavel Begunkov <[email protected]>
Date: Wed, 25 Aug 2021 12:25:44 +0100
Subject: [PATCH 10/63] net: add accept helper not installing fd
[ Upstream commit d32f89da7fa8ccc8b3fb8f909d61e42b9bc39329 ]
Introduce and reuse a helper that acts similarly to __sys_accept4_file() but returns struct file instead of installing file descriptor. Will be used by io_uring.
--- include/linux/socket.h | 3 ++ net/socket.c | 67 +++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 31 deletions(-)
net/socket.c +36 -31
67 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From b7a66ad26bc4d7ba3285345a3bfef88214164df3 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Sat, 5 Sep 2020 11:13:35 -0600
Subject: [PATCH 09/63] net: provide __sys_shutdown_sock() that takes a socket
[ Upstream commit b713c195d59332277a31a59c91f755e53b5b302b ]
No functional changes in this patch, needed to provide io_uring support for shutdown(2).
--- include/linux/socket.h | 1 + net/socket.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 8e9c2ce1060f14cda30808322d9a8dcbd7a3fd77 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Tue, 23 Feb 2021 09:44:37 -0300
Subject: [PATCH 08/63] tools headers UAPI: Sync openat2.h with the kernel
sources
[ Upstream commit 1e61463cfcd0b3e7a19ba36b8a98c64ebaac5c6e ]
To pick the changes in:
99668f618062816c ("fs: expose LOOKUP_CACHED through openat2() RESOLVE_CACHED")
That don't result in any change in tooling, only silences this perf build warning:
Warning: Kernel ABI header at 'tools/include/uapi/linux/openat2.h' differs from latest version at 'include/uapi/linux/openat2.h' diff -u tools/include/uapi/linux/openat2.h include/uapi/linux/openat2.h
--- tools/include/uapi/linux/openat2.h | 4 ++++ 1 file changed, 4 insertions(+)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From cb9294e007feacca1a5849773460dde71e50cdde Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 17 Dec 2020 09:19:10 -0700
Subject: [PATCH 07/63] fs: expose LOOKUP_CACHED through openat2()
RESOLVE_CACHED
[ Upstream commit 99668f618062816ca7ba639b007eb145b9d3d41e ]
Now that we support non-blocking path resolution internally, expose it via openat2() in the struct open_how ->resolve flags. This allows applications using openat2() to limit path resolution to the extent that it is already cached.
If the lookup cannot be satisfied in a non-blocking manner, openat2(2) will return -1/-EAGAIN.
--- fs/open.c | 6 ++++++ include/linux/fcntl.h | 2 +- include/uapi/linux/openat2.h | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 597ed7633bde8abc24c0cea5fbbfd824200d3251 Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Tue, 6 Apr 2021 12:33:07 -0400
Subject: [PATCH 06/63] Make sure nd->path.mnt and nd->path.dentry are always
valid pointers
[ Upstream commit 7d01ef7585c07afaf487759a48486228cd065726 ]
Initialize them in set_nameidata() and make sure that terminate_walk() clears them once the pointers become potentially invalid (i.e. we leave RCU mode or drop them in non-RCU one). Currently we have "path_init() always initializes them and nobody accesses them outside of path_init()/terminate_walk() segments", which is asking for trouble.
With that change we would have nd->path.{mnt,dentry}
1) always valid - NULL or pointing to currently allocated objects.
2) non-NULL while we are successfully walking
3) NULL when we are not walking at all
4) contributing to refcounts whenever non-NULL outside of RCU mode.
--- fs/namei.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From b93a6e389bdc72d423e666cbb5475ca7c7c4deb9 Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Mon, 15 Feb 2021 12:03:23 -0500
Subject: [PATCH 05/63] fix handling of nd->depth on LOOKUP_CACHED failures in
try_to_unlazy*
[ Upstream commit eacd9aa8cedeb412842c7b339adbaa0477fdd5ad ]
After switching to non-RCU mode, we want nd->depth to match the number of entries in nd->stack[] that need eventual path_put(). legitimize_links() takes care of that on failures; unfortunately, failure exits added for LOOKUP_CACHED do not.
We could add the logics for that into those failure exits, both in try_to_unlazy() and in try_to_unlazy_next(), but since both checks are immediately followed by legitimize_links() and there's no calls of legitimize_links() other than those two... It's easier to move the check (and required handling of nd->depth on failure) into legitimize_links() itself.
[caught by Jens: ... and since we are zeroing ->depth here, we need to do drop_links() first]
--- fs/namei.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 53e825b10aa8f037c19c51997f5f8402d046d883 Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 17 Dec 2020 09:19:09 -0700
Subject: [PATCH 04/63] fs: add support for LOOKUP_CACHED
[ Upstream commit 6c6ec2b0a3e0381d886d531bd1471dfdb1509237 ]
io_uring always punts opens to async context, since there's no control over whether the lookup blocks or not. Add LOOKUP_CACHED to support just doing the fast RCU based lookups, which we know will not block. If we can do a cached path resolution of the filename, then we don't have to always punt lookups for a worker.
During path resolution, we always do LOOKUP_RCU first. If that fails and we terminate LOOKUP_RCU, then fail a LOOKUP_CACHED attempt as well.
--- fs/namei.c | 9 +++++++++ include/linux/namei.h | 1 + 2 files changed, 10 insertions(+)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 2f065a20a2d0b75c25a9125f452991049dcd4205 Mon Sep 17 00:00:00 2001
From: Al Viro <[email protected]>
Date: Mon, 4 Jan 2021 00:08:41 -0500
Subject: [PATCH 03/63] saner calling conventions for unlazy_child()
[ Upstream commit ae66db45fd309fd1c6d4e846dfc8414dfec7d6ad ]
same as for the previous commit - instead of 0/-ECHILD make it return true/false, rename to try_to_unlazy_child().
--- fs/namei.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From 4d95aa07b6f1059990366f88112c48f217fbbc5d Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Fri, 10 Sep 2021 11:18:36 -0600
Subject: [PATCH 02/63] iov_iter: add helper to save iov_iter state
[ Upstream commit 8fb0f47a9d7acf620d0fd97831b69da9bc5e22ed ]
In an ideal world, when someone is passed an iov_iter and returns X bytes, then X bytes would have been consumed/advanced from the iov_iter. But we have use cases that always consume the entire iterator, a few examples of that are iomap and bdev O_DIRECT. This means we cannot rely on the state of the iov_iter once we've called ->read_iter() or ->write_iter().
This would be easier if we didn't always have to deal with truncate of the iov_iter, as rewinding would be trivial without that. We recently added a commit to track the truncate state, but that grew the iov_iter by 8 bytes and wasn't the best solution.
Implement a helper to save enough of the iov_iter state to sanely restore it after we've called the read/write iterator helpers. This currently only works for IOVEC/BVEC/KVEC as that's all we need, support for other iterator types are left as an exercise for the reader.
--- include/linux/uio.h | 15 +++++++++++++ lib/iov_iter.c | 52 ++++++++++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 19 deletions(-)
lib/iov_iter.c +33 -19
52 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
From a3db03dc7a4f33de20188638d5b193c2946c5dfe Mon Sep 17 00:00:00 2001
From: Jens Axboe <[email protected]>
Date: Thu, 4 Mar 2021 12:21:05 -0700
Subject: [PATCH 01/63] kernel: provide create_io_thread() helper
[ Upstream commit cc440e8738e5c875297ac0e90316745093be7e28 ]
Provide a generic helper for setting up an io_uring worker. Returns a task_struct so that the caller can do whatever setup is needed, then call wake_up_new_task() to kick it into gear.
Add a kernel_clone_args member, io_thread, which tells copy_process() to mark the task with PF_IO_WORKER.
--- include/linux/sched/task.h | 2 ++ kernel/fork.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.0
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerQuoted 7 lines · Jens Axboe
Hi Greg,
Here's the series we discussed before the break, no changes since then. Last 3 patches are new stable backports, the rest is backporting the 5.15.85
io_uringcodebase to 5.10-stable. This is done to make 5.10 maintainable wrtio_uring, and importantly, to bring back the native io workers to 5.10-stable.
Thanks for this! I've queued them all up now and will push out a -rc with just them for testing in a bit.
greg k-h