Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4621544iog; Wed, 22 Jun 2022 02:29:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sd2rzrOCWNEflADwrsPAVOlnD3hScu5ucq8RTid76LuHi2Iq8bC6ao6Qndq9d8XRiDlFEz X-Received: by 2002:a65:6bd4:0:b0:405:2d64:532c with SMTP id e20-20020a656bd4000000b004052d64532cmr2121898pgw.179.1655890198611; Wed, 22 Jun 2022 02:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655890198; cv=none; d=google.com; s=arc-20160816; b=QNiThOk+5epKWADd9pX5yLUPjfjb/9FcIO0I1EFXTfkQWxpWtgreiAwcCNLXvWl4Hw skH0bUKJfiMQoIp9lUH6VuZNzW8M3dsGBoSy9vzN3SIwyZVCsYaX3BJZQirrahLi7Ugd SAc9rXt2C8hIo/J1/vkYfSobpoTTtKgonFjiMDozp6YHK5Ztt8p+GVyd7zeTgCrC3BJw 24+kjMF4Xk+gkTzdqHOmUvRA/TdBMoHGaSMCiRb5j77nX88YPmqzLVzEq0USNHRxogIN jCvQ/HAeoaNkw7Wa9WiWPm2sEcJDSW8bea+KJj7rnJLzsjONneO99NNuL+wAa7fx5HTN /3Hg== 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=eG05JCLiolZtdBqK9JEVqCDLmzV0NLM/SBILo4e+8PI=; b=KukdrPsJsRCHx0SANbnZKTbIuljx+hqMyzz6tKWFzV7aFrFSj2PIJAQaIoMkxd4w32 fL5hIpzLujeHOLZEijBuXuDnjlzuQdZDLN3egRUAMIUauXkasRrfI99RL73MqAcTmGV2 3agZxXUjrZ6Hg36KSGTVNKDTIn43JfN4Y+fzUmlfO0O/ZK2AzukX8N+h4CZ725Hxgxz8 ybOkbHnKYVFJYGdR0MMP5KclQ22Sr1dzAXhcpBGc4X/+9S6xISdCxctDtfRpZ5h9d1zn y6SbyJAKnBOInnHjf4yW1XI38uwCng7OirwcfrYFWDnsy98TD5pQRt6EO1MBDGTzyE08 06Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Rsyh0y5k; 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 f5-20020a17090aa78500b001e851c352easi25224459pjq.135.2022.06.22.02.29.46; Wed, 22 Jun 2022 02:29:58 -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=Rsyh0y5k; 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 S1352705AbiFVI1j (ORCPT + 99 others); Wed, 22 Jun 2022 04:27:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352297AbiFVI1M (ORCPT ); Wed, 22 Jun 2022 04:27:12 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5A2138BCF for ; Wed, 22 Jun 2022 01:26:45 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25M7Vc2N004423; Wed, 22 Jun 2022 08:26:37 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=eG05JCLiolZtdBqK9JEVqCDLmzV0NLM/SBILo4e+8PI=; b=Rsyh0y5k8lmcqf/M+0FSG64Iab6xWp+ie8lFcKTrbLHTtjMht51cZPCRCxrZVySAx/Oi u7HH5MSBST199+ft9gfhE7QseGEkMSx92RiV4ZgJvKM7RzHf7HJysc02Qi56+72PxEyn MP8arOlH+Oc+D6F4n6PLpqN2NrVTAxtHjihA09Si2ZSxk5gf07qNhuclpORBdOmcdZKn xNELpfOfiRErw8j1wKFg6QNEr2MGHyFD+ZW7EeEfPglDgrN4d0lrGuVpsvxnyelwh9s8 gEIQfVYcAp7Ds+NJ67O8ekfkB6l3MkFD2LzjUgsxQ9EKBBohHBcjx36wT4AhueTgMXhN tQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3guxs5he3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jun 2022 08:26:36 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25M7tmbA010830; Wed, 22 Jun 2022 08:26:36 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 3guxs5he36-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jun 2022 08:26:36 +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 25M8JxVV003300; Wed, 22 Jun 2022 08:26:35 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02dal.us.ibm.com with ESMTP id 3gt0098rbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jun 2022 08:26:35 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25M8QYrH36503906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Jun 2022 08:26:34 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00AC06E050; Wed, 22 Jun 2022 08:26:34 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A8BB6E04E; Wed, 22 Jun 2022 08:26:28 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.69.226]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 22 Jun 2022 08:26:28 +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 , "Aneesh Kumar K.V" Subject: [PATCH v7 10/12] mm/demotion: Update node_is_toptier to work with memory tiers Date: Wed, 22 Jun 2022 13:55:11 +0530 Message-Id: <20220622082513.467538-11-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622082513.467538-1-aneesh.kumar@linux.ibm.com> References: <20220622082513.467538-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: zkQjAXAatpbBVjQaWRmhi_DSH-rW1i0B X-Proofpoint-ORIG-GUID: JfQk3jbXycLFIj3GuRJ4NFX8VzknRIwt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-21_11,2022-06-21_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206220039 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 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 --- include/linux/memory-tiers.h | 6 ++++++ include/linux/node.h | 5 ----- mm/huge_memory.c | 1 + mm/memory-tiers.c | 41 ++++++++++++++++++++++++++++++++++++ mm/migrate.c | 1 + mm/mprotect.c | 1 + 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h index 335d21a30b2c..ff1a08933575 100644 --- a/include/linux/memory-tiers.h +++ b/include/linux/memory-tiers.h @@ -44,6 +44,7 @@ int node_get_memory_tier_id(int node); int node_update_memory_tier(int node, int tier); struct memory_tier *node_get_memory_tier(int node); void node_put_memory_tier(struct memory_tier *memtier); +bool node_is_toptier(int node); #else @@ -62,5 +63,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 f7248002dad9..88f3288c8be0 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index aecce987df7c..7204f7381a15 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -18,6 +18,7 @@ struct demotion_nodes { static void establish_migration_targets(void); static DEFINE_MUTEX(memory_tier_lock); static LIST_HEAD(memory_tiers); +static int top_tier_id; /* * node_demotion[] examples: * @@ -373,6 +374,31 @@ void node_put_memory_tier(struct memory_tier *memtier) put_device(&memtier->dev); } +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->dev.id >= top_tier_id) + toptier = true; + else + toptier = false; +out: + rcu_read_unlock(); + return toptier; +} + #ifdef CONFIG_MIGRATION void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets) { @@ -545,6 +571,21 @@ static void establish_migration_targets(void) } while (1); } build_lower_tier_mask: + /* + * 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->dev.id; + 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 0b554625a219..78615c48fc0f 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 ba5592655ee3..92a2fc0fa88b 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include -- 2.36.1