From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C23CC369C2 for ; Tue, 22 Apr 2025 17:05:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 986926B000A; Tue, 22 Apr 2025 13:05:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9365E6B000C; Tue, 22 Apr 2025 13:05:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D7F16B000D; Tue, 22 Apr 2025 13:05:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5CF7C6B000A for ; Tue, 22 Apr 2025 13:05:07 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2B735140C1C for ; Tue, 22 Apr 2025 17:05:09 +0000 (UTC) X-FDA: 83362305138.24.51BC03D Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) by imf21.hostedemail.com (Postfix) with ESMTP id 478221C0021 for ; Tue, 22 Apr 2025 17:05:07 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=a+iA07Yu; spf=pass (imf21.hostedemail.com: domain of qq282012236@gmail.com designates 209.85.160.48 as permitted sender) smtp.mailfrom=qq282012236@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745341507; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+7WrLg4e9cY2VHcHtoBcoTJy6lszZ4yXJERHqcp7ExI=; b=ZUJ9J1vynnrU3+kruNX/p7HQU5rJ/NJW97Zxh1cj27m5iejbVo9/i67QcqqHgQoB3sSzYu o+9Ev9pcbWybpeh2+hbQ2cLKUa/sRryQlZKY8FgCx27ERaepnPnTJyVLCOPHDZsARd8uup 4nbSeGULi/RwXAt0gAOd72DNoilx2B8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=a+iA07Yu; spf=pass (imf21.hostedemail.com: domain of qq282012236@gmail.com designates 209.85.160.48 as permitted sender) smtp.mailfrom=qq282012236@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745341507; a=rsa-sha256; cv=none; b=5t7KT6oekWuY7nPp20QBC95+ZvGpeNl5dgsAlTiWGT+cQS3uYlZOvVYArBM7j93eSI9x0o aRrgWlrdK3beDQLDwU5PalrVDP5LF8Xnjj9yL+weIpKoWB49vhLXWUIz7QUFbWOdy3VVd6 jQV1n3zPAt/4ymgiAvtIfz1/zSV59VQ= Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-2c2bb447e5eso2838911fac.0 for ; Tue, 22 Apr 2025 10:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745341506; x=1745946306; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+7WrLg4e9cY2VHcHtoBcoTJy6lszZ4yXJERHqcp7ExI=; b=a+iA07Yu/hoyqmp5w3lqy7ejwB35racdPP8lXjfvVLtdIIdyn5DEZxIrDbxwlY2oge 39hMT6Mg2W6VufHfjpTeunqbw760/RwuMERfVy9y5rWk/YBU6AhMog+E/kTJiEtno4qo C7yN0rCYPrK12NJo/NPlL4ZAW4Sq+oTp35XyvfTSb/KMhmFopuFb0QKB3oD9jzcK4yiA 8Mfc5cV9cw4ekXklNIAWm4M7CwiqFYUmhb/T+6gDPB2PdG+JDLihROQgQgGVAxgYGuA9 2hnWmquaGn7IcTSgu2Jegnwfii70rYX84cE9kE6DUglIWLYdFwxuSKiqxfkPZxsiNOo2 zy+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745341506; x=1745946306; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+7WrLg4e9cY2VHcHtoBcoTJy6lszZ4yXJERHqcp7ExI=; b=DYxxiC3J/t9IgVyxP4x3ZxILzh0TNgnLNcsNbdWE7mkJbMX0HNQkHUZYLCkIyusBuT TSoZPhXhaxjCZWzo44z3rq3BiExm8EdcsyUsbA0TCf91LFAW+KZOkFUq07F12aTba4hl 7XWcugF7iJiPmKnXRcHdqbDsKNugU9md4JTWVFUuHxgYLj41bCTL3FZuXIpUsTEB2Nxc 3rSvLMn+vzvEU/SkF2hTUS85p5m9liSJ08p0m05az67k2ws65QASKvlpvLxy+ols/3D5 Gk5jreXxaQwMBhaBpzCve+C6x5xSTeubdGbBcMCS9DKU9g4JgzL3Cz0fAq9Sd9cWqMiZ ylVw== X-Forwarded-Encrypted: i=1; AJvYcCVdTeUlhx9/icXUC1PV0s0/zcH0NenHaP1DcZ80WNHvXxyRbW5Z/HIyw6Mzf7Sg8bq9wo1ah+1m+A==@kvack.org X-Gm-Message-State: AOJu0YyQYCBSuMycOGnesnjEVe+pXDQFA71FOiMEaVJT4HHevkydBVnb D5BbHI4wCuowg08w97ZuUox47+Yj6D/VdquTIuHbgKsxdEGhy007lJisEJ2WGFFObA2Uq4Yk8RJ lTZM98H8tYljTeMoDH9wOd0Kvb9A= X-Gm-Gg: ASbGncuO7W5tBWnMLX/rXXXU1em2owPphgtC0RY2rg2EK+WIYX3NqvA10QS1WpmjPm9 +eoAaHc3eBrsQRdAxrUcckItwetwRc2VxoDS3N1Ie4FgzRhQyV91PPoxD7jHUBnOUNNe5/CeneE 24RKGQQXqNcwWSceAx0NOrEfs= X-Google-Smtp-Source: AGHT+IG5jwX6aVuobCSfbSvJJVwejcD1mwDTMTpKItoC292lr3eiPUL1ZrVtszaaUklSkLJkJnMb0yYQavR0xmtevIM= X-Received: by 2002:a05:6871:bd07:b0:2d5:75eb:518f with SMTP id 586e51a60fabf-2d575eb71e5mr4778772fac.2.1745341506113; Tue, 22 Apr 2025 10:05:06 -0700 (PDT) MIME-Version: 1.0 References: <20250422162913.1242057-1-qq282012236@gmail.com> <20250422162913.1242057-2-qq282012236@gmail.com> <14195206-47b1-4483-996d-3315aa7c33aa@kernel.dk> In-Reply-To: <14195206-47b1-4483-996d-3315aa7c33aa@kernel.dk> From: =?UTF-8?B?5aec5pm65Lyf?= Date: Wed, 23 Apr 2025 01:04:53 +0800 X-Gm-Features: ATxdqUH2JFOvPlQAV9Hzfw7ZRpF8PKn7CsDp2ww7xDEp1szv9ceWdNCDqRVVWO4 Message-ID: Subject: Re: [PATCH v2 1/2] io_uring: Add new functions to handle user fault scenarios To: Jens Axboe Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, akpm@linux-foundation.org, peterx@redhat.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: cn6z67gtk4qjbs8wsk3ropfgs57yehcr X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 478221C0021 X-Rspam-User: X-HE-Tag: 1745341507-987360 X-HE-Meta: U2FsdGVkX1+h5L26rtyaPUAuVXzbbF2+s5hh9E/tYaxF4pwMzMTn/PbS3cUOp2GV8INGrVQtdFvI852FE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Ws/7tDU04Xx3kluxA9Oaluq0vYW6HasQFhkFFjv0gd0B9N9hkLJPi7cAQa9XE0AWUR+KoFL6ppU3Oto2+8OF/Lr8FW768tqg10UqrFCsz7DPeLGkIGq63PlCWuKiT4+AHzUgQqY7AgrkQeK6jmUdNTXrpy+WeiII2675LEkg8ROrTEW0UL+sOz0bpOyZINr9hEYh1tO5MIomi5bBuSdUrg54f3pgeHkAX6WUXfNpd+kaReqOBt7cTuMFv+gHNrdGrTh5quV5ZzuWRgbvUhuXuYJOiuuYN5+E9i/sXZ/gK0xr/6eWpTs77x3Ao= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Apr 23, 2025 at 12:32=E2=80=AFAM Jens Axboe wrote= : > > On 4/22/25 10:29 AM, Zhiwei Jiang wrote: > > diff --git a/io_uring/io-wq.h b/io_uring/io-wq.h > > index d4fb2940e435..8567a9c819db 100644 > > --- a/io_uring/io-wq.h > > +++ b/io_uring/io-wq.h > > @@ -70,8 +70,10 @@ enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, = work_cancel_fn *cancel, > > void *data, bool cancel_all); > > > > #if defined(CONFIG_IO_WQ) > > -extern void io_wq_worker_sleeping(struct task_struct *); > > -extern void io_wq_worker_running(struct task_struct *); > > +extern void io_wq_worker_sleeping(struct task_struct *tsk); > > +extern void io_wq_worker_running(struct task_struct *tsk); > > +extern void set_userfault_flag_for_ioworker(void); > > +extern void clear_userfault_flag_for_ioworker(void); > > #else > > static inline void io_wq_worker_sleeping(struct task_struct *tsk) > > { > > @@ -79,6 +81,12 @@ static inline void io_wq_worker_sleeping(struct task= _struct *tsk) > > static inline void io_wq_worker_running(struct task_struct *tsk) > > { > > } > > +static inline void set_userfault_flag_for_ioworker(void) > > +{ > > +} > > +static inline void clear_userfault_flag_for_ioworker(void) > > +{ > > +} > > #endif > > > > static inline bool io_wq_current_is_worker(void) > > This should go in include/linux/io_uring.h and then userfaultfd would > not have to include io_uring private headers. > > But that's beside the point, like I said we still need to get to the > bottom of what is going on here first, rather than try and paper around > it. So please don't post more versions of this before we have that > understanding. > > See previous emails on 6.8 and other kernel versions. > > -- > Jens Axboe The issue did not involve creating new worker processes. Instead, the existing IOU worker kernel threads (about a dozen) associated with the VM process were fully utilizing CPU without writing data, caused by a fault while reading user data pages in the fault_in_iov_iter_readable function when pulling user memory into kernel space. This issue occurs like during VM snapshot loading (which uses userfaultfd for on-demand memory loading), while the task in the guest is writing data to disk. Normally, the VM first triggers a user fault to fill the page table. So in the IOU worker thread, the page tables are already filled, fault no chance happens when faulting in memory pages in fault_in_iov_iter_readable. I suspect that during snapshot loading, a memory access in the VM triggers an async page fault handled by the kernel thread, while the IOU worker's async kernel thread is also running. Maybe If the IOU worker's thread is scheduled first. I=E2=80=99m going to bed now.