From patchwork Fri Jul 26 21:56:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 13743194 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 CDB0CC3DA4A for ; Fri, 26 Jul 2024 21:57:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EDE46B0096; Fri, 26 Jul 2024 17:57:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64CE16B0098; Fri, 26 Jul 2024 17:57:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A3696B0099; Fri, 26 Jul 2024 17:57:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 262E46B0096 for ; Fri, 26 Jul 2024 17:57:50 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D62D4C0169 for ; Fri, 26 Jul 2024 21:57:49 +0000 (UTC) X-FDA: 82383266658.27.1E459B5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id CE2A51A001C for ; Fri, 26 Jul 2024 21:57:47 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iqgrHSmz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of frederic@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=frederic@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722031027; a=rsa-sha256; cv=none; b=sHDT2dmo/9FWR+DowAjjce9/VeR5QVLeLG0Ef9zwT+wMlbK+OG3eGV498RX4SaPZbN+J79 Iq9vvbQ2RDsJYoC0Yjx5KadxtIfSHfIajqlO2VLjjoaRYg689Ike32+hzn7LBk2cEPJH5N Wc1D5JAh622g0pnDcnxCx31UzqPWR64= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iqgrHSmz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of frederic@kernel.org designates 145.40.73.55 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=1722031027; 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=2plyUun0w48eTm1VlsywmP9butfRi8OOoMDte60dZ3Q=; b=aJSqwXsc22daCUfFXiPg/wwBO6qQUPkqpnfqgErJDfGc0/1iI0ridycaDPlrJaxXgFd6Zt E/XViTFrk/gatjDTa+APGJEQ+KTSlv/om+YzMa6GDC/Ox1Ks70JGmv4RNTyK8Lr/M4mDVv kGrJPrPqttOx22eY7ixBFFQSbV+iDe4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 48A12CE1940; Fri, 26 Jul 2024 21:57:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2B33C32782; Fri, 26 Jul 2024 21:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722031064; bh=gPMXvX+GlymTegeJ33I/1BOjjt7hvEufmzbmhRPnpxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqgrHSmz8YA7EVyJFrBUszMUuoULJREzG0WmIVQaPwZgshXH9zPEIRF+Y8MrjnWkM Zt3wRLuZMuDHLaUl7mHZVZJJebIAnhF3ewfY12xrp+pMS3rOrGHuwiCIrXgDtdgbpo fqrvDWzHarZ5T4rMmD8B0dQWcCrjj7zT4ofXxfLUT1/BcPwCJnP2kMJVcshvr4xbwW xdMDv2GNTaRv6yTwhplpRpErKEak9nfL5A3iL7FO8eM/NlgFldnD6GIsJ4MQTFVPMn svskNbqqQ3C0B6v8p/pu/8VrsrkvDTA2qxa0iiKGjB9B0mJJXmZ3Z1wJndxKQW2vdE GB5zT8LjtgUBg== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Michal Hocko , Vlastimil Babka , linux-mm@kvack.org, Andrew Morton , Peter Zijlstra , Thomas Gleixner Subject: [RFC PATCH 15/20] mm: Make kswapd use kthread's preferred affinity Date: Fri, 26 Jul 2024 23:56:51 +0200 Message-ID: <20240726215701.19459-16-frederic@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726215701.19459-1-frederic@kernel.org> References: <20240726215701.19459-1-frederic@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CE2A51A001C X-Stat-Signature: 1a161cxaw8jfh43p69fkou8sks77yrik X-Rspam-User: X-HE-Tag: 1722031067-472832 X-HE-Meta: U2FsdGVkX18UxjCABxjP+tFJbfvD8np6VKalCGS7LKAF10iQf+00LxphUJT8J5f1gx5M8vdxQJK6IjsbY7AEIjMXE8B9zaNAk95kmwknaNZtScxFydik8aBUoIVa54edjOG1nfBOv6HDrc/JS/zshOcqoBlRw4jiOOHQO17hOMx1+H4UjE2tpUwAl2JMjdh5lmxEDyFdBZyF+1P0YPewvX5by33vyOlIhHhsvYbzflo4DDfQMithDTag504cwdmmzGQcPImuMIzkFvfUM5QSDKiJqFOXZ5d7xsFsYwzXIygmw3ybdmfr7M8BtLlBnIKpH2zRkMPhwAK+GyMZnZOAFgADgjF/mxCmoyZBKu6MpkXPMyQRHii9CgDYsZ+sgsLE6kQIwBVBlukWoTkudxMFw5X12fZx+TN6RW7T3pMv0ee8EpCuA8FfpipmxxsQr8NbWeQbU9X7UzaqdGaKqNH0Ot9Eswfdh9Ppm3Iimo+a+L4cbaFQrKhX9+xWGpb/PfoKE3smeH3Cv1UPHowmp/c4s9LBJ/yHtLKhtbar0zBaWekeqjEqJMqkf1lNMQ6l2At1ave2748f3mIWrKJWNWSIPSsGiG+/0+j1qeZQYLiX0d56yYB2yeok5abfoU+WHXn/CUkkiVsTdjz/1TmgqfiBzJMX/lVMCI8N4aXlD6PTJBflBA8h5TziqMWwE/SCz1lGqVE1VQgKV3g74ldsj4yBu8zCXEINq14eZbi8ZlVUbplBl3LGhH8yIx1RNxTpHe4XT9bnMEJZRhnQkPzWMmHQZn6n3FDG8/J5hUgrFZdv2Ps+APIxTprjGS/fJ5aFqh+VCePzAgyWVowGjBoF3HK0pSvay1dRMpycC8qKNaRiqQpfJPiYFYegIUFg6rWHYD1KVfXeQfa+pxUJIA7A0yM+U4xX9tLeeWIZiVsECMO6qvts4iTRaJzbmosvmHkSYKUz7+cZeiS57fjvKVydL/D gieSVavM daCeswrLibvgkwb8S6rQcoryTg36yO4vE1Wdi9FBXILnvmZSWHH19iOSCZ+DRJQ7Qd+QpvYUwjCbTWQTvyn2K1EKVNg+12VQBcO559yRknAqJYyKexhrrTp0iygBbu3jQHPttRZjsm6hLqH755t7rKEqorA//lUjmGGC/Q/0AxRStcS2HcD/grq919VpxYNAX4jGVgITnewoP52VRtRkeX0F2fo2qFl154g4GLt0WGrQp7KWSbaCa4jg+26wUFsZ75hztuPEGOCNQyzc= 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: Now that kthreads have an infrastructure to handle preferred affinity against CPU hotplug and housekeeping cpumask, convert kswapd to use it instead of handling halfway all the constraints by itself. Signed-off-by: Frederic Weisbecker Acked-by: Vlastimil Babka --- mm/vmscan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 2e34de9cd0d4..94359a893b4f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7116,10 +7116,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", @@ -7288,7 +7284,7 @@ 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(kswapd, pgdat, "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", @@ -7296,6 +7292,8 @@ void __meminit kswapd_run(int nid) BUG_ON(system_state < SYSTEM_RUNNING); pgdat->kswapd = NULL; } + kthread_affine_preferred(pgdat->kswapd, cpumask_of_node(pgdat->node_id)); + wake_up_process(pgdat->kswapd); } pgdat_kswapd_unlock(pgdat); }