From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796467773; b=Fxm7veWbiIuET9j1CBeAzihAFilHYDLkvj2Qk98mp4q+mYj+W9wiBeRYLP3z4274HsJB VwSZ3l9cj5QHZk6iVWL8mTs5HoLXAE1nMtfNMiB2DS1U1HXIU03f8h/nUJnyxliMyQEEo Y8LKiNKi9nEI0pQcCkGpm2waPWkBtm0bQpkMlIsNSnXjKz0fgu/M8uwnaI8YVK8TRlCer d0Up07FF2Xt59KRlWA2bJ8sKeli5G6g20l/3s5H6V1aRW9NfrpV0euwfOyxv16nL1H3HM vppu0mee/wrH6xX8XpXPDZeRoy8K/vsvS3o0MkdfWo9CRBWCeu6ykPny590vRAu3c7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796467773; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=Q3j3IPyUa5Mu4f1f1hiaUwnHqKny6qARW0n7R6KVrWU=; b=QtriIbiNq5rNjYBrZ+4D50+nVJMoPN/mGpBr1G7NkiDpSPhdPbR0WESvMC3LpgDfLIdm nSuoG3X7M/rRH17X0YQe4jGm5ZlO/CzS3bCllqGxcNdCoqCONCTQ0Ed8l3cVngrc0vStT IoT/5T5Ak8CF7345A5CAzZatg8GNY09B4bOkjCgpKALc2l5+axPcFuZ2i35oQ/ChzB9Ca Z43Qq516yGoHFWvPZpgC1Qc+N39HDjAGxg+O00S+578axTUKhReimmcFatA0lBhVqkn4p XQ3fL6BUvoKak4bFx1MXEkafD47Y8DJcb7dExYwtw0ASj2PN1iONWaA+tkF9N9EVi9w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="aC+ECuF/"; arc=none smtp.remote-ip=74.125.82.176 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B93D3606A32F for ; Sat, 5 Dec 2026 10:49:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B93D3606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=aC+ECuF/ Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-38699cf08dfso2444187eec.1 for ; Sat, 05 Dec 2026 02:49:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796467772; x=1797072572; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Q3j3IPyUa5Mu4f1f1hiaUwnHqKny6qARW0n7R6KVrWU=; b=aC+ECuF/jir1JHau5MPGADBTV4IuMWyzVX6tjWM//jzcwTVBbp6y61oWMR0EcdKpp6 ZpIEprHVItYYW6L5IoJjU6E0UgQFi44YEyTQ3ULRRIvCQ5H+oqVcP1jt5Hh0kgGNfIO9 unsbrgRahFcCIs5A/7LZ1RqKk7Xfe52q/I2yhq62Y3TrRhM094kDXM8Bp1WYbBfCiM4f DLa4KEz6XhtjmfnqN+BnZEVNE3mFoyP8RZwMiiHjBDkuwwc8FfyAEOrrjtUvZDr1AJnU 63zNC+wmdNaawrvPno2YUHpySDwlpHkrM5Y5P6txOHgGbv2P1xr3LAMdHMW3Fk1nmpQB GJTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796467772; x=1797072572; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Q3j3IPyUa5Mu4f1f1hiaUwnHqKny6qARW0n7R6KVrWU=; b=wBmGi5/qRDs8aNpsD4TgbpbXYcYOVHzJs+Z+m0ex6uKVuPNxoCWTRvJ7dBE0Rf2mRf WJl92Sd91jhHJsEdOGFpFs9r83vdWemjuCgZXVH/MkMcx+3QplbyL0JteOA8BpxJWtpo +h9ZKemshd+zsA6Xyt4AFjQ2sd4+oPbfIL27rhZtkwdlYYy08Ea4hNElUjWXKPtLCRxD Ysx2J+JTkfrYTP5agSg4ZedS2mFlhRPogukPZKZmmxf5HqULB1o8AzT32qwx4ZgxWlxk vSBwF0Lfntg+FnK287PlPSm2iXGr5vwsc1peXmtjfcBnWybZ2r3+pBv+NByBTU+dbdrD AmTg== X-Forwarded-Encrypted: i=1; AL+hErE9Bop3myOeV9veThYe/P/bqdoIMXfph0JUWyTt4fEXw5VYn09luQjzQ4d1xccAG9TDc++XsWI/LwwRlBs=@vger.kernel.org X-Gm-Message-State: AB4q+uEZf9yA1HXkiE0+eoKp+vhtqrLBWBYM62BfoXrIrZrXXgXtcXM2 J1iXb47kKmcgDayd/s72W8Etwg5meO6ZtOBgZ0+F492P76bOtThFuYWw X-Gm-Gg: AZFdTZfcA/2pyXUN1cBjNRdg6abOnwyDwuJDWTgoLsayqNzhOR2hyudz13cl4Y5rD2I 4ECbzBEBLkBxMd1JGEjudC+SQpQU+Va855aGrHofnu7hRxnJsWezn6iKm5WOKf8gMiIAglr+Pvm rpLQ+8e6CM375LGJYbBuNC4C72Mv/iQfu7TrH6DS6rhDiIhpb5l5ItKAvTjhiWzeipKkCssSsmN FEc5RV4QEM6COZPkk/huFPY/bBasJDsC9h0C3nGjZvboiA2IPXbsO5lr2u+e/iMThnRAkYj7uVa iBjufhtfWpUicLdApWeBpLpRPYOFOfxFzZ6sv3sxaLpXAyiaere+yXDNHU5GbU/p7RpzVhBznRc sTiX1wErguEj3XeLCvEXwUE+a8QjpdNmQO8VCTAtGtIxxMTokAj3KFV6ViVfT0+Au6aonjqeoTB K4dprG/Fiq/mkMFdLJ4HA15r0rX6g3a+lcso8mYdsA9grZG4rEUfhtkGvyJU3qFyV7CpMfGjJGJ 3zHNm6smlC9xZySjTGeeg5+XYJjd5O37/lxQRLEL+LgX200i5Tg9sNUvWukk6DFmmsGK5wwR2hp 8bJ9aBp8BegttxkbNbkWlEzRzQ5YfHs8vZF4cfg7vkwu7e+/eUIo3sMq4lFuk4gG1NJR X-Received: by 2002:a05:7301:1a11:b0:386:9ef2:8e01 with SMTP id 5a478bee46e88-38751e585ddmr4518917eec.0.1796467771507; Sat, 05 Dec 2026 02:49:31 -0800 (PST) Received: from 6610b1a2ef46 ([203.116.140.24]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875224312fsm18005203eec.26.2026.12.05.02.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 02:49:30 -0800 (PST) From: Hang Zhengyang To: Jens Axboe Cc: Mikhail Malyshev , Felix Moessbauer , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] io_uring/io-wq: don't change the io-wq CPU mask on CPU hotplug Date: Sat, 5 Dec 2026 10:49:26 +0000 Message-ID: <20261205104926.1213768-1-hang.zhengyang1010@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The io-wq CPU hotplug callbacks set a CPU in wq->cpu_mask when it comes online and clear it when it goes offline, if the io-wq has a worker at that time. Since commit 0659e44ce739 ("io_uring/io-wq: apply the current cpuset to new workers"), that mask is the affinity registered with IORING_REGISTER_IOWQ_AFF, or all possible CPUs. So CPU hotplug changes the affinity: - A CPU that comes online is added to the registered mask. With CPUs 0-1 registered, after CPU 3 goes offline and online, a new worker has Cpus_allowed_list 0-1,3. Suspend to RAM does this to every non-boot CPU. - A CPU that goes offline while the io-wq has a worker, and comes back when it has none, is left out of the mask, registered or not. The callbacks date from when io-wq had one mask per NUMA node, started from cpumask_of_node(). The mask now starts from cpu_possible_mask and needs no update on hotplug. Remove the callbacks. Fixes: 0e03496d1967 ("io-wq: use private CPU mask") Cc: stable@vger.kernel.org # 6.6.x: 0659e44ce739: io_uring/io-wq: apply the current cpuset to new workers Cc: stable@vger.kernel.org # v6.4+ Signed-off-by: Hang Zhengyang --- On 6.6.y, this needs 0659e44ce739 first, which is in 6.6.164-rc1. 6.12.120, 6.18.66 and 7.3.7 have it. 5.15 and 6.1 still have one mask per node and need a different fix. Tested on io_uring-7.4 in a 4-CPU KVM guest: both cases above happen without the patch and not with it, and the liburing tests show no new failures. The suspend case is from reading the code. I used Claude Code to find the issue, write the patch and run the tests. I reviewed the patch. io_uring/io-wq.c | 68 ------------------------------------------------ 1 file changed, 68 deletions(-) diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c index 9609ae50dbd7..044b20be2bab 100644 --- a/io_uring/io-wq.c +++ b/io_uring/io-wq.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -125,8 +124,6 @@ struct io_wq { atomic_t worker_refs; struct completion worker_done; - struct hlist_node cpuhp_node; - struct task_struct *task; struct io_wq_acct acct[IO_WQ_ACCT_NR]; @@ -138,8 +135,6 @@ struct io_wq { cpumask_var_t cpu_mask; }; -static enum cpuhp_state io_wq_online; - struct io_cb_cancel_data { work_cancel_fn *fn; void *data; @@ -1426,12 +1421,6 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data) wq->task = get_task_struct(data->task); atomic_set(&wq->worker_refs, 1); init_completion(&wq->worker_done); - ret = cpuhp_state_add_instance_nocalls(io_wq_online, &wq->cpuhp_node); - if (ret) { - put_task_struct(wq->task); - goto err; - } - return wq; err: io_wq_put_hash(data->hash); @@ -1549,7 +1538,6 @@ static void io_wq_destroy(struct io_wq *wq) .cancel_all = true, }; - cpuhp_state_remove_instance_nocalls(io_wq_online, &wq->cpuhp_node); io_wq_cancel_pending_work(wq, &match); free_cpumask_var(wq->cpu_mask); io_wq_put_hash(wq->hash); @@ -1564,49 +1552,6 @@ void io_wq_put_and_exit(struct io_wq *wq) io_wq_destroy(wq); } -struct online_data { - unsigned int cpu; - bool online; -}; - -static bool io_wq_worker_affinity(struct io_worker *worker, void *data) -{ - struct online_data *od = data; - - if (od->online) - cpumask_set_cpu(od->cpu, worker->wq->cpu_mask); - else - cpumask_clear_cpu(od->cpu, worker->wq->cpu_mask); - return false; -} - -static int __io_wq_cpu_online(struct io_wq *wq, unsigned int cpu, bool online) -{ - struct online_data od = { - .cpu = cpu, - .online = online - }; - - rcu_read_lock(); - io_wq_for_each_worker(wq, io_wq_worker_affinity, &od); - rcu_read_unlock(); - return 0; -} - -static int io_wq_cpu_online(unsigned int cpu, struct hlist_node *node) -{ - struct io_wq *wq = hlist_entry_safe(node, struct io_wq, cpuhp_node); - - return __io_wq_cpu_online(wq, cpu, true); -} - -static int io_wq_cpu_offline(unsigned int cpu, struct hlist_node *node) -{ - struct io_wq *wq = hlist_entry_safe(node, struct io_wq, cpuhp_node); - - return __io_wq_cpu_online(wq, cpu, false); -} - int io_wq_cpu_affinity(struct io_uring_task *tctx, cpumask_var_t mask) { cpumask_var_t allowed_mask; @@ -1673,16 +1618,3 @@ int io_wq_max_workers(struct io_wq *wq, int *new_count) return 0; } - -static __init int io_wq_init(void) -{ - int ret; - - ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "io-wq/online", - io_wq_cpu_online, io_wq_cpu_offline); - if (ret < 0) - return ret; - io_wq_online = ret; - return 0; -} -subsys_initcall(io_wq_init); base-commit: 7e3dc305a86e40ce1f9cd926ecd06d339468f5cb -- 2.53.0