From patchwork Wed Dec 11 15:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 13903665 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 5D603E77182 for ; Wed, 11 Dec 2024 15:41:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCCAC6B009A; Wed, 11 Dec 2024 10:41:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D79566B009B; Wed, 11 Dec 2024 10:41:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCCAD6B009C; Wed, 11 Dec 2024 10:41:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 92D6B6B009A for ; Wed, 11 Dec 2024 10:41:21 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 47DF2121240 for ; Wed, 11 Dec 2024 15:41:21 +0000 (UTC) X-FDA: 82883091480.13.3E0347B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 2F6E51C0016 for ; Wed, 11 Dec 2024 15:40:34 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U9WYCmgx; spf=pass (imf21.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733931655; 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=nqutTAx9KQqgBFO04UaNAUPs+5hccDbER7OZr21LVo8=; b=HXVaTGKsWtFT3qjLo+QDi0B+J8LBQa2GShvR6pDY7vg5UY/qooOlRWHjKj3Bmpzl2RQm5d aV4vYX5selIVGnM2hs7akw3NniSEVyqzWASzyDr6VK1X5QHtEKHgkNFZ8A+VnFKjsXfT+P QQroDTPIDqH7H9XZC0bdwIytLrIx3F4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733931655; a=rsa-sha256; cv=none; b=QYnSgWHdqNCVacetVhzX/LG8KJzguSCj8BWCwgqOpOmRLu5WaoHC2fblw9k0TnyJng88gw t4WgdHQnuT+CiUWWqqWn+YbTj/iOdMfqGZG9f5/3I6b3yaXsQWKT48XgyVd4QudHwLHc7v /TzVduG+1Inf4hYLMEFWOHaFFL4/8v8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U9WYCmgx; spf=pass (imf21.hostedemail.com: domain of frederic@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=frederic@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1071F5C62D3; Wed, 11 Dec 2024 15:40:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70927C4CED7; Wed, 11 Dec 2024 15:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733931678; bh=suTQZYxIg8YKQDgrkF/Nr6nKfzRdV+Dy0JZZ2b4bJTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U9WYCmgxo2g6VtQBPGF75toF0DAsYCTyprqdP4MP/NL2WIApZWX+8uC1qH9sQ1YFW v0y/ucaUndq8W/x+f1Q4cgbUtSg4zxiTNL7bcU+OEexhm+aII2nwqmXKZhl5fuWft/ oYJSOk3J2Vbvtq40KV4FImTLyFDGnLoTw64Bsu7uP2mqgYs/QG5SrvAfDzx0EOw8Uo GwE42btpRiL/wjR3Iob8c8NqKwooftte+J87DnPtcu9yEJxo7/ta3eqkvxkBV2MG+S 745vWEMlgyYxNhaKejN77vOr5PpisfcJz8TCIyRhlGVTtyiMzo/gUbSXP2/GBZWb1g zwFw/D33ikaZQ== 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 14/19] mm: Create/affine kswapd to its preferred node Date: Wed, 11 Dec 2024 16:40:27 +0100 Message-ID: <20241211154035.75565-15-frederic@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241211154035.75565-1-frederic@kernel.org> References: <20241211154035.75565-1-frederic@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2F6E51C0016 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: es8st5ee63gawn7yrknq8fykou4feu1k X-HE-Tag: 1733931634-844103 X-HE-Meta: U2FsdGVkX1/HUdHwM66YRO0/oZaNDjCFR0YmzGwf7+DjALeMqN5XHa0kQqObsRZdI2d/53UeKz12I16tH2kHDqY4TQaMDZ3x5jX5yYUa6SElxBQKxA5nMIEksPt0uN4OpjNU7Q4YKW3muLmS8WGoktnRpmXARbvXJfsl4AVgEPg5Q5DpBi+ku8dgvoKUKk0/5IUf/CX7JQ3BUljgEUvOeoC788gxAHRselGj+UbMKItU3/mZIHjklN5FSlbKF7NaPcfpQHrgCtin5cQ1wATwrFi8wEKfG9TAljHMXfjFvIrtJyj4ZFUEE+/Yldbiu92NBwbEPY6D3KizFzU4g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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 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 76378bc257e3..ec4eab23fb19 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7182,10 +7182,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", @@ -7354,13 +7350,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);