From patchwork Sat Apr 16 05:38:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12815683 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 C6392C433F5 for ; Sat, 16 Apr 2022 05:39:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 698286B0073; Sat, 16 Apr 2022 01:39:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6487C6B0074; Sat, 16 Apr 2022 01:39:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 473756B0075; Sat, 16 Apr 2022 01:39:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 3AB466B0073 for ; Sat, 16 Apr 2022 01:39:10 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E24C4A62FD for ; Sat, 16 Apr 2022 05:39:09 +0000 (UTC) X-FDA: 79361638818.30.2F3086C Received: from cyan.elm.relay.mailchannels.net (cyan.elm.relay.mailchannels.net [23.83.212.47]) by imf31.hostedemail.com (Postfix) with ESMTP id 2DA8E20003 for ; Sat, 16 Apr 2022 05:39:08 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id D48B480877; Sat, 16 Apr 2022 05:39:07 +0000 (UTC) Received: from pdx1-sub0-mail-a254.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3A30A8081C; Sat, 16 Apr 2022 05:39:07 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1650087547; a=rsa-sha256; cv=none; b=cGRLvoSTg+bqcskZ3kmeLRHpaP4ZS+CX1ePnaDZt9BUVFOeU2R3uIhN2HdwoLcBqocv6yN PpG67ZZwEHom5CANZ5RKBzOW+Yk5zglgBbn87yleZcD06UTp/LEbooGgNd03Ao97O62Bm0 yl5WRVFUnvtHRDYjiFQtaifEObBlmzb7n8ki6ZB5BRhG/mWPr+IkFqD/sS4QPsdtFrlPHI qfOvCTXUkPT4oZztirSUkHx0Az2WbCwZViQE+Km+PCnoDzSqwSohNieZ7Pw0PZ1xvTFhje 6eqqadD8C6PGPlI94945pZep8aoSTSmnYNmr0hoUuqjebtJtQmKPuWEM8R9khw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1650087547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6i5ewlPlZcpl0U53ReVtxqDV6akyDEkpkhvA2ApaQDM=; b=RcKea6IbTdk+/u3AVWCe5VLH/E2+psKqcpcBIcFipQ1LSQG/k+EqAXd3kQGLiFPVHVbA9N Mruhd7Er5TDPBPP+RV3JuZxGjP3KmP+c2rfSExypN1KiOEhw2M1/SBwnrcsBWjF0+v+nJr MNU5plebEvUvB8xSkpGk8soSNsr7zqemwQrcC/bSoD1ra7d4C8qNbK5t2jI07sF9U/mIeo sLO88WXkkYoCNJhAHSS22v3Bw4zkKf48eU2pxzEMwcjOwx3GJRnU9WwtAc+lV5NPVbgMZZ Q7QM1jvZs6/AxszTuQWHXS+j+xKzsEQFtN+s28spPgJszFNfdbDZj+KgEHUJZA== ARC-Authentication-Results: i=1; rspamd-b69d6888c-k22hh; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a254.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.125.123.25 (trex/6.7.1); Sat, 16 Apr 2022 05:39:07 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Trail-Eight: 702c94657123f1e4_1650087547719_2608661820 X-MC-Loop-Signature: 1650087547719:1342454741 X-MC-Ingress-Time: 1650087547719 Received: from localhost.localdomain (unknown [104.36.29.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a254.dreamhost.com (Postfix) with ESMTPSA id 4KgMSn6r2Rz2x; Fri, 15 Apr 2022 22:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1650087546; bh=6i5ewlPlZcpl0U53ReVtxqDV6akyDEkpkhvA2ApaQDM=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=AjdzWRn8Jfh8MVjXZjilJ+tQi0Xt6YBrmAL/Y6diDSVFVfobB+o/NlRj7JWsu+66Y qcdR9F4+GtPHmZ+JvH2JFyJoP0CLPcYZpB3h+J4z6Pj2b1R26Wzg+0hU7cbHIzgpHd cFOn1RG9ziICZLhz1FaF92ex7wLWEjwmc4WuwAC8K5WdjrzipVqMYYbZ1cwnuMJO34 0opMS0YlDqa45fWbNSJesrC4WSF4N7jMFmBQ2so2qxy+k87sOz+Z6kAfyj7u/NpgOw u+3YMKo0UuNZeBMdWXpqNEndn8DPUf14ZMlSvcF1u95/NQ+JWTX1Xnh5tOP+2g0WaC KLEr4tGPZnXPQ== From: Davidlohr Bueso To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, dave@stgolabs.net, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] drivers/base/node: cleanup register_node() Date: Fri, 15 Apr 2022 22:38:57 -0700 Message-Id: <20220416053902.68517-2-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220416053902.68517-1-dave@stgolabs.net> References: <20220416053902.68517-1-dave@stgolabs.net> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2DA8E20003 X-Stat-Signature: 6kfxrqfd7h9hcju5odoq7zuzbou74c8f Authentication-Results: imf31.hostedemail.com; dkim=fail ("body hash did not verify") header.d=stgolabs.net header.s=dreamhost header.b=AjdzWRn8; spf=pass (imf31.hostedemail.com: domain of dave@stgolabs.net designates 23.83.212.47 as permitted sender) smtp.mailfrom=dave@stgolabs.net; dmarc=none X-HE-Tag: 1650087548-338564 X-Bogosity: Ham, tests=bogofilter, spamicity=0.309507, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Trivially get rid of some unnecessary indentation. Signed-off-by: Davidlohr Bueso Reviewed-by: David Hildenbrand Acked-by: David Rientjes --- drivers/base/node.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index ec8bb24a5a22..6cdf25fd26c3 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -661,16 +661,16 @@ static int register_node(struct node *node, int num) node->dev.bus = &node_subsys; node->dev.release = node_device_release; node->dev.groups = node_dev_groups; - error = device_register(&node->dev); - if (error) + error = device_register(&node->dev); + if (error) { put_device(&node->dev); - else { - hugetlb_register_node(node); - - compaction_register_node(node); + return error; } - return error; + + hugetlb_register_node(node); + compaction_register_node(node); + return 0; } /** From patchwork Sat Apr 16 05:38:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12815684 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 CD3A9C433F5 for ; Sat, 16 Apr 2022 05:39:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2C986B0074; Sat, 16 Apr 2022 01:39:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB5BC6B0075; Sat, 16 Apr 2022 01:39:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92FFE6B0078; Sat, 16 Apr 2022 01:39:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 830776B0074 for ; Sat, 16 Apr 2022 01:39:11 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4D28423D2B for ; Sat, 16 Apr 2022 05:39:11 +0000 (UTC) X-FDA: 79361638902.12.5E86870 Received: from hedgehog.birch.relay.mailchannels.net (hedgehog.birch.relay.mailchannels.net [23.83.209.81]) by imf03.hostedemail.com (Postfix) with ESMTP id 8D3BC20005 for ; Sat, 16 Apr 2022 05:39:10 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 4D9C38E0866; Sat, 16 Apr 2022 05:39:09 +0000 (UTC) Received: from pdx1-sub0-mail-a254.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 6B1788E0A2D; Sat, 16 Apr 2022 05:39:08 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1650087548; a=rsa-sha256; cv=none; b=MEnOUgboGU+pBdhHmAjrwm1t+GnuY96RET8wgcs1uybtAGqFOhFf0px7NXjmiMKxcVEo6B 6ssfrCv1r4KNEJ1fVI8lDgtAz2ulcmRAYfTjxG2K5FV0pLS00sbBwA9WdczoXsYwicohhl itzmbz+69dYviPe923SSUE8p6BtZtNZL11kAGRgTVd+BOjmyzGd+fyCAi/DZgAf6GQk0+I 38/CN5LjTKGI3STGOQimHb/4jIxNtLocH2PuSTDjHtR7xuhvGTntzxHH+br4pJe7Kwwl/u pkegy2UYYQRcBN4C9AHgK5nhXMNBSNCytmII0abKX46sCiOOpc4u3CPAgpQ95w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1650087548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=o6IEbKvua02oTa9M00UzUl+jNfiR5q6pe5kpfgir4y8=; b=9wb1NxbfwZzQuQ41GZQL+zJuut45olZ9DquTQtw2Civ9s8/zGDtZJWNtP8KuIvu8aqlbFB 1QFUKPcXByjX55f4Fdcz6IHCJPTXVsroKlcUxvf6AkqCKk3pfE3cWybVNnWfMMJ4P0ITW2 eiNmTuTolTKcdcRb41gOUkCwUojscX/MZYrbetS5338Zv87MEPFB4DWJnhfDO0OU/W6CFs CdoyCSDZGvmbT9bwszF/0DNkk8roB7b2HZN9+xvGYPE0Yi1mJ1u2dIbOU6rIPiNG3WEIa4 LpDGj4onyTZf0mnFNo4tJQ0o5BjTP5eE3I1QNzfTs381mvq9DeVXcm5XgfEKRw== ARC-Authentication-Results: i=1; rspamd-b69d6888c-bbjgq; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a254.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.127.95.106 (trex/6.7.1); Sat, 16 Apr 2022 05:39:09 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Bottle-Society: 79e8c51671ba30ce_1650087548870_3045130971 X-MC-Loop-Signature: 1650087548870:2453292932 X-MC-Ingress-Time: 1650087548869 Received: from localhost.localdomain (unknown [104.36.29.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a254.dreamhost.com (Postfix) with ESMTPSA id 4KgMSq0Syxz1PX; Fri, 15 Apr 2022 22:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1650087548; bh=o6IEbKvua02oTa9M00UzUl+jNfiR5q6pe5kpfgir4y8=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=VGpJSw0EzAMU0y6a6KvMpV2wz+jg6tAye0rdHHJ+LrVetgpyc3WHVFQBWLSS3nImn XDjpSfV5OwoAKwBD1jPR5CMzNSmtEFagvLEqc9ovKkwotm83oJceLOMPJtI0WaWHyW zB/HwNfeWRfireGMH2SX/NoGuZRPXA47wfayuP4jLkqI36zLnfof0j3zRJk0vNOcKL WMIaBrc39S4szwXvRuUjqtOhzCr/e/YsxLE0a6Y6vE/00OJ9Fe/GCHhbZGLUfV8ipB 6SwrYQUKP8ilY9ou0aHaA0LTIhRDSCxr/BbOaRbVAkvL4BNPBV09jZeoebje9dDkly GCZiTtes7rFew== From: Davidlohr Bueso To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, dave@stgolabs.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] mm/vmscan: use node_is_toptier helper in node_reclaim Date: Fri, 15 Apr 2022 22:38:58 -0700 Message-Id: <20220416053902.68517-3-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220416053902.68517-1-dave@stgolabs.net> References: <20220416053902.68517-1-dave@stgolabs.net> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 8D3BC20005 X-Stat-Signature: 3xzhs1i86ocuxurzfr93uotew195rd8x Authentication-Results: imf03.hostedemail.com; dkim=fail ("body hash did not verify") header.d=stgolabs.net header.s=dreamhost header.b=VGpJSw0E; spf=pass (imf03.hostedemail.com: domain of dave@stgolabs.net designates 23.83.209.81 as permitted sender) smtp.mailfrom=dave@stgolabs.net; dmarc=none X-HE-Tag: 1650087550-473853 X-Bogosity: Ham, tests=bogofilter, spamicity=0.090077, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We have helpers for a reason. Signed-off-by: Davidlohr Bueso Acked-by: David Rientjes --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 1678802e03e7..cb583fcbf5bf 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4750,7 +4750,7 @@ int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order) * over remote processors and spread off node memory allocations * as wide as possible. */ - if (node_state(pgdat->node_id, N_CPU) && pgdat->node_id != numa_node_id()) + if (node_is_toptier(pgdat->node_id) && pgdat->node_id != numa_node_id()) return NODE_RECLAIM_NOSCAN; if (test_and_set_bit(PGDAT_RECLAIM_LOCKED, &pgdat->flags)) From patchwork Sat Apr 16 05:38:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12815685 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 86D0EC433FE for ; Sat, 16 Apr 2022 05:39:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 982146B0075; Sat, 16 Apr 2022 01:39:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92F1D6B0078; Sat, 16 Apr 2022 01:39:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75B976B007B; Sat, 16 Apr 2022 01:39:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 67AEC6B0075 for ; Sat, 16 Apr 2022 01:39:12 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 217D48249980 for ; Sat, 16 Apr 2022 05:39:12 +0000 (UTC) X-FDA: 79361638944.29.1FDFB22 Received: from antelope.elm.relay.mailchannels.net (antelope.elm.relay.mailchannels.net [23.83.212.4]) by imf31.hostedemail.com (Postfix) with ESMTP id 8467320003 for ; Sat, 16 Apr 2022 05:39:11 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 66FAC6C0905; Sat, 16 Apr 2022 05:39:10 +0000 (UTC) Received: from pdx1-sub0-mail-a254.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 9EEF46C08CD; Sat, 16 Apr 2022 05:39:09 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1650087549; a=rsa-sha256; cv=none; b=sbosIBhnEqP1T17IyQBJiEtU/uS2lfZdVvZLa55sLUW8R4P293rXEojZ+eQa0BehrjjNyS GtbXbXvnkOCLORoeOGORl+gNG0jhT//wPSmlr26FG/6BWGWCly2hS35xRXuAWiBFq3bDjK MmQHFCeXiMN4F8k7Kw7sOgDl3K8/BEsuHKfPKD9toH//v3isBfOAXTm+/tL37V8VgbpUJP W0MwlBKCDJSO5h2mJf4B1dcdBxA+4kka5Dr6V6zn7NjzPcrohNpcwsUy8ozJvfFrVBmmYm k3VjkoJj/HineqBmq804b71J2QLN1JjcwVXwuQ6ESVCqLnSXoTB2kgEcDKUsJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1650087549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f59htISnwsqoH/jBojWcG/OX8Gw18WwWDAuC1GWBkrc=; b=LjAwIScXaues8ODld+ikp2DoRT/kH0s1tZQi5XHiJLc0Bu+oyXhKLJZ/DHZ+WK2Xnreq23 hZnseiZIpCGZDL2v/6IJpDWfxED8U58PGpQIz8pNkU6hJR1U8UApt0nHM57rdMJ0Y0152t dyTMFCmo/ev9KwQoEVaVkOYbXPKSaD2LyNBYcqauV5X57ZJ85yiKcMlOcCrEXh3lz3d5NT 7QumbFtCwI3nZZ/5YirWHxXs3AsAWxEW+z3upjESwvGhxjxn5cbrqFrSvrtqfGUYkoEJj1 +SL7rso6Xpfrd9s979otP32YURrMYnF0iFcd0Fwf6jrRnRmRyaLgdRwKkDB0fA== ARC-Authentication-Results: i=1; rspamd-b69d6888c-zhs78; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a254.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.158.161 (trex/6.7.1); Sat, 16 Apr 2022 05:39:10 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Glossy-Minister: 2239f3141878fde9_1650087550201_4208480808 X-MC-Loop-Signature: 1650087550201:4069922302 X-MC-Ingress-Time: 1650087550201 Received: from localhost.localdomain (unknown [104.36.29.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a254.dreamhost.com (Postfix) with ESMTPSA id 4KgMSr2zjXz1M5; Fri, 15 Apr 2022 22:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1650087549; bh=f59htISnwsqoH/jBojWcG/OX8Gw18WwWDAuC1GWBkrc=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=nFPvhSglVmtuufEmK6rGA668yDzj4PT0wtwCTlI3Pa5k5AFfKRgEbHOx/iMxJyzTr MW3dLOtFRYgV/T8I598HUMMjY6i9ZXcUOzZGTcceQi8gV7j6pxIOSDpGmUuo/pRmOE 7PpemJMP4k5fWMZPf7nEj1EMXi90TV674KMZAuCrlR10bFLrgU4ftCjsYtlMSfiJHy EMC1pNwgnqnnxCxADAbhVsAGMGCCSZkofbuXuU4hACZhipSKgp20heJcztRdQmQmAf yn0g952C7zaU7xYYoLC88WhRVnYr0lFDDMBPWDwj4xyQlUAxH0iesIha60bqEBDxHA l5K3VkL1TaPgg== From: Davidlohr Bueso To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, dave@stgolabs.net, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] mm: make __node_reclaim() more flexible Date: Fri, 15 Apr 2022 22:38:59 -0700 Message-Id: <20220416053902.68517-4-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220416053902.68517-1-dave@stgolabs.net> References: <20220416053902.68517-1-dave@stgolabs.net> MIME-Version: 1.0 Authentication-Results: imf31.hostedemail.com; dkim=fail ("body hash did not verify") header.d=stgolabs.net header.s=dreamhost header.b=nFPvhSgl; dmarc=none; spf=pass (imf31.hostedemail.com: domain of dave@stgolabs.net designates 23.83.212.4 as permitted sender) smtp.mailfrom=dave@stgolabs.net X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8467320003 X-Stat-Signature: 4aihctrdnsn9cp5fozufkgpxupb6thsa X-HE-Tag: 1650087551-820772 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000716, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently __node_reclaim() is tailored to the allocator paths. With proactive per-node reclaim it requires a bit more flexibly: - Deal in terms of nr_pages instead of order. Similarly this also applies to the respective tracing. - Make the caller pass an already armed scan control. - Return number of reclaimed pages. The caller can trivially check against this explicitly instead. The current node_reclaim() interface remains the same. Signed-off-by: Davidlohr Bueso --- include/trace/events/vmscan.h | 12 ++++----- mm/vmscan.c | 47 +++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index de136dbd623a..ab6ce8d8770b 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -439,25 +439,25 @@ TRACE_EVENT(mm_vmscan_lru_shrink_active, TRACE_EVENT(mm_vmscan_node_reclaim_begin, - TP_PROTO(int nid, int order, gfp_t gfp_flags), + TP_PROTO(int nid, unsigned long nr_pages, gfp_t gfp_flags), - TP_ARGS(nid, order, gfp_flags), + TP_ARGS(nid, nr_pages, gfp_flags), TP_STRUCT__entry( __field(int, nid) - __field(int, order) + __field(int, nr_pages) __field(gfp_t, gfp_flags) ), TP_fast_assign( __entry->nid = nid; - __entry->order = order; + __entry->nr_pages = nr_pages; __entry->gfp_flags = gfp_flags; ), - TP_printk("nid=%d order=%d gfp_flags=%s", + TP_printk("nid=%d nr_pages=%d gfp_flags=%s", __entry->nid, - __entry->order, + __entry->nr_pages, show_gfp_flags(__entry->gfp_flags)) ); diff --git a/mm/vmscan.c b/mm/vmscan.c index cb583fcbf5bf..1735c302831c 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4668,36 +4668,28 @@ static unsigned long node_pagecache_reclaimable(struct pglist_data *pgdat) /* * Try to free up some pages from this node through reclaim. + * Returns the number of reclaimed pages. */ -static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order) +static unsigned long __node_reclaim(struct pglist_data *pgdat, + gfp_t gfp_mask, unsigned long nr_pages, + struct scan_control *sc) { /* Minimum pages needed in order to stay on node */ - const unsigned long nr_pages = 1 << order; struct task_struct *p = current; unsigned int noreclaim_flag; - struct scan_control sc = { - .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), - .gfp_mask = current_gfp_context(gfp_mask), - .order = order, - .priority = NODE_RECLAIM_PRIORITY, - .may_writepage = !!(node_reclaim_mode & RECLAIM_WRITE), - .may_unmap = !!(node_reclaim_mode & RECLAIM_UNMAP), - .may_swap = 1, - .reclaim_idx = gfp_zone(gfp_mask), - }; unsigned long pflags; - trace_mm_vmscan_node_reclaim_begin(pgdat->node_id, order, - sc.gfp_mask); + trace_mm_vmscan_node_reclaim_begin(pgdat->node_id, nr_pages, + sc->gfp_mask); cond_resched(); psi_memstall_enter(&pflags); - fs_reclaim_acquire(sc.gfp_mask); + fs_reclaim_acquire(sc->gfp_mask); /* * We need to be able to allocate from the reserves for RECLAIM_UNMAP */ noreclaim_flag = memalloc_noreclaim_save(); - set_task_reclaim_state(p, &sc.reclaim_state); + set_task_reclaim_state(p, &sc->reclaim_state); if (node_pagecache_reclaimable(pgdat) > pgdat->min_unmapped_pages) { /* @@ -4705,23 +4697,34 @@ static int __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned in * priorities until we have enough memory freed. */ do { - shrink_node(pgdat, &sc); - } while (sc.nr_reclaimed < nr_pages && --sc.priority >= 0); + shrink_node(pgdat, sc); + } while (sc->nr_reclaimed < nr_pages && --sc->priority >= 0); } set_task_reclaim_state(p, NULL); memalloc_noreclaim_restore(noreclaim_flag); - fs_reclaim_release(sc.gfp_mask); + fs_reclaim_release(sc->gfp_mask); psi_memstall_leave(&pflags); - trace_mm_vmscan_node_reclaim_end(sc.nr_reclaimed); + trace_mm_vmscan_node_reclaim_end(sc->nr_reclaimed); - return sc.nr_reclaimed >= nr_pages; + return sc->nr_reclaimed; } int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order) { int ret; + const unsigned long nr_pages = 1 << order; + struct scan_control sc = { + .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), + .gfp_mask = current_gfp_context(gfp_mask), + .order = order, + .priority = NODE_RECLAIM_PRIORITY, + .may_writepage = !!(node_reclaim_mode & RECLAIM_WRITE), + .may_unmap = !!(node_reclaim_mode & RECLAIM_UNMAP), + .may_swap = 1, + .reclaim_idx = gfp_zone(gfp_mask), + }; /* * Node reclaim reclaims unmapped file backed pages and @@ -4756,7 +4759,7 @@ int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order) if (test_and_set_bit(PGDAT_RECLAIM_LOCKED, &pgdat->flags)) return NODE_RECLAIM_NOSCAN; - ret = __node_reclaim(pgdat, gfp_mask, order); + ret = __node_reclaim(pgdat, gfp_mask, nr_pages, &sc) >= nr_pages; clear_bit(PGDAT_RECLAIM_LOCKED, &pgdat->flags); if (!ret) From patchwork Sat Apr 16 05:39:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12815686 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 96B16C433F5 for ; Sat, 16 Apr 2022 05:39:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E15276B0078; Sat, 16 Apr 2022 01:39:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC5796B007B; Sat, 16 Apr 2022 01:39:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC8B26B007D; Sat, 16 Apr 2022 01:39:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id A88116B0078 for ; Sat, 16 Apr 2022 01:39:13 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 771E120FF3 for ; Sat, 16 Apr 2022 05:39:13 +0000 (UTC) X-FDA: 79361638986.25.D3653CB Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by imf07.hostedemail.com (Postfix) with ESMTP id BBF5C40007 for ; Sat, 16 Apr 2022 05:39:12 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id ADBC98E0819; Sat, 16 Apr 2022 05:39:11 +0000 (UTC) Received: from pdx1-sub0-mail-a254.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id F3BE78E06B6; Sat, 16 Apr 2022 05:39:10 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1650087551; a=rsa-sha256; cv=none; b=7ELyfl2/zsWIsKl8MdBfcyCbEYf4HNqnvfgIVRy+9TgA9J7diXiVf/TjMLe6fJKlnfzu1D eCLKLZHgo3v1J0H/NGPajmXRDvPS3dfcy9UTLzDHqewMi8LGh3GW+7+M74jYckdqnoCNCT L/fcZ/zBRVgRO1ya+4OkGlCZPSGr8kWwKuO1hf17c6JaRiZeF5Ux1evJFezRpddA4vCmai tPRY9CffGFWfiFl/ePHu7ecoGDVeZg/y2WxgnNpIu/eY4KfFL2K+7b2KmWcfGNHTsZ4rTR CxeSUKmDfjOtQwK11+8JSDgutG3K/OOjHT+iJE1dssMn4SMpAACsOYAO1IKTsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1650087551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1GcA1EQLKr6cDmztZQrBKDqx1z4dpZsZKzsdXEMRVzY=; b=YBmqxd4qGkYBUlYDZck0Aj6Bmr2e+O3nepNecQR9p+2EDE5JvllEthms9t1MHJWalgBD3c hwPjqPKVmJO7QiJNvdFahzAkIeOtUvUcmLs67t2xb9LsLV5mV3kUyczC49GY3lcwlQOiTQ vvlfli9cXPnvsg0ID4RheL0jWCcc+xNu+COAQn8IOrrAX0VMiTyzEQaBH7ZSssF2aHZdGt eRdK844Kd2qxuCmxvh/YBfQnmayWsTJCtM8wEmFbEbzAYGJdK+pCaMpHPemuQX6XNjUHEA +Fwx1VCnQmVk7m77cCl6+uB8OBL/IBUdmvYBF+KYszOdnzb16YhlPWLSowlijQ== ARC-Authentication-Results: i=1; rspamd-b69d6888c-bbjgq; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a254.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.116.106.98 (trex/6.7.1); Sat, 16 Apr 2022 05:39:11 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Squirrel-Reign: 2b63278d331c9d71_1650087551437_1108755106 X-MC-Loop-Signature: 1650087551437:2424071474 X-MC-Ingress-Time: 1650087551437 Received: from localhost.localdomain (unknown [104.36.29.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a254.dreamhost.com (Postfix) with ESMTPSA id 4KgMSs4Rm1z2x; Fri, 15 Apr 2022 22:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1650087550; bh=1GcA1EQLKr6cDmztZQrBKDqx1z4dpZsZKzsdXEMRVzY=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=O6EVUGnYZCCOAL10auVg4KYPQEL5CcCMIqG67RDrj2Yfq0ehUw5IHLfaf/xeFrV6C Aazy55ckqril50OFjab3d0r5RpDPw6Dm3BY8FKdU0zeo22iZpxM0sivWmkLQkHtXiS y3Lmo1ZKB+9X0CUDCeDo0+b8dlqikjoQkpTVPWmtiKp5dMzvWAJJ+2tYNa1FaSK7DT U7gQZ4715IYXfWw9epgv0ydXQg1EI5qLHC9qVMXbK22aQ7yK8BomZDb2lxAWPLcQLN /XN8vu+DoWAadOkW+YDEjWPTLFRCy1meDR70ryGIaGDZB7Dei9Yyyza3hBsFU2/7ac bIofukKT3MClw== From: Davidlohr Bueso To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, dave@stgolabs.net, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] mm: introduce per-node proactive reclaim interface Date: Fri, 15 Apr 2022 22:39:00 -0700 Message-Id: <20220416053902.68517-5-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220416053902.68517-1-dave@stgolabs.net> References: <20220416053902.68517-1-dave@stgolabs.net> MIME-Version: 1.0 Authentication-Results: imf07.hostedemail.com; dkim=fail ("body hash did not verify") header.d=stgolabs.net header.s=dreamhost header.b=O6EVUGnY; dmarc=none; spf=pass (imf07.hostedemail.com: domain of dave@stgolabs.net designates 23.83.212.17 as permitted sender) smtp.mailfrom=dave@stgolabs.net X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: BBF5C40007 X-Stat-Signature: 3c3k1f5wzcdt8j7hz9prduwp4h5janru X-HE-Tag: 1650087552-514711 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: This patch introduces a mechanism to trigger memory reclaim as a per-node sysfs interface, inspired by compaction's equivalent; ie: echo 1G > /sys/devices/system/node/nodeX/reclaim It is based on the discussions from David's thread[1] as well as the current upstreaming of the memcg[2] interface (which has nice explanations for the benefits of userspace reclaim overall). In both cases conclusions were that either way of inducing proactive reclaim should be KISS, and can be later extended. So this patch does not allow the user much fine tuning beyond the size of the reclaim, such as anon/file or whether or semantics of demotion. [1] https://lore.kernel.org/all/5df21376-7dd1-bf81-8414-32a73cea45dd@google.com/ [2] https://lore.kernel.org/all/20220408045743.1432968-1-yosryahmed@google.com/ Signed-off-by: Davidlohr Bueso --- Documentation/ABI/stable/sysfs-devices-node | 10 ++++ drivers/base/node.c | 2 + include/linux/swap.h | 16 ++++++ mm/vmscan.c | 59 +++++++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node index 8db67aa472f1..3c935e1334f7 100644 --- a/Documentation/ABI/stable/sysfs-devices-node +++ b/Documentation/ABI/stable/sysfs-devices-node @@ -182,3 +182,13 @@ Date: November 2021 Contact: Jarkko Sakkinen Description: The total amount of SGX physical memory in bytes. + +What: /sys/devices/system/node/nodeX/reclaim +Date: April 2022 +Contact: Davidlohr Bueso +Description: + Write the amount of bytes to induce memory reclaim in this node. + This file accepts a single key, the number of bytes to reclaim. + When it completes successfully, the specified amount or more memory + will have been reclaimed, and -EAGAIN if less bytes are reclaimed + than the specified amount. diff --git a/drivers/base/node.c b/drivers/base/node.c index 6cdf25fd26c3..d80c478e2a6e 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -670,6 +670,7 @@ static int register_node(struct node *node, int num) hugetlb_register_node(node); compaction_register_node(node); + reclaim_register_node(node); return 0; } @@ -685,6 +686,7 @@ void unregister_node(struct node *node) hugetlb_unregister_node(node); /* no-op, if memoryless node */ node_remove_accesses(node); node_remove_caches(node); + reclaim_unregister_node(node); device_unregister(&node->dev); } diff --git a/include/linux/swap.h b/include/linux/swap.h index 27093b477c5f..cca43ae6d770 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -398,6 +398,22 @@ extern unsigned long shrink_all_memory(unsigned long nr_pages); extern int vm_swappiness; long remove_mapping(struct address_space *mapping, struct folio *folio); +#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) +extern int reclaim_register_node(struct node *node); +extern void reclaim_unregister_node(struct node *node); + +#else + +static inline int reclaim_register_node(struct node *node) +{ + return 0; +} + +static inline void reclaim_unregister_node(struct node *node) +{ +} +#endif /* CONFIG_SYSFS && CONFIG_NUMA */ + extern unsigned long reclaim_pages(struct list_head *page_list); #ifdef CONFIG_NUMA extern int node_reclaim_mode; diff --git a/mm/vmscan.c b/mm/vmscan.c index 1735c302831c..3539f8a0f0ea 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4819,3 +4819,62 @@ void check_move_unevictable_pages(struct pagevec *pvec) } } EXPORT_SYMBOL_GPL(check_move_unevictable_pages); + +#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) +static ssize_t reclaim_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int err, nid = dev->id; + gfp_t gfp_mask = GFP_KERNEL; + struct pglist_data *pgdat = NODE_DATA(nid); + unsigned long nr_to_reclaim, nr_reclaimed = 0; + unsigned int nr_retries = MAX_RECLAIM_RETRIES; + struct scan_control sc = { + .gfp_mask = current_gfp_context(gfp_mask), + .reclaim_idx = gfp_zone(gfp_mask), + .priority = NODE_RECLAIM_PRIORITY, + .may_writepage = !laptop_mode, + .may_unmap = 1, + .may_swap = 1, + }; + + buf = strstrip((char *)buf); + err = page_counter_memparse(buf, "", &nr_to_reclaim); + if (err) + return err; + + sc.nr_to_reclaim = max(nr_to_reclaim, SWAP_CLUSTER_MAX); + + while (nr_reclaimed < nr_to_reclaim) { + unsigned long reclaimed; + + if (test_and_set_bit(PGDAT_RECLAIM_LOCKED, &pgdat->flags)) + return -EAGAIN; + + /* does cond_resched() */ + reclaimed = __node_reclaim(pgdat, gfp_mask, + nr_to_reclaim - nr_reclaimed, &sc); + + clear_bit(PGDAT_RECLAIM_LOCKED, &pgdat->flags); + + if (!reclaimed && !nr_retries--) + break; + + nr_reclaimed += reclaimed; + } + + return nr_reclaimed < nr_to_reclaim ? -EAGAIN : count; +} + +static DEVICE_ATTR_WO(reclaim); +int reclaim_register_node(struct node *node) +{ + return device_create_file(&node->dev, &dev_attr_reclaim); +} + +void reclaim_unregister_node(struct node *node) +{ + return device_remove_file(&node->dev, &dev_attr_reclaim); +} +#endif From patchwork Sat Apr 16 05:39:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12815687 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 98C66C433F5 for ; Sat, 16 Apr 2022 05:39:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB3E16B007E; Sat, 16 Apr 2022 01:39:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C63446B007D; Sat, 16 Apr 2022 01:39:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8F4D6B007E; Sat, 16 Apr 2022 01:39:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 9859A6B007B for ; Sat, 16 Apr 2022 01:39:14 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9EFEB230FA for ; Sat, 16 Apr 2022 05:39:14 +0000 (UTC) X-FDA: 79361639028.02.D58034D Received: from dog.elm.relay.mailchannels.net (dog.elm.relay.mailchannels.net [23.83.212.48]) by imf31.hostedemail.com (Postfix) with ESMTP id CC2FE20004 for ; Sat, 16 Apr 2022 05:39:13 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A92A15A0812; Sat, 16 Apr 2022 05:39:12 +0000 (UTC) Received: from pdx1-sub0-mail-a254.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0E0E75A041F; Sat, 16 Apr 2022 05:39:12 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1650087552; a=rsa-sha256; cv=none; b=4SXZxwS7usFcejGdUgETrT2yCbFZZB0lsfZtsUDgM99sdQkJ9YgUA2s3BBm8c6WoxSuV/Z gZ6O/5ICyUsAyggYyaKZ8JLnAq0bMVlYSZSSrS5qn6Inh9Z5RhQmf99U6KJswX0uf9Nb70 HtLZe6NMlIiouQqGeMKXhG/DjiyqlHDvfZtPd3k+cZX/A6wocnmKbGBWv8FkDiau8NqKNy /HJpa5Cu8U9tS4y3UzLPNExuJ7kUXMuYu3N5ToJ1mkso20vHZ4Drzvs1CIzkMnkme6kPsQ PQmcbACRGX4/zWLy+zuOTF3FytavqfLVxamQyBqJ1hnc6hXGW4DIkiW1KoruJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1650087552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MINJwd5OLO59JndE14sJrRNnUCPFbYse28/G1Tm6ZUg=; b=sTaubIZYnrvhNGLF8wetyW7Esi2m5P0VyBx2gFW/fqOkLhzuWQoH/Atm6p8XdbgY2HN72e c2HdGJeOrgt4LHzf2izQQS4fvpSbcq7mrYxEzKIih6nZFBc/solCM22B6RkP5/bXjWYR+Y aRdLjd0SDYwsXOVNn+CSUPkc5xlAqDP1HQx1KmWM9YmEcKqDGhVI18R24NC8gELhGM3QZT tSRbYOq7/aUgXFFpg+CtCsUpj51on6UOMcTdt1/upqcJwPmTTv2JOt0kJG+05Gf4cddVZL q44Z6qhxQtSCYl7xUcZYMn2lJ0B5P5IFvdlx/oczXqEV0QHXz/W8tjVzPTqI1g== ARC-Authentication-Results: i=1; rspamd-b69d6888c-g7hrr; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a254.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.158.161 (trex/6.7.1); Sat, 16 Apr 2022 05:39:12 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Illustrious-White: 551691287601fc33_1650087552488_1211284300 X-MC-Loop-Signature: 1650087552488:2168839710 X-MC-Ingress-Time: 1650087552488 Received: from localhost.localdomain (unknown [104.36.29.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a254.dreamhost.com (Postfix) with ESMTPSA id 4KgMSt6gZhz1M5; Fri, 15 Apr 2022 22:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1650087551; bh=MINJwd5OLO59JndE14sJrRNnUCPFbYse28/G1Tm6ZUg=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=ig+ufRQSyfnVLcYiog8z/3ADVGHTPhIJPTs3FGEh28sxNpFrfhhsNi87iTDg7XSWv wKVBlG4mxXB/m0sQXdaYLFnWehjtrB4NmRIz2W7bgFwCZvLxA1Z8OwRBg4Ze4yFZfG p5SwVjsN75gVF8rGfeQQlTrr4kkR9Nljh4k2by+dyBiFHI9dB4WChA2otUEwishpPc RUtrYSIMA3op2xuk8kz3KoOQWVTukWn2iFqB45tcsqgLTqa2QN2J6eBTmmnb7wvnPD JX9LIq3yFzt33jJuNbzXekqsgcj2v5J4CzKAc1r+TO90eEbFBuDMaYdXEhWftI0JGO A/nmlgDZaeyHA== From: Davidlohr Bueso To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, dave@stgolabs.net, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] mm/migration: export demotion_path of a node via sysfs Date: Fri, 15 Apr 2022 22:39:01 -0700 Message-Id: <20220416053902.68517-6-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220416053902.68517-1-dave@stgolabs.net> References: <20220416053902.68517-1-dave@stgolabs.net> MIME-Version: 1.0 Authentication-Results: imf31.hostedemail.com; dkim=fail ("body hash did not verify") header.d=stgolabs.net header.s=dreamhost header.b=ig+ufRQS; dmarc=none; spf=pass (imf31.hostedemail.com: domain of dave@stgolabs.net designates 23.83.212.48 as permitted sender) smtp.mailfrom=dave@stgolabs.net X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: CC2FE20004 X-Stat-Signature: i8fx6c99pdxzefs4d9pcsr4x1zp3k14f X-HE-Tag: 1650087553-822086 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: Add a /sys/devices/system/node/nodeX/demotion_path file to export the possible target(s) in node_demotion[node]. Signed-off-by: Davidlohr Bueso --- Documentation/ABI/stable/sysfs-devices-node | 6 ++++ drivers/base/node.c | 39 +++++++++++++++++++++ include/linux/migrate.h | 15 ++++++++ mm/migrate.c | 15 +------- 4 files changed, 61 insertions(+), 14 deletions(-) diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node index 3c935e1334f7..f620c6ae013c 100644 --- a/Documentation/ABI/stable/sysfs-devices-node +++ b/Documentation/ABI/stable/sysfs-devices-node @@ -192,3 +192,9 @@ Description: When it completes successfully, the specified amount or more memory will have been reclaimed, and -EAGAIN if less bytes are reclaimed than the specified amount. + +What: /sys/devices/system/node/nodeX/demotion_path +Date: April 2022 +Contact: Davidlohr Bueso +Description: + Shows nodes within the next tier of slower memory below this node. diff --git a/drivers/base/node.c b/drivers/base/node.c index d80c478e2a6e..ab4bae777535 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -560,11 +561,49 @@ static ssize_t node_read_distance(struct device *dev, } static DEVICE_ATTR(distance, 0444, node_read_distance, NULL); +static ssize_t node_read_demotion_path(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int nid = dev->id; + int len = 0; + int i; + struct demotion_nodes *nd; + + /* + * buf is currently PAGE_SIZE in length and each node needs 4 chars + * at the most (target + space or newline). + */ + BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE); + + if (!node_demotion) { + len += sysfs_emit_at(buf, len, "%d", NUMA_NO_NODE); + goto done; + } + + nd = &node_demotion[nid]; + + rcu_read_lock(); + if (nd->nr == 0) + len += sysfs_emit_at(buf, len, "%d", NUMA_NO_NODE); + else { + for (i = 0; i < nd->nr; i++) { + len += sysfs_emit_at(buf, len, "%s%d", + i ? " " : "", nd->nodes[i]); + } + } + rcu_read_unlock(); +done: + len += sysfs_emit_at(buf, len, "\n"); + return len; +} +static DEVICE_ATTR(demotion_path, 0444, node_read_demotion_path, NULL); + static struct attribute *node_dev_attrs[] = { &dev_attr_meminfo.attr, &dev_attr_numastat.attr, &dev_attr_distance.attr, &dev_attr_vmstat.attr, + &dev_attr_demotion_path.attr, NULL }; diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 90e75d5a54d6..b0ac6a717e44 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -111,6 +111,21 @@ static inline int migrate_misplaced_page(struct page *page, } #endif /* CONFIG_NUMA_BALANCING */ +#define DEFAULT_DEMOTION_TARGET_NODES 15 + +#if MAX_NUMNODES < DEFAULT_DEMOTION_TARGET_NODES +#define DEMOTION_TARGET_NODES (MAX_NUMNODES - 1) +#else +#define DEMOTION_TARGET_NODES DEFAULT_DEMOTION_TARGET_NODES +#endif + +struct demotion_nodes { + unsigned short nr; + short nodes[DEMOTION_TARGET_NODES]; +}; + +extern struct demotion_nodes *node_demotion __read_mostly; + #ifdef CONFIG_MIGRATION /* diff --git a/mm/migrate.c b/mm/migrate.c index 6c31ee1e1c9b..e47ea25fcfe8 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2172,20 +2172,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, * must be held over all reads to ensure that no cycles are * observed. */ -#define DEFAULT_DEMOTION_TARGET_NODES 15 - -#if MAX_NUMNODES < DEFAULT_DEMOTION_TARGET_NODES -#define DEMOTION_TARGET_NODES (MAX_NUMNODES - 1) -#else -#define DEMOTION_TARGET_NODES DEFAULT_DEMOTION_TARGET_NODES -#endif - -struct demotion_nodes { - unsigned short nr; - short nodes[DEMOTION_TARGET_NODES]; -}; - -static struct demotion_nodes *node_demotion __read_mostly; +struct demotion_nodes *node_demotion __read_mostly; /** * next_demotion_node() - Get the next node in the demotion path From patchwork Sun Apr 17 03:49:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 12815925 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 BA640C433F5 for ; Sun, 17 Apr 2022 03:49:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B9896B0072; Sat, 16 Apr 2022 23:49:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 268286B0073; Sat, 16 Apr 2022 23:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E27F6B0074; Sat, 16 Apr 2022 23:49:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 005E96B0072 for ; Sat, 16 Apr 2022 23:49:39 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id CE3CF807A3 for ; Sun, 17 Apr 2022 03:49:39 +0000 (UTC) X-FDA: 79364991678.02.A945BE0 Received: from fossa.birch.relay.mailchannels.net (fossa.birch.relay.mailchannels.net [23.83.209.62]) by imf21.hostedemail.com (Postfix) with ESMTP id C10761C0002 for ; Sun, 17 Apr 2022 03:49:38 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 85355120DBA; Sun, 17 Apr 2022 03:49:37 +0000 (UTC) Received: from pdx1-sub0-mail-a254.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id B2C75120DB7; Sun, 17 Apr 2022 03:49:36 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1650167376; a=rsa-sha256; cv=none; b=2AWpxcPXLhDqchTvOP7wkCpWhYrtq7R9zHGTYYpZnIH5oTyHgNlYc32F3RbX/xvEJbEUBj jLTuSmYZZJIcELFiUf0LJ6e7YzPK7OXUxpv7hZhvIkH0J5IOGlx/XO4cZb4pB+8lhEX82M 8xRZZ/4ehCQclqHzbaU6TTNiixiRE6Z6G1/roRG9cjDdyp3P8yYuiVOsx7399f3QlPQuGH cWd0G6jCtiC/KToyXgLTHTyx8HM7FrZjf1bzeml4sGCHR3ndJpy3N1BsNWjbgqC5IkNI23 O8vzg3saZOElypqmLJn4qAEv5yj5foRUbKUycc5n2JEeWW1VNHvqyWhOvao9Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1650167376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TCFsTcqFrfctJCb7WwW2kivBjtsWElvnzgT7n+875Bg=; b=qBd3agOJD+t73EVdA8gGF3zUxw5gp0ZQZm7rjqqEn+H5gG1XwSQEaN1hz8YlaSrflbj3Ji YtpgMprQWdoAAihi11LfN75TJSco/HCsskglu39uZae/1Vu59uqBgVONqBtIjXDjkytdA/ PGQ41Mx+nelxplkloAzEemazJiFKM5zVpT1cZQK2E6KhSdxinDlIqMuxeizHE0oVNqxEbc 9BLyH48LnufZKM2AcSn/z2idbZGm8COHMYD7o2roqDShmBTCgsXtBETBEqkTsQl9IyFL/j WANmTfc2xIaN/uf/DCVHFBoo75Sw5ZgjmulyL+AwKpBJ0ul5Bxg3d/Ktblottg== ARC-Authentication-Results: i=1; rspamd-5f678fb567-vwqvc; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from pdx1-sub0-mail-a254.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.121.210.130 (trex/6.7.1); Sun, 17 Apr 2022 03:49:37 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Zesty-Tart: 6d7974f36c54f951_1650167377147_1315708952 X-MC-Loop-Signature: 1650167377147:3412058637 X-MC-Ingress-Time: 1650167377147 Received: from offworld (unknown [104.36.29.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a254.dreamhost.com (Postfix) with ESMTPSA id 4Kgwzz4Hh1z1K1; Sat, 16 Apr 2022 20:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1650167376; bh=TCFsTcqFrfctJCb7WwW2kivBjtsWElvnzgT7n+875Bg=; h=Date:From:To:Cc:Subject:Content-Type; b=XvH2pFAONkX1wF6yc5i4ltrc8kz/udpMfHJXDhWOKtMH2cPpYlHYGFvIy4Bt8wYYM nJNOAEN/gOSXgT08Hwfv2CQJUeekOcuXzsyXI+lCrliLCiYUiksDFIp28hC+6eDczv KgWfyLGPdDSJjo3A7equ9HIkk2phgaci6fJIrkyudS9V6yeCy5BYgOM4uch9JkjjSm d6p/73eOsgrZvJLK1ZRbRjXAF1pSz5hIzH8Z8tTs10sJOeyPg4ZT3CKSXet+AN7dmO kisre1HGPtMtxSIzYp2Bo/7MsKpOnBSgxUEri02pJ61uw9xoYH0f+pJMKRs/T7+Ewp PQMf76CUUnBcQ== Date: Sat, 16 Apr 2022 20:49:32 -0700 From: Davidlohr Bueso To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] mm/migrate: export whether or not node is toptier in sysf Message-ID: <20220417034932.jborenmvfbqrfhlj@offworld> Mail-Followup-To: linux-mm@kvack.org, mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, linux-kernel@vger.kernel.org References: <20220416053902.68517-1-dave@stgolabs.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220416053902.68517-1-dave@stgolabs.net> User-Agent: NeoMutt/20201120 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C10761C0002 X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=stgolabs.net header.s=dreamhost header.b=XvH2pFAO; dmarc=none; spf=pass (imf21.hostedemail.com: domain of dave@stgolabs.net designates 23.83.209.62 as permitted sender) smtp.mailfrom=dave@stgolabs.net X-Stat-Signature: 3p6mf1at1oxbt45rpijjwikiy9i8t6t6 X-HE-Tag: 1650167378-762062 X-Bogosity: Ham, tests=bogofilter, spamicity=0.003725, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This allows userspace to know if the node is considered fast memory (with CPUs attached to it). While this can be already derived without a new file, this helps further encapsulate the concept. Signed-off-by: Davidlohr Bueso --- Resending, just noticed this oatch was never posted. Documentation/ABI/stable/sysfs-devices-node | 6 ++++++ drivers/base/node.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) -- 2.26.2 diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node index f620c6ae013c..1c21c3985535 100644 --- a/Documentation/ABI/stable/sysfs-devices-node +++ b/Documentation/ABI/stable/sysfs-devices-node @@ -198,3 +198,9 @@ Date: April 2022 Contact: Davidlohr Bueso Description: Shows nodes within the next tier of slower memory below this node. + +What: /sys/devices/system/node/nodeX/memory_toptier +Date: April 2022 +Contact: Davidlohr Bueso +Description: + Node is attached to fast memory or not. diff --git a/drivers/base/node.c b/drivers/base/node.c index ab4bae777535..b9de5b0360f2 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -598,12 +598,25 @@ static ssize_t node_read_demotion_path(struct device *dev, } static DEVICE_ATTR(demotion_path, 0444, node_read_demotion_path, NULL); +static ssize_t node_read_memory_toptier(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int nid = dev->id; + int len = 0; + + len += sysfs_emit_at(buf, len, "%d\n", !!node_is_toptier(nid)); + + return len; +} +static DEVICE_ATTR(memory_toptier, 0444, node_read_memory_toptier, NULL); + static struct attribute *node_dev_attrs[] = { &dev_attr_meminfo.attr, &dev_attr_numastat.attr, &dev_attr_distance.attr, &dev_attr_vmstat.attr, &dev_attr_demotion_path.attr, + &dev_attr_memory_toptier.attr, NULL };