From patchwork Mon Sep 16 22:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 13805809 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 54A24C3ABCE for ; Mon, 16 Sep 2024 22:50:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D40456B0095; Mon, 16 Sep 2024 18:50:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9FB56B0096; Mon, 16 Sep 2024 18:50:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A55946B0098; Mon, 16 Sep 2024 18:50:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7618F6B0095 for ; Mon, 16 Sep 2024 18:50:14 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EB0F6A6BDA for ; Mon, 16 Sep 2024 22:50:13 +0000 (UTC) X-FDA: 82572096306.27.6352AD2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 5A09040003 for ; Mon, 16 Sep 2024 22:50:12 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HEoC805W; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.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=1726526890; 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=k44zBR4dafRS9fG3qLeo6AW/vnkxSemRlIZbhp5LW1c=; b=aT5boImCHI0L/HE/te1gmuaYy5JeOJPyf7F+fNibTbt7ZhLboO49G7vfF4a5lfaSWHWKzP vXxVl69j/jjB1SHEKLJrTR6Fmsm3UmKqpUcI6GViwWFR0EjH27iHw6ninFLhU/K/AO/38x U+Hkpwlk/7ldlTHa975+EZm0Vfnn+qA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726526890; a=rsa-sha256; cv=none; b=jTwlgKUYtUMbyYlWdyuV13TCtwbTC13NMCwHuoh1mdjROeMCayT3Hi3/ogJ0TPh6IDNotp 07t08AOhXRchPYnMbr6x1vflmLz5RdjfUke6L0yDeNPgMqVifm+mTSjL9DoLuFvbtukdyv X5rSQPa5XJtM6XP2XldfYj74mlo4if8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HEoC805W; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E48045C021F; Mon, 16 Sep 2024 22:50:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41614C4CECF; Mon, 16 Sep 2024 22:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726527011; bh=G//HPzoeqfpZXKC5DLATLC3AcQAMDmNkHz7pJ7brv/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HEoC805WXjqBDwxV7eq88XdBPgl/1Aao31aSAp9FLezKIHwvZEL3AKGDJ2vy2zjPT lu51to/xU4m9d8gbzURHBNR24ECfrEl6uPBmhAJ8jiIDQK6w9NuMBoL94o6vkxVAyZ a3Ik8JPEZ2YjOM7fC6rW1Gn27PvEH20ANr9DG/djdGmNPpSkgU262JHq4F476uw6zI 5nzOvJiviekib1ZPhByMT/8Kfz2tOlRfJQSIl62ae/YQ+wohPmqzbee9Ih/c8ihaAI MFXNtAjBEI29GG7vYZEbn4d0evySHTlPDGNYaPXXUry2Ey1hQBT+GWGyp3fI29MXYm KYkRAwyfS2m2Q== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Michal Hocko , Vlastimil Babka , linux-mm@kvack.org, Andrew Morton , Peter Zijlstra , Thomas Gleixner Subject: [PATCH 14/19] mm: Create/affine kswapd to its preferred node Date: Tue, 17 Sep 2024 00:49:18 +0200 Message-ID: <20240916224925.20540-15-frederic@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240916224925.20540-1-frederic@kernel.org> References: <20240916224925.20540-1-frederic@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5A09040003 X-Stat-Signature: rwydiy5ftkmra9u6xfu6nxrhutzarsfq X-Rspam-User: X-HE-Tag: 1726527012-172937 X-HE-Meta: U2FsdGVkX1/gVwy4ibIxeuWE6KkQuQJAe68tMmXlOuNdELihX7x/iKXmiSXMa7ddDnPoS8CLYOJ8wWOQ5vgmrqgWOR5elaUpTivPxWVAKQ4k4ycn0vGbm03t1KihUwg5xp6kZGZlDWEEQGANpQxfoeOdrJnR/+zHuOIXHO+hvcblG2vhmYZQzLAgUvEumqvWFEwpPmpYXLWi0Tv3l8Pem+GEkYgj6d8ezKfNHNHi2+EtEIgxwhxLjUvQv4mjFuh/CcrdNZjAIhJAzfXtzAzHk+blhUSJRPwiZdgHeVByHTImRZM9l01/YVPLjDFHL96gFzQ4+e/kx8WymxRgJnawskr3n5zoqsTzJOJAa95RQugv+bXDL8cyY9L51PXumvWD0AWR6LB1G9euUotd/3PmAfTYombTfuU/lJfQ20GoiJxwvqZww/KEB6WH89x/j4pZ3vs/0yRJT4WQxwtFxe24bkx/1dUFcZwrfJ4D9lwiAWXX/96MCOfSRni2ofHlaciqUt0j7HMfwVvDgLTeFXhkT4bAGr/9Fveyy6z6y51AXDF02R9JX/iLa5N/5C5Hv5/FWC4R/UNIgjvHKXSWj5S1qRc+uCtjPSYZxbYA9TP6DE/D4S18Z4N7b1MuT0GCx4vdr6/BqKDffi8Sm7o2EsCQv2qnAV8OY/2fQKq15nLwZOqes8rWaMJL0khr4umO0+w/fHvb7GZyCEs4rGhsjRT8FqerpwJAD8BMLlbVBjkfzU039AnWyR4z06ICC8Z+XROKqA8Pkd4n+0uzwVbXk3iKpr45G+5xADYz65oKWR7t7mZGKki/FIN/XU7DY+QHHNNFhwh1WG1T3h6f4RrdmdWdQw2jVSavrwXvsUjJnDLY2J+Y0jHrzanV61z7zeZg9q9/L596G4kPsJESyIC7/t49XR4MbRuCUqBrXh1PqvH7ZcPlV/jJPWOh+n0DW1pDcUrMv3zygoC/XRE8YAGRbQI n3EXlu5a 4wjLoP7Gq8E7d0EUPJCuas/nFewU/0eHPvIy/aPdhSY4n/NgAz0Nwx8clJ97PnNAj2vuPtVfw9MeKVrvbhrNtKylpYEjGiK/Z2J/h1lLe7ZspMcGtXSJChouzljevcN7g+rDyG3J0j4kEFLsYOM3Lbv4CdNQzCEVeGORUUGbhUTm7gUeTF3xJyWcXE7f5G5WOjwN307oNBtVsOd5fsuz8FWD1IvVuHoH6FvI8aB1bt+ghQXlUZ7pbWC10nb/d6AmXROy1iMLepdAC9ro= 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: 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 Signed-off-by: Frederic Weisbecker Acked-by: Michal Hocko --- mm/vmscan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index bd489c1af228..00a7f1e92447 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7139,10 +7139,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", @@ -7311,13 +7307,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);