From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6C0AC07E9D for ; Tue, 27 Sep 2022 02:51:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbiI0Cu7 (ORCPT ); Mon, 26 Sep 2022 22:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230378AbiI0Cs5 (ORCPT ); Mon, 26 Sep 2022 22:48:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 064F761706 for ; Mon, 26 Sep 2022 19:48:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B4D0EB81911 for ; Tue, 27 Sep 2022 02:48:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E3F2C433D7; Tue, 27 Sep 2022 02:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1664246904; bh=OeMhJL+1VBnOPAq9F/kwvn7sRa8vsrq/W7D1GxZ/Byg=; h=Date:To:From:Subject:From; b=hkRJNjnkBS1cfsozwMPmzGVbsaaRkx3wCpMAO3BdDE/r27AyQ8zWgniByghM0GQcR tweF1CZT2GBGoAR2WxSN1zcd6Q6wg/g2lHD/7UZPvPY+5dUl55IE+4nm+HAUi4t6Fm ZRkJ0zkh4cO/ZR4LssRXn0dlRNBbGkdID4iVo+8I= Date: Mon, 26 Sep 2022 19:48:23 -0700 To: mm-commits@vger.kernel.org, ying.huang@intel.com, weixugc@google.com, tim.c.chen@intel.com, sj@kernel.org, shy828301@gmail.com, mhocko@kernel.org, jvgediya.oss@gmail.com, Jonathan.Cameron@huawei.com, hesham.almatary@huawei.com, hannes@cmpxchg.org, dave@stgolabs.net, dave.hansen@intel.com, dan.j.williams@intel.com, bharata@amd.com, apopple@nvidia.com, aneesh.kumar@linux.ibm.com, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] mm-demotion-update-node_is_toptier-to-work-with-memory-tiers.patch removed from -mm tree Message-Id: <20220927024824.6E3F2C433D7@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The quilt patch titled Subject: mm/demotion: update node_is_toptier to work with memory tiers has been removed from the -mm tree. Its filename was mm-demotion-update-node_is_toptier-to-work-with-memory-tiers.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: "Aneesh Kumar K.V" Subject: mm/demotion: update node_is_toptier to work with memory tiers Date: Thu, 18 Aug 2022 18:40:41 +0530 With memory tier 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(slower) memory tiers added we consider all memory tiers above a memory tier having CPU NUMA nodes as a top memory tier [sj@kernel.org: include missed header file, memory-tiers.h] Link: https://lkml.kernel.org/r/20220820190720.248704-1-sj@kernel.org [akpm@linux-foundation.org: mm/memory.c needs linux/memory-tiers.h] [aneesh.kumar@linux.ibm.com: make toptier_distance inclusive upper bound of toptiers] Link: https://lkml.kernel.org/r/20220830081457.118960-1-aneesh.kumar@linux.ibm.com Link: https://lkml.kernel.org/r/20220818131042.113280-10-aneesh.kumar@linux.ibm.com Signed-off-by: Aneesh Kumar K.V Reviewed-by: "Huang, Ying" Acked-by: Wei Xu Cc: Alistair Popple Cc: Bharata B Rao Cc: Dan Williams Cc: Dave Hansen Cc: Davidlohr Bueso Cc: Hesham Almatary Cc: Jagdish Gediya Cc: Johannes Weiner Cc: Jonathan Cameron Cc: Michal Hocko Cc: Tim Chen Cc: Yang Shi Cc: SeongJae Park Signed-off-by: Andrew Morton --- include/linux/memory-tiers.h | 11 +++++++ include/linux/node.h | 5 --- kernel/sched/fair.c | 1 mm/huge_memory.c | 1 mm/memory-tiers.c | 47 +++++++++++++++++++++++++++++++++ mm/memory.c | 1 mm/migrate.c | 1 mm/mprotect.c | 1 8 files changed, 63 insertions(+), 5 deletions(-) --- a/include/linux/memory-tiers.h~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/include/linux/memory-tiers.h @@ -40,6 +40,7 @@ void clear_node_memory_type(int node, st #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) { @@ -50,6 +51,11 @@ static inline void node_get_allowed_targ { *targets = NODE_MASK_NONE; } + +static inline bool node_is_toptier(int node) +{ + return true; +} #endif #else @@ -87,5 +93,10 @@ static inline void node_get_allowed_targ { *targets = NODE_MASK_NONE; } + +static inline bool node_is_toptier(int node) +{ + return true; +} #endif /* CONFIG_NUMA */ #endif /* _LINUX_MEMORY_TIERS_H */ --- a/include/linux/node.h~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/include/linux/node.h @@ -185,9 +185,4 @@ static inline void register_hugetlbfs_wi #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_ */ --- a/mm/huge_memory.c~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/mm/huge_memory.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include --- a/mm/memory-tiers.c~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/mm/memory-tiers.c @@ -37,6 +37,7 @@ static LIST_HEAD(memory_tiers); static struct node_memory_type_map node_memory_types[MAX_NUMNODES]; static struct memory_dev_type *default_dram_type; #ifdef CONFIG_MIGRATION +static int top_tier_adistance; /* * node_demotion[] examples: * @@ -162,6 +163,31 @@ static struct memory_tier *__node_get_me } #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->adistance_start <= top_tier_adistance) + 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; @@ -320,6 +346,27 @@ static void establish_demotion_targets(v } 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) { + tier_nodes = get_memtier_nodemask(memtier); + nodes_and(tier_nodes, node_states[N_CPU], tier_nodes); + if (!nodes_empty(tier_nodes)) { + /* + * abstract distance below the max value of this memtier + * is considered toptier. + */ + top_tier_adistance = memtier->adistance_start + + MEMTIER_CHUNK_SIZE - 1; + break; + } + } + /* * Now build the lower_tier mask for each node collecting node mask from * all memory tier below it. This allows us to fallback demotion page * allocation to a set of nodes that is closer the above selected --- a/mm/migrate.c~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/mm/migrate.c @@ -50,6 +50,7 @@ #include #include #include +#include #include --- a/mm/mprotect.c~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/mm/mprotect.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include --- a/kernel/sched/fair.c~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/kernel/sched/fair.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include --- a/mm/memory.c~mm-demotion-update-node_is_toptier-to-work-with-memory-tiers +++ a/mm/memory.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include _ Patches currently in -mm which might be from aneesh.kumar@linux.ibm.com are