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 08604C3DA7F for ; Mon, 5 Aug 2024 16:23:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 671416B00B1; Mon, 5 Aug 2024 12:23:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6213F6B00B2; Mon, 5 Aug 2024 12:23:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E8F36B00B3; Mon, 5 Aug 2024 12:23:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2F52E6B00B1 for ; Mon, 5 Aug 2024 12:23:53 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A0322803AB for ; Mon, 5 Aug 2024 16:23:52 +0000 (UTC) X-FDA: 82418713104.28.FAC57F7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id E9591140005 for ; Mon, 5 Aug 2024 16:23:50 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=n6cGXl8q; spf=pass (imf26.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722875023; 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=UhIKQfekkVDMXnw3g9/KW30zg1OnVeN9wGnY8PgscYY=; b=wKzCNCmHlhsTks04oEuRGvP1Qk11sKg/gz+jFamS0G0O2eOKorjMEAGmvyl1j0jZB/2k3V R/8W6OaG0FU7zzPe3KN+Ce/RppUlLJcw+4DWljeE1g1pDW6u//t+zJ2xqs1qUkwvYPYM4s Y8mVWfJkSMh3iyaTtWxvNVZHnPxJr8I= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=n6cGXl8q; spf=pass (imf26.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722875023; a=rsa-sha256; cv=none; b=4WDrF0ZsfNq6hIi7Gog+xVxMezNSLdA7nbVCYMx6noEzRXzaOszYFYopOPDMf3E5tiqz4v 0J+wQQUL0nUNL/ArTJRN3nWP4SGoHT3y0bJdTdRL0iK4kErQriwGf9AYlMTDKaVEZT1yp+ uOvYRwf5qJro7tD2ZkLRsOS/inl+JaQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C6A1460D27; Mon, 5 Aug 2024 16:23:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01B73C32782; Mon, 5 Aug 2024 16:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722875029; bh=vQwii10q1YmYVa9isa85ZRO5B5Git5ym+CsLyg9wPCg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n6cGXl8qOQQhSq+jW2IBk/kplIW+fRTvFlWp6o+SBfIL2VJptogBiJ+XvRrpuKwT0 GlbCJ+orj+Vb5bEHt/SsqajQScJEvGKTXECUILf7Oxi5mMtAabmC7FGm5bvxszQaiL HM7+xD7MYfMzTE+6/doHINDIXZ2pp+oPJPJVcdaT2enx5tyFnmCxfdQ9j7xtVqc4ko 7pEcN2ZSBt6RTQiu6RC0pC9Ar78AXW5SMHPimiLxi52mAK7PUXT0Vbdn2a0zyqI3MO 8nu1l7TyxVMpebsZvrg5+r59ITowKh5mEIo/Qk2ulq57sESO2iR3XWaVbrfCK8IucX h9TUGXXeVoOlw== Date: Mon, 5 Aug 2024 18:23:46 +0200 From: Frederic Weisbecker To: Vlastimil Babka Cc: LKML , Andrew Morton , Kees Cook , Peter Zijlstra , Thomas Gleixner , Michal Hocko , linux-mm@kvack.org, "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Boqun Feng , Zqiang , rcu@vger.kernel.org Subject: Re: [RFC PATCH 12/20] kthread: Implement preferred affinity Message-ID: References: <20240726215701.19459-1-frederic@kernel.org> <20240726215701.19459-13-frederic@kernel.org> <4e9d1f6d-9cd8-493c-9440-b46a99f1c8af@suse.cz> <00914d25-f0ae-4b00-9608-2457821c071c@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <00914d25-f0ae-4b00-9608-2457821c071c@suse.cz> X-Rspam-User: X-Stat-Signature: nzcezgdswfrwjwps9a49tc8rkfogndhn X-Rspamd-Queue-Id: E9591140005 X-Rspamd-Server: rspam11 X-HE-Tag: 1722875030-308106 X-HE-Meta: U2FsdGVkX19MhbULLW3qGwW563RbZ53UIoCzjG1sQFBgXO1XkLMjz8B8f19gyQp+3m1wQD8HEej+VkG3wpkeyNsNErzt1J925GhY4DYEQQx9+vDhs5dIq8pYq8LRz2XuzNbNKm0v0NTrAJrmHUa6iibewsigNMH+JQbOFXbo6SNgKdAccKbN7C3yzDtV3xp1h8f9gHIUbKwQsVyu1DI9GROk0L1+8cxf3U1cv17AJpAKcKC59W0qgKTJfTtRuMHdl4Y0mEw27I8ltc/V7qKKVdntr6giJlcYiRgefpTJc+dPm3Zc8krXiKFLaKgjADkrDJRfWRsRu7gjp+G01T2kASZH077nIV7QvgByM2ivyeoO2TsMTqysmIzaeGKNICsLfhPzuvvIVxwaDlBMRI/GQze9/yzFYEdfkWiIKwHs1Lx6Sv4cExbVlaeRY0O3mXSuA2/L7aO4dpxgViTwR6lS5lz4wKehRa6H9LW5beQNXvG0QCkwH5I5nOKy+wQNLSaEa/dhkXRQRfrCnRCCWqMqoVNjaRKe2stUCoUhF/IRl1m1B+MYdXkce+AzNV9RoVQ7qYe6K46OLIN7h3U6R4JzgssD3gU1N5CXgLwOEa4rfVGeYj/e1nr97iLhRogYIDaJJalzQBKhXH9tTH+8dt2RmmpCsmUzmLoP6Hj91WugR0Wpv30EySnSiiol7tufYHuGMiw+T4t7rEhQVttskPlWcIVEhlXMcXE/W1jAiUlsTqBUgfJMzc/s8k6Ra1efj3l9uScqw38tWS3EDx6uq6bYVMrBQAGqfmgHAR9wOMq+A6zKXKDmaFoGQAakJphJXO1FFct49N8W+QCm6y1IehoOnjk3iDhnNb8HR2dxAfmqMuzb8kXq12x2YtC7Vk2wy2IOk7aVDA1cIHQRzi53BMfCRU2Y7Ff3T2/882Y4DJ/LDMJH2P/w52bFRBX8FfNaaFivbQ0HG9qFFSkOr3jnw5j hEMfKctL U5J8Nlppd7WPmXFU8ESLxoxftrcdJVaoeFRR02Ce/KRzIJk8sMNLlO5ZrSs8R0r9M2IKR6VG6dOmcicvJdw+bsaRBhs1hahIPbw4yoNFjnGV4bpCgExoB04ROlgqBrwJhjJ0X0t6faQqXbypRUPWsUEy31+43ahPEOGvzsUwDpWSNHbiiJc7PFW6tFriCw5hn2StCDimhseY55MG1q+ymhYXi7GgmJ4podcowmOxseZy7ZvMgzTklmiQ/DNIUf8cuMIlxTgVMdmY9tDzNV4bMt99BVA== 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: Le Mon, Aug 05, 2024 at 04:53:51PM +0200, Vlastimil Babka a écrit : > If you mean the loop in kcompactd_init() then indeed, but we also have a > hook in online_pages() to start new threads on newly onlined nodes, so > that's not a problem. > > The problem (I think) I see is cpumask_of_node(pgdat->node_id) is a snapshot > of cpus running on the NUMA node the time, and is never updated later as new > cpus might be brought up. Oh I see now... > > kcompactd_cpu_online() does try to update that when cpus are onlined (in a > clumsy way), there was nothing like that for kswapd and after your series > this update is also removed for kcompactd. Ok... > > > If all users of preferred affinity were to use NUMA nodes, it could be > > a good idea to do a flavour of kernel/smpboot.c which would handle > > per-node kthreads instead of per-cpu kthreads. I initially thought > > about that. It would have handled all the lifecycle of those kthreads, > > including creation, against hotplug. Unfortunately RCU doesn't rely on > > per-NUMA nodes but rather use its own tree. > > > > If there be more users of real per NUMA nodes kthreads than kswapd and > > kcompactd, of course that would be much worth considering. > > Yeah it's not that compelling, but a way to update the preferred affine mask > in response to cpu hotplug events, that kswapd and kcompactd could use, > would be sufficient. And maybe more widely useful. > > I guess there could be a callback defined for kthread to provide a new > preferred_affinity, that you'd call from kthreads_hotplug_update() ? > And kcompactd and kswapd could both use the same callback that interprets > kthread_data() as pgdat and fetches a new cpumask of it? It's too bad we don't have a way to have a cpumask_possible_of_node(). I've looked into the guts of numa but that doesn't look easy to do. Or there could be kthread_set_preferred_node()... ? Thanks. > > > Thanks. >