From: Zhiwei Jiang <qq282012236@gmail.com>
To: viro@zeniv.linux.org.uk
Cc: brauner@kernel.org, jack@suse.cz, akpm@linux-foundation.org,
peterx@redhat.com, axboe@kernel.dk, asml.silence@gmail.com,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, io-uring@vger.kernel.org,
Zhiwei Jiang <qq282012236@gmail.com>
Subject: [PATCH 2/2] userfaultfd: Set the corresponding flag in IOU worker context
Date: Tue, 22 Apr 2025 10:45:45 +0000 [thread overview]
Message-ID: <20250422104545.1199433-3-qq282012236@gmail.com> (raw)
In-Reply-To: <20250422104545.1199433-1-qq282012236@gmail.com>
Set this to avoid premature return from schedule in IOU worker threads,
ensuring it sleeps and waits to be woken up as in normal cases.
Signed-off-by: Zhiwei Jiang <qq282012236@gmail.com>
---
fs/userfaultfd.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index d80f94346199..74bead069e85 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -32,6 +32,7 @@
#include <linux/swapops.h>
#include <linux/miscdevice.h>
#include <linux/uio.h>
+#include "../io_uring/io-wq.h"
static int sysctl_unprivileged_userfaultfd __read_mostly;
@@ -369,7 +370,10 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
vm_fault_t ret = VM_FAULT_SIGBUS;
bool must_wait;
unsigned int blocking_state;
+ struct io_worker *worker = current->worker_private;
+ if (worker)
+ set_userfault_flag_for_ioworker(worker);
/*
* We don't do userfault handling for the final child pid update
* and when coredumping (faults triggered by get_dump_page()).
@@ -506,6 +510,9 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
__set_current_state(TASK_RUNNING);
+ if (worker)
+ clear_userfault_flag_for_ioworker(worker);
+
/*
* Here we race with the list_del; list_add in
* userfaultfd_ctx_read(), however because we don't ever run
--
2.34.1
next prev parent reply other threads:[~2025-04-22 10:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 10:45 [PATCH 0/2] Fix 100% CPU usage issue in IOU worker threads Zhiwei Jiang
2025-04-22 10:45 ` [PATCH 1/2] io_uring: Add new functions to handle user fault scenarios Zhiwei Jiang
2025-04-22 10:45 ` Zhiwei Jiang [this message]
2025-04-22 13:34 ` [PATCH 0/2] Fix 100% CPU usage issue in IOU worker threads Jens Axboe
2025-04-22 14:10 ` 姜智伟
2025-04-22 14:13 ` Jens Axboe
2025-04-22 14:18 ` 姜智伟
2025-04-22 14:29 ` Jens Axboe
2025-04-22 15:49 ` Jens Axboe
2025-04-22 16:14 ` 姜智伟
2025-04-22 16:24 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250422104545.1199433-3-qq282012236@gmail.com \
--to=qq282012236@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox