From patchwork Tue Nov 12 14:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 13872308 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 62ECCD42B88 for ; Tue, 12 Nov 2024 14:23:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC1168D0006; Tue, 12 Nov 2024 09:23:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D498E8D0001; Tue, 12 Nov 2024 09:23:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9ABD8D0006; Tue, 12 Nov 2024 09:23:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 984908D0001 for ; Tue, 12 Nov 2024 09:23:42 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 467FBC01E6 for ; Tue, 12 Nov 2024 14:23:42 +0000 (UTC) X-FDA: 82777659174.09.1475428 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id BCA6440021 for ; Tue, 12 Nov 2024 14:23:21 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q1O9NV5N; spf=pass (imf12.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=1731421187; 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=8naD96APlxs8kUiD4q6PDGQvlmGm/MxvS7Zm1QGRIvE=; b=4Ex+y4azsnJOm4sW9ZKjdW8Rh2gRY4vXr1wEsLwFJO/9S2ntn0UKMQW4oBaqQOA260I/Gb g4p0/s6PfEHIv1C0EWyTKFgHc0tF7p8S6YRrLHw3g674sKF7zK4ddrPN5iNDre6XT4QH91 zQTsZ/2CCamlTmqASg0SzPOetkDw0f8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q1O9NV5N; spf=pass (imf12.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731421187; a=rsa-sha256; cv=none; b=GLpah2X61MVL24ntr8zY3vtWCxOQQnnJ898juFqXbj6pEGdTD10qQ+0o8iSB8efPtWbJs4 ucBqeQwT5wGc68VfhszhQ/2oEZs22tx9Y41GZ/HJcSuhk6D5ZuVFpRw09DO3Eh8eylbFiW jq1ej+lqkf0/WFfuDAPDT1Kt+I2gv8w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 74B9E5C5640; Tue, 12 Nov 2024 14:22:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9259C4CECD; Tue, 12 Nov 2024 14:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731421419; bh=KNvMrDCkq+FkVo1LT5dQKXPLt7u3YoAjScUJDJ7bxzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q1O9NV5NBLcP9bidRunvKKRNekVsicJ56mPgrMO9TvKroDqkxtfTAUxMn23f5UqVl ZHIxRDlI7gIoJmY7caOSxYA18hbZKOC9TuKHNcfO52HrJMEK5SE3m+kL2f4ybC+KiT SlAu7sXTxUGFvRZaSTJXCZoNoMwT7Elw6A18DfiuHa+xaWDQv+EyX7jIEmOisY0vNU cUUDYMB0q26vkcQQsF/R4jOhcL2hbY5HWrBMf4SspagRSkOIurR90wuSrT3/QVDrzM VEOwjgK1adSLPK4xsiD7fgruumY9q7dn6fGogIV+O5puHjTu7iY2YMRDB4J8EB7PsD 0MDaJpt6OxGKg== 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 16/21] mm: Create/affine kswapd to its preferred node Date: Tue, 12 Nov 2024 15:22:40 +0100 Message-ID: <20241112142248.20503-17-frederic@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241112142248.20503-1-frederic@kernel.org> References: <20241112142248.20503-1-frederic@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BCA6440021 X-Stat-Signature: tnrxekhyukmn8o7cuw7dbqixa5jw8uop X-Rspam-User: X-HE-Tag: 1731421401-369508 X-HE-Meta: U2FsdGVkX1+NmbNNblc1JCcMPs6YzlugQbbCLxQBBQ4rqcRfimmh+GhiSZzX2SsGs7kgWb8XfQ9zfBtki2L70jTFgEROV1bTK2dlPWms1LBtkhlnGmIhcTBhfjwmjlvNoMpVFX3SUqHTM15eIhQ2RTJwhgHreH0OXBzA9WBcgd69hwFGZzkTwUT4kIn0H349PugwOYHXS8RSSnf7sNu67OOYhh3cgSsJS6rMfesHVofCyB1Mj3HDvkqeNe/2RflespzmFRKsvpk3CDgj06PsedUQSBKrXBct9J94vquNTHxf1CxgPXUwOyHRA65aD9xluGnyPaCZVU6psxYAzrmoiucoYWibTsX2sR3OkmwZLmTvdJ8a7Yhy/lkMLVisD3Ozmfjnrg62ABUeLBz0uEnbgQ90g5eHpyUi65E0UuRrY5ZlmXKNR+xZfTksH4JAmen9k/nIDyjOPt+04HAsZbA1cQjHcfKzbD635scf4aFbcePffJyVVHIKKgEcLrMqnBG7HmOONdhBCqQyqijoifhCvhaBxB/fyOmWkrCFxXgarulJszW+8wHt0TylCNxeXGMuWm7sh9i49qJU/MWHV95SVoNnrKP6u8OpZvrtVVDI4pPGKroxsFNCYP3p1oIzBoYryIZKejbWHGvJDAUFjwMVxxLrDDU27pjH0uK+8AyTf30kB/myR7kDFXaeNP2saJkbXA0FaDgrJnQoyj8tPo+OgLdJottj2q5R/Gv/kxcvhCFZpcexKh8hp4sH5EztOmoXZwh2iOrP4EjlDA0DYi5/cSr5H0j5CAjQvZDzUmTek2g3MSsppBxY5VWA4dbGcg+GsgiBVgJeCBf7pFZlCFDB8VBTLEagM2D54VXUG2HKwBLYlhpDZfKnSBxOLxKFJI7J1eboK85aZbFzzbjw2ahGn+EuQgIYqXXDjus/JfgIB/QYGhcpr/JMCos906BkU2+aFXHRT03SeYAY51xlTg1 Wp1ysB5m Uu65LWZSmTbSkEhYe7aeMcSIMzu96ZYzr/thM0yNRsh9NhrJuAqcLui+qdJdSCqW7VAtaYjd0kqNHysaDg5n2b6RSLTBMtoRxrhGVSuaqzxdtRilp+zYiipeAlLg6eGW1oop6WiiZ5pmAnhBXoEnlL0F6445MnCh7SGywPmycNbvHyt1VOvU4euEo+myTMMnCJs/jDg4cRhAs8qzDNRP/T9/VegPPlPFvwmyKE2ivmGZdeD9uBWjwyM+xc7YiO8X/YbZ4+mNPRWWL2FD/moY+t7XWbReWglAoj9UwnZlahjZJH9Q9dSbwOQBnBhUWQdCK6AV0UXPEsApAcew= 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 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 28ba2b06fc7d..5d7686bef51c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7168,10 +7168,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", @@ -7340,13 +7336,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);