Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1393274rwb; Thu, 11 Aug 2022 23:23:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mRTJJDZGy+g0rJep44e67flghSYbo/7p+LWbt4vx+N6owkKB6zDEOU4U2f0v35Ya+sJH4 X-Received: by 2002:aa7:c1d0:0:b0:43c:f89f:a134 with SMTP id d16-20020aa7c1d0000000b0043cf89fa134mr2224828edp.4.1660285420321; Thu, 11 Aug 2022 23:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660285420; cv=none; d=google.com; s=arc-20160816; b=T8euv98eQL0lUNg879848eqH6OROYZvTj1Om/emDOGTQdhfsxUwlfDbkQwbNhlx524 cry9suOeUKqAKcxQYLmTWe0e1fh1P/JP8jjXfw/Uc/T94OxKMMidhcBWuXDe5rFZhpF0 i67+M9eFGatopnlH52zF/hEgNf0Gl5ddTckg8Ay0Eab8Z8XsDRp+bJKxBsyCCj5VD2DP 6nDrRuXGLM6gtFthulO7EUJCu5x6TSjCLiHuseIYmhZUR9vXK/1qJGcGj3e0NeBGLXUX 2540W+jxfsPxRpOaM2MLOXfxMzsIk9iypncg21b9ijfDeuIZDnTKJ/sQXVj4Zv3mFHwv 9EkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TEXzQrkoWkfpWIYMlURGzW1J4m7v0vVBhMH3v/YjR9I=; b=ZT6pF2UnkjJV7QJD4P5O68u42OQFQlW+QztBbwaGprvUggXD/I/pjNlk/N6jaB4AM/ RGhtQRm1Bivniz2pqiPqiB4Cqa4Hg5VeGyZEU8xegMryL/JIUUiho7/2RujrvLzd5l4W g1ZxF2ePxK0CW6kslcfIVDIegXbfHlJwMle7hvzUdHFREr6zvqty9k74kJwXg+NEBO8L y4fS1+vDVyip3qUELPKYKtBnSnnzHiBL9EsXJbdNCmtMVRXTXIrPhJX8p/Wrae6WiD3/ jfW33eEZdlaJNF3OJo78EvbUFyM0IsLm9ZKYF4c0uu6Z+rFIr9T+t/16kD+IPgQdKX60 4moQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WdBieX6D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a170906528100b00730937fad20si1084882ejm.97.2022.08.11.23.23.15; Thu, 11 Aug 2022 23:23:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WdBieX6D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237117AbiHLF7G (ORCPT + 99 others); Fri, 12 Aug 2022 01:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237164AbiHLF6j (ORCPT ); Fri, 12 Aug 2022 01:58:39 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B308A4B06 for ; Thu, 11 Aug 2022 22:58:31 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27C5lBol000700; Fri, 12 Aug 2022 05:58:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=TEXzQrkoWkfpWIYMlURGzW1J4m7v0vVBhMH3v/YjR9I=; b=WdBieX6DOMCmDkuCao/Z+WFcp2p0JZEu6IdnzreIPxZxrlX/BLgMrP0zxWlUDNj1MTIA /etSsogG4XN008exH+7uCoI8pJRMNmEEVZa1ROAZOp9slnAsmkLZi2lG6kbhzXG/bj8u zHEOzd4fTFdnHYpXL9YSRTHXRqKY5z5shm8JfKGBKOStxMUPaQK22AAbcM3UtJBUZ0cb XMJi3r0Dmjkf40rtDsQX2PvNXJccjwRGkxrLcgN/mpKh5CbBN0MA9NKTRmyc2XgiVtzR qLBAUzX5jObOMEvl4k15ByFVy/RvHtcsWgP1u3gsP1MlWdX0dbP7nQUNKD1J5mRsorDf 0w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hwh1787hr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 05:58:20 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 27C5v06i033896; Fri, 12 Aug 2022 05:58:20 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hwh1787h9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 05:58:20 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 27C5b9Kh017978; Fri, 12 Aug 2022 05:58:19 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02dal.us.ibm.com with ESMTP id 3hvkjhb2nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 05:58:19 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 27C5wI7Z60621060 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Aug 2022 05:58:18 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 13EBE7805E; Fri, 12 Aug 2022 05:58:18 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FA2878063; Fri, 12 Aug 2022 05:58:12 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.116.179]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 12 Aug 2022 05:58:12 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: Wei Xu , Huang Ying , Yang Shi , Davidlohr Bueso , Tim C Chen , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Johannes Weiner , jvgediya.oss@gmail.com, Bharata B Rao , "Aneesh Kumar K.V" Subject: [PATCH v14 09/10] mm/demotion: Update node_is_toptier to work with memory tiers Date: Fri, 12 Aug 2022 11:27:08 +0530 Message-Id: <20220812055710.357820-10-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220812055710.357820-1-aneesh.kumar@linux.ibm.com> References: <20220812055710.357820-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: W8Se9rfbhWRPW6j73iI2MzV1AmVn2MtI X-Proofpoint-ORIG-GUID: i3JMutiuEZr_Ke_MLwwpxsdBVY_dPZca X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-12_04,2022-08-11_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 bulkscore=0 adultscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 impostorscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208120015 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Aneesh Kumar K.V --- include/linux/memory-tiers.h | 11 +++++++++ include/linux/node.h | 5 ---- mm/huge_memory.c | 1 + mm/memory-tiers.c | 46 ++++++++++++++++++++++++++++++++++++ mm/migrate.c | 1 + mm/mprotect.c | 1 + 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h index 6fdff436c205..9198d69afaa9 100644 --- a/include/linux/memory-tiers.h +++ b/include/linux/memory-tiers.h @@ -37,6 +37,7 @@ void clear_node_memory_type(int node, struct memory_dev_type *memtype); #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) { @@ -47,6 +48,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 @@ -84,5 +90,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 40d641a8bfb0..9ec680dd607f 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -185,9 +185,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 8a7c1b344abe..1e9357576f2d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index 2db4b4116a28..165ebbbac30d 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -32,6 +32,7 @@ static LIST_HEAD(memory_tiers); static struct memory_dev_type *node_memory_types[MAX_NUMNODES]; static struct memory_dev_type *default_dram_type; #ifdef CONFIG_MIGRATION +static int top_tier_adistance; /* * node_demotion[] examples: * @@ -157,6 +158,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->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; @@ -314,6 +340,26 @@ static void establish_demotion_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) { + 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; + 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 diff --git a/mm/migrate.c b/mm/migrate.c index ea86594f4bc5..55e7718cfe45 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -50,6 +50,7 @@ #include #include #include +#include #include diff --git a/mm/mprotect.c b/mm/mprotect.c index 3a23dde73723..61cd80831b04 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include -- 2.37.1