From patchwork Mon Apr 5 17:08:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Chen X-Patchwork-Id: 12183451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BED0DC43461 for ; Mon, 5 Apr 2021 18:09:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 545CC61246 for ; Mon, 5 Apr 2021 18:09:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 545CC61246 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DE10C6B0075; Mon, 5 Apr 2021 14:08:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D68B96B0078; Mon, 5 Apr 2021 14:08:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC15A6B007B; Mon, 5 Apr 2021 14:08:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 981EC6B0075 for ; Mon, 5 Apr 2021 14:08:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 53326824999B for ; Mon, 5 Apr 2021 18:08:59 +0000 (UTC) X-FDA: 77999099598.07.DAC37EB Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf06.hostedemail.com (Postfix) with ESMTP id 6DDC2C0007C8 for ; Mon, 5 Apr 2021 18:08:59 +0000 (UTC) IronPort-SDR: gWG+TdPIwzUe2iw3NJ4nVWkfbD+bq2/YqJYn/G2ZEKqaGEe7jZhpHujfFS7TSw/2Gh1eedtFN4 XccfuCy7dlvg== X-IronPort-AV: E=McAfee;i="6000,8403,9945"; a="172968196" X-IronPort-AV: E=Sophos;i="5.81,307,1610438400"; d="scan'208";a="172968196" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2021 11:08:58 -0700 IronPort-SDR: roq1dXu4kU12x4YrUui45ev184O6K4wcr29dMW2iXpvfH51dqj3i31whjoyiVBESwJh09PH4Wf zLiS8OPhJXdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,307,1610438400"; d="scan'208";a="448153872" Received: from skl-02.jf.intel.com ([10.54.74.28]) by fmsmga002.fm.intel.com with ESMTP; 05 Apr 2021 11:08:57 -0700 From: Tim Chen To: Michal Hocko Cc: Tim Chen , Johannes Weiner , Andrew Morton , Dave Hansen , Ying Huang , Dan Williams , David Rientjes , Shakeel Butt , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 01/11] mm: Define top tier memory node mask Date: Mon, 5 Apr 2021 10:08:25 -0700 Message-Id: <57544494cb67299fabfa01dd17885f7b6a4266bb.1617642417.git.tim.c.chen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6DDC2C0007C8 X-Stat-Signature: emtdbr397j8ffqx9oq3mhpigan91jmio Received-SPF: none (linux.intel.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=mga17.intel.com; client-ip=192.55.52.151 X-HE-DKIM-Result: none/none X-HE-Tag: 1617646139-728800 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: Traditionally, all RAM is DRAM. Some DRAM might be closer/faster than others, but a byte of media has about the same cost whether it is close or far. But, with new memory tiers such as High-Bandwidth Memory or Persistent Memory, there is a choice between fast/expensive and slow/cheap. The fast/expensive memory lives in the top tier of the memory hierachy and it is a precious resource that needs to be accounted and managed on a memory cgroup basis. Define the top tier memory as the memory nodes that don't have demotion paths into it from higher tier memory. Signed-off-by: Tim Chen --- drivers/base/node.c | 2 ++ include/linux/nodemask.h | 1 + mm/memory_hotplug.c | 3 +++ mm/migrate.c | 1 + mm/page_alloc.c | 5 ++++- 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 04f71c7bc3f8..9eb214ac331f 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -1016,6 +1016,7 @@ static struct node_attr node_state_attr[] = { #endif [N_MEMORY] = _NODE_ATTR(has_memory, N_MEMORY), [N_CPU] = _NODE_ATTR(has_cpu, N_CPU), + [N_TOPTIER] = _NODE_ATTR(is_toptier, N_TOPTIER), [N_GENERIC_INITIATOR] = _NODE_ATTR(has_generic_initiator, N_GENERIC_INITIATOR), }; @@ -1029,6 +1030,7 @@ static struct attribute *node_state_attrs[] = { #endif &node_state_attr[N_MEMORY].attr.attr, &node_state_attr[N_CPU].attr.attr, + &node_state_attr[N_TOPTIER].attr.attr, &node_state_attr[N_GENERIC_INITIATOR].attr.attr, NULL }; diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index ac398e143c9a..3003401ed7f0 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -399,6 +399,7 @@ enum node_states { #endif N_MEMORY, /* The node has memory(regular, high, movable) */ N_CPU, /* The node has one or more cpus */ + N_TOPTIER, /* Top tier node, no demotion path into node */ N_GENERIC_INITIATOR, /* The node has one or more Generic Initiators */ NR_NODE_STATES }; diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7550b88e2432..7b21560d4c4d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -654,6 +655,8 @@ static void node_states_set_node(int node, struct memory_notify *arg) if (arg->status_change_nid >= 0) node_set_state(node, N_MEMORY); + + node_set_state(node, N_TOPTIER); } static void __meminit resize_zone_range(struct zone *zone, unsigned long start_pfn, diff --git a/mm/migrate.c b/mm/migrate.c index 72223fd7e623..e84aedf611da 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -3439,6 +3439,7 @@ static int establish_migrate_target(int node, nodemask_t *used) return NUMA_NO_NODE; node_demotion[node] = migration_target; + node_clear_state(migration_target, N_TOPTIER); return migration_target; } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ff058941ccfa..471a2c342c4f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -157,6 +157,7 @@ nodemask_t node_states[NR_NODE_STATES] __read_mostly = { [N_MEMORY] = { { [0] = 1UL } }, [N_CPU] = { { [0] = 1UL } }, #endif /* NUMA */ + [N_TOPTIER] = NODE_MASK_ALL, }; EXPORT_SYMBOL(node_states); @@ -7590,8 +7591,10 @@ void __init free_area_init(unsigned long *max_zone_pfn) free_area_init_node(nid); /* Any memory on that node */ - if (pgdat->node_present_pages) + if (pgdat->node_present_pages) { node_set_state(nid, N_MEMORY); + node_set_state(nid, N_TOPTIER); + } check_for_memory(pgdat, nid); } }