From patchwork Thu Sep 26 22:49:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 13813710 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 EEC2ACCFA17 for ; Thu, 26 Sep 2024 22:49:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA9B56B009F; Thu, 26 Sep 2024 18:49:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBDE86B00A1; Thu, 26 Sep 2024 18:49:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B81586B00A2; Thu, 26 Sep 2024 18:49:56 -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 9741A6B009F for ; Thu, 26 Sep 2024 18:49:56 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3022F120337 for ; Thu, 26 Sep 2024 22:49:56 +0000 (UTC) X-FDA: 82608383592.06.C335850 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 8CC00140014 for ; Thu, 26 Sep 2024 22:49:54 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="qPdT/czz"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727390895; a=rsa-sha256; cv=none; b=5jzZU5Kso7YxadNT1aTK+a9kugJjP9NOywkVwxMItwhjcDur2XGr+Xmc2saMLgeLqYfH3I 5SA3abiFlAtiY9ZXAD5TVZ1MpUW8f2dU3JtC2CCoD6kEUndg4/hgzlYdqUa2IyQQWc83cM tjeBvoLPjOcO3JgSqX8ZpxZXZ4SDujg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="qPdT/czz"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727390895; 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=CmttsLVxdQAGPqv4EyY4vbYE12QAnLoDFwzJoqQT6E4=; b=F0NRcos1G8S/6quEfloCYAIw84jKjiKNndeNA35oaA3zY4yFv5oWSayWwDrVfiRTgGPqNx tFerbMWJ83Uh7bi1p+ApUaQJ5kkR29y0+8g+S3BjcABUJ3kvkw7rqkQFLhY72eAXJRq8r0 O2eupG//91omonDjLi6GglzkySIpcoY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C7D125C5696; Thu, 26 Sep 2024 22:49:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85329C4CECE; Thu, 26 Sep 2024 22:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727390993; bh=GGwHDTPCelnTuLQKmOHE+XEiEGRzn3nDzNLPlrg5wLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qPdT/czzAUkVt9taXAsYs8HYqiPAzFsD1PahFMGeLLa7p2XkOjqAGBmtuWIxHHZzI L73JueO4kixmDYeWu4a8O6Hn0pH8EOVcPCTshEGMwt/hCvhT5sU0By3wHdlwzQxZeg iJQwSFGkPH8DB3lu63k2EugRuJGZ1VPzYDgoxy+UIi4yJzBy0vF7kxHNXBsdPjwhgf kgXfavf0yn90bg42dxvHuz0QrUskQDnr4er73zhZEdFiHbE93hnfsomY8jIU0clpCq dnEuS0e4bCA/Mg/ntuju71is5DUonzaMun23oaFLmCDFNQiEx7M05CYRWIWd2qVizV vL26k62znYIuQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Michal Hocko , Vlastimil Babka , linux-mm@kvack.org, Andrew Morton , Peter Zijlstra , Thomas Gleixner , Michal Hocko Subject: [PATCH 15/20] mm: Create/affine kswapd to its preferred node Date: Fri, 27 Sep 2024 00:49:03 +0200 Message-ID: <20240926224910.11106-16-frederic@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240926224910.11106-1-frederic@kernel.org> References: <20240926224910.11106-1-frederic@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8CC00140014 X-Stat-Signature: 51371xu4oijkshxud4xrp7up4wj9yjho X-Rspam-User: X-HE-Tag: 1727390994-652802 X-HE-Meta: U2FsdGVkX1/8tApfTHDLrzLVUN3Hki/vWDJDdyIJZQ8AnVDX5i6QLq+dsxJg3Zt2vqx2pK+B2w+U3sKTX5iOBP9deqaf2QsE7YiPhitCnLWKEmHqZQ2sn6A23TMqUMEuJHVQRF9xmiTU5zjqidlH8hmSSDuBs8lI3LphddrM4ITzIA63NiogQwBKaboXZCnJhk3F0jje2SvNjK+M/1vyvRzdSEJFHCFTEYb4JqtJHQaCYYMNK822BuzGHSSHn+mB8xZbWxKrpLSC5eXSBI1W97SdZCN1RngFdFcjbAZGbAjH+3rt1ddWL5CdCpnpRJJregpKhP2Rp0L6AzdOKx+KZQYcndw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kvack.org List-ID: List-Subscribe: List-Unsubscribe: kswapd is dedicated to a specific node. As such it wants to be preferrably affine to it, memory and CPUs-wise. Use the proper kthread API to achieve that. As a bonus it takes care of CPU-hotplug events and CPU-isolation on its behalf. Acked-by: Vlastimil Babka Acked-by: Michal Hocko Signed-off-by: Frederic Weisbecker --- mm/vmscan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 749cdc110c74..2f2b75536d9c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7162,10 +7162,6 @@ static int kswapd(void *p) unsigned int highest_zoneidx = MAX_NR_ZONES - 1; pg_data_t *pgdat = (pg_data_t *)p; struct task_struct *tsk = current; - const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); - - if (!cpumask_empty(cpumask)) - set_cpus_allowed_ptr(tsk, cpumask); /* * Tell the memory management that we're a "memory allocator", @@ -7334,13 +7330,15 @@ void __meminit kswapd_run(int nid) pgdat_kswapd_lock(pgdat); if (!pgdat->kswapd) { - pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid); + pgdat->kswapd = kthread_create_on_node(kswapd, pgdat, nid, "kswapd%d", nid); if (IS_ERR(pgdat->kswapd)) { /* failure at boot is fatal */ pr_err("Failed to start kswapd on node %d,ret=%ld\n", nid, PTR_ERR(pgdat->kswapd)); BUG_ON(system_state < SYSTEM_RUNNING); pgdat->kswapd = NULL; + } else { + wake_up_process(pgdat->kswapd); } } pgdat_kswapd_unlock(pgdat);