From: Aneesh Kumar K V <aneesh.kumar@linux.ibm.com>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
Wei Xu <weixugc@google.com>, Yang Shi <shy828301@gmail.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Tim C Chen <tim.c.chen@intel.com>,
Michal Hocko <mhocko@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Hesham Almatary <hesham.almatary@huawei.com>,
Dave Hansen <dave.hansen@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Alistair Popple <apopple@nvidia.com>,
Dan Williams <dan.j.williams@intel.com>,
Johannes Weiner <hannes@cmpxchg.org>,
jvgediya.oss@gmail.com
Subject: Re: [PATCH v10 8/8] mm/demotion: Update node_is_toptier to work with memory tiers
Date: Mon, 25 Jul 2022 14:26:35 +0530 [thread overview]
Message-ID: <e7073964-6631-38f1-62cb-f59b8d26f891@linux.ibm.com> (raw)
In-Reply-To: <87ilnly3m4.fsf@yhuang6-desk2.ccr.corp.intel.com>
On 7/25/22 2:24 PM, Huang, Ying wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
>
>> With memory tiers support we can have memory only NUMA nodes
>> in the top tier from which we want to avoid promotion tracking NUMA
>> faults. Update node_is_toptier to work with memory tiers.
>> All NUMA nodes are by default top tier nodes. With lower memory
>> tiers added we consider all memory tiers above a memory tier having
>> CPU NUMA nodes as a top memory tier
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
>> ---
>> include/linux/memory-tiers.h | 11 +++++++++
>> include/linux/node.h | 5 -----
>> mm/huge_memory.c | 1 +
>> mm/memory-tiers.c | 43 ++++++++++++++++++++++++++++++++++++
>> mm/migrate.c | 1 +
>> mm/mprotect.c | 1 +
>> 6 files changed, 57 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h
>> index 0e58588fa066..085dd815bf73 100644
>> --- a/include/linux/memory-tiers.h
>> +++ b/include/linux/memory-tiers.h
>> @@ -20,6 +20,7 @@ extern bool numa_demotion_enabled;
>> #ifdef CONFIG_MIGRATION
>> int next_demotion_node(int node);
>> void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets);
>> +bool node_is_toptier(int node);
>> #else
>> static inline int next_demotion_node(int node)
>> {
>> @@ -30,6 +31,11 @@ static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *target
>> {
>> *targets = NODE_MASK_NONE;
>> }
>> +
>> +static inline bool node_is_toptier(int node)
>> +{
>> + return true;
>> +}
>> #endif
>>
>> #else
>> @@ -44,5 +50,10 @@ static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *target
>> {
>> *targets = NODE_MASK_NONE;
>> }
>> +
>> +static inline bool node_is_toptier(int node)
>> +{
>> + return true;
>> +}
>> #endif /* CONFIG_NUMA */
>> #endif /* _LINUX_MEMORY_TIERS_H */
>> diff --git a/include/linux/node.h b/include/linux/node.h
>> index a2a16d4104fd..d0432db18094 100644
>> --- a/include/linux/node.h
>> +++ b/include/linux/node.h
>> @@ -191,9 +191,4 @@ static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
>>
>> #define to_node(device) container_of(device, struct node, dev)
>>
>> -static inline bool node_is_toptier(int node)
>> -{
>> - return node_state(node, N_CPU);
>> -}
>> -
>> #endif /* _LINUX_NODE_H_ */
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 834f288b3769..8405662646e9 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -35,6 +35,7 @@
>> #include <linux/numa.h>
>> #include <linux/page_owner.h>
>> #include <linux/sched/sysctl.h>
>> +#include <linux/memory-tiers.h>
>>
>> #include <asm/tlb.h>
>> #include <asm/pgalloc.h>
>> diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c
>> index 4a96e4213d66..f0515bfd4051 100644
>> --- a/mm/memory-tiers.c
>> +++ b/mm/memory-tiers.c
>> @@ -13,6 +13,7 @@
>>
>> struct memory_tier {
>> struct list_head list;
>> + int id;
>> int perf_level;
>> nodemask_t nodelist;
>> nodemask_t lower_tier_mask;
>> @@ -26,6 +27,7 @@ static LIST_HEAD(memory_tiers);
>> static DEFINE_MUTEX(memory_tier_lock);
>>
>> #ifdef CONFIG_MIGRATION
>> +static int top_tier_id;
>> /*
>> * node_demotion[] examples:
>> *
>> @@ -129,6 +131,7 @@ static struct memory_tier *find_create_memory_tier(unsigned int perf_level)
>> if (!new_memtier)
>> return ERR_PTR(-ENOMEM);
>>
>> + new_memtier->id = perf_level >> MEMTIER_CHUNK_BITS;
>> new_memtier->perf_level = perf_level;
>> if (found_slot)
>> list_add_tail(&new_memtier->list, ent);
>> @@ -154,6 +157,31 @@ static struct memory_tier *__node_get_memory_tier(int node)
>> }
>>
>> #ifdef CONFIG_MIGRATION
>> +bool node_is_toptier(int node)
>> +{
>> + bool toptier;
>> + pg_data_t *pgdat;
>> + struct memory_tier *memtier;
>> +
>> + pgdat = NODE_DATA(node);
>> + if (!pgdat)
>> + return false;
>> +
>> + rcu_read_lock();
>> + memtier = rcu_dereference(pgdat->memtier);
>> + if (!memtier) {
>> + toptier = true;
>> + goto out;
>> + }
>> + if (memtier->id >= top_tier_id)
>> + toptier = true;
>> + else
>> + toptier = false;
>> +out:
>> + rcu_read_unlock();
>> + return toptier;
>> +}
>> +
>> void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets)
>> {
>> struct memory_tier *memtier;
>> @@ -304,6 +332,21 @@ static void establish_migration_targets(void)
>> }
>> } while (1);
>> }
>> + /*
>> + * Promotion is allowed from a memory tier to higher
>> + * memory tier only if the memory tier doesn't include
>> + * compute. We want to skip promotion from a memory tier,
>> + * if any node that is part of the memory tier have CPUs.
>> + * Once we detect such a memory tier, we consider that tier
>> + * as top tiper from which promotion is not allowed.
>> + */
>> + list_for_each_entry_reverse(memtier, &memory_tiers, list) {
>> + nodes_and(used, node_states[N_CPU], memtier->nodelist);
>> + if (!nodes_empty(used)) {
>> + top_tier_id = memtier->id;
>
> I don't think we need to introduce memory tier ID for this. We can add
> a top_tier_perf_level, set it here and use it in node_is_toptier().
>
Sure. Will switch to that in the next iteration.
-aneesh
prev parent reply other threads:[~2022-07-25 9:05 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-20 2:59 [PATCH v10 0/8] mm/demotion: Memory tiers and demotion Aneesh Kumar K.V
2022-07-20 2:59 ` [PATCH v10 1/8] mm/demotion: Add support for explicit memory tiers Aneesh Kumar K.V
2022-07-26 3:53 ` Huang, Ying
2022-07-26 11:59 ` Aneesh Kumar K V
2022-07-27 1:16 ` Huang, Ying
2022-07-28 17:23 ` Johannes Weiner
2022-07-20 2:59 ` [PATCH v10 2/8] mm/demotion: Move memory demotion related code Aneesh Kumar K.V
2022-07-20 2:59 ` [PATCH v10 3/8] mm/demotion: Add hotplug callbacks to handle new numa node onlined Aneesh Kumar K.V
2022-07-26 4:03 ` Huang, Ying
2022-07-26 12:03 ` Aneesh Kumar K V
2022-07-27 1:53 ` Huang, Ying
2022-07-27 4:38 ` Aneesh Kumar K.V
2022-07-28 6:42 ` Huang, Ying
2022-07-20 2:59 ` [PATCH v10 4/8] mm/demotion/dax/kmem: Set node's performance level to MEMTIER_PERF_LEVEL_PMEM Aneesh Kumar K.V
2022-07-21 6:07 ` kernel test robot
2022-07-25 6:37 ` Huang, Ying
2022-07-25 6:48 ` Aneesh Kumar K V
2022-07-25 8:35 ` Huang, Ying
2022-07-25 8:42 ` Aneesh Kumar K V
2022-07-26 2:13 ` Huang, Ying
2022-07-27 4:31 ` Aneesh Kumar K.V
2022-07-28 6:39 ` Huang, Ying
2022-07-20 2:59 ` [PATCH v10 5/8] mm/demotion: Build demotion targets based on explicit memory tiers Aneesh Kumar K.V
2022-07-20 3:38 ` Aneesh Kumar K.V
2022-07-21 0:02 ` kernel test robot
2022-07-26 7:44 ` Huang, Ying
2022-07-26 12:30 ` Aneesh Kumar K V
2022-07-27 1:40 ` Huang, Ying
2022-07-27 4:35 ` Aneesh Kumar K.V
2022-07-28 6:51 ` Huang, Ying
2022-08-03 3:18 ` Aneesh Kumar K.V
2022-08-04 4:19 ` Huang, Ying
2022-07-20 2:59 ` [PATCH v10 6/8] mm/demotion: Add pg_data_t member to track node memory tier details Aneesh Kumar K.V
2022-07-26 8:02 ` Huang, Ying
2022-07-20 2:59 ` [PATCH v10 7/8] mm/demotion: Demote pages according to allocation fallback order Aneesh Kumar K.V
2022-07-26 8:24 ` Huang, Ying
2022-07-20 2:59 ` [PATCH v10 8/8] mm/demotion: Update node_is_toptier to work with memory tiers Aneesh Kumar K.V
2022-07-25 8:54 ` Huang, Ying
2022-07-25 8:56 ` Aneesh Kumar K V [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e7073964-6631-38f1-62cb-f59b8d26f891@linux.ibm.com \
--to=aneesh.kumar@linux.ibm.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave@stgolabs.net \
--cc=hannes@cmpxchg.org \
--cc=hesham.almatary@huawei.com \
--cc=jvgediya.oss@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=shy828301@gmail.com \
--cc=tim.c.chen@intel.com \
--cc=weixugc@google.com \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).