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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21784C00144 for ; Fri, 29 Jul 2022 06:42:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 926878E0001; Fri, 29 Jul 2022 02:42:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D5466B0073; Fri, 29 Jul 2022 02:42:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 775C18E0001; Fri, 29 Jul 2022 02:42:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 65F5D6B0072 for ; Fri, 29 Jul 2022 02:42:40 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 375C0C160C for ; Fri, 29 Jul 2022 06:42:40 +0000 (UTC) X-FDA: 79739194080.25.A7461CD Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf29.hostedemail.com (Postfix) with ESMTP id 370C41200A1 for ; Fri, 29 Jul 2022 06:42:38 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T6RcqC010283; Fri, 29 Jul 2022 06:42:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=kj0Kk/lxUhod21OuHXXtIfLlVCej2PwE34+4rV/c62Y=; b=DZxTUrWeTvF1ebr1oPqYSsLMTYYoEv4U4QD3F8m0c7oX+9OpYx9j3sh7iJx+gJVjV6Z1 YolN+Q+I6cOd0m7jT/f9T7TdvHiZcs6R6wv9vBXKhiknIqAzVVbgAMXU4NXreWbRAkUc fmseElkCqrElaPCGmZzSnMCxiddjjON7y652NKQb4Q8Q+ba2aHdfbRdBovXge8UD/7mr 0ht9KxLbB032MDj7sTfQ4riY9ZRTZP4tyK/zRc/6xtbpc+mDuJkouod0AHU1lCl6ILbs Iw86sC0Pit3feEnCBdMR2TD6DbL202Sc2R3GQ8/+Lm2rrYuoAUCN7FLt6BF+aUQ/Z6BF Ow== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmaa5gnkh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 06:42:25 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T6SCs1011635; Fri, 29 Jul 2022 06:42:25 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmaa5gnjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 06:42:24 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26T6a9pS018740; Fri, 29 Jul 2022 06:42:22 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3hg96wq88s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 06:42:22 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26T6gJUA29491520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jul 2022 06:42:20 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9CCBAE04D; Fri, 29 Jul 2022 06:42:19 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BCEC2AE045; Fri, 29 Jul 2022 06:42:16 +0000 (GMT) Received: from [9.43.86.244] (unknown [9.43.86.244]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 29 Jul 2022 06:42:16 +0000 (GMT) Message-ID: <9fa09da8-eff7-e39a-96b0-2bc51711f08f@linux.ibm.com> Date: Fri, 29 Jul 2022 12:11:39 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v11 8/8] mm/demotion: Update node_is_toptier to work with memory tiers Content-Language: en-US To: "Huang, Ying" Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Wei Xu , 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 References: <20220728190436.858458-1-aneesh.kumar@linux.ibm.com> <20220728190436.858458-9-aneesh.kumar@linux.ibm.com> <87sfmkl8x0.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Aneesh Kumar K V In-Reply-To: <87sfmkl8x0.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: lfdallBhMO1H6FWSmHLaDOuXYeEgYnI6 X-Proofpoint-ORIG-GUID: kXmSMPVDVJP0XA-g3U3awcWmjBtVh5Ke 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-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 phishscore=0 mlxscore=0 clxscore=1015 malwarescore=0 impostorscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290026 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659076959; a=rsa-sha256; cv=none; b=tGBvmZhs8gvYvfo8uEwDumVqT3qMZ9SuixO/LDpUchf0cG/81WTbxtb8+H+sJ09VRG7Sxb 695/C/eg8MtXg9Fw661S5x57RS45/CDkWYb8PLm6Dd9QzUA71y0WeV14BC0i+Qg+fFHNt9 VGk0HiNR4XOaSYxAOBtdBrV8PiIqzeU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=DZxTUrWe; spf=pass (imf29.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659076959; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kj0Kk/lxUhod21OuHXXtIfLlVCej2PwE34+4rV/c62Y=; b=3AwqEoUgFcTnfBhQlnJc4dmKMNJEOm+5wvVJx1t+dgqdvKXViL/Umw7pwwMchNafRAxhOq 0hBnOuPeRkW3POzJgbWPIif1ZtgMpL9FHjq1UeajUXiqJVtPAVg7cWPRtRfWVDxmhHizB4 T30FtIhPkwzC2Q7BTNhXojBGT5t2jGs= Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=DZxTUrWe; spf=pass (imf29.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 370C41200A1 X-Stat-Signature: db44hpmqysunfq5gn6rn45rfob3yahoc X-HE-Tag: 1659076958-175316 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: On 7/29/22 12:09 PM, Huang, Ying wrote: > "Aneesh Kumar K.V" 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 >> --- >> include/linux/memory-tiers.h | 11 ++++++++++ >> include/linux/node.h | 5 ----- >> mm/huge_memory.c | 1 + >> mm/memory-tiers.c | 42 ++++++++++++++++++++++++++++++++++++ >> mm/migrate.c | 1 + >> mm/mprotect.c | 1 + >> 6 files changed, 56 insertions(+), 5 deletions(-) >> >> diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h >> index f8dbeda617a7..bc9fb9d39b2c 100644 >> --- a/include/linux/memory-tiers.h >> +++ b/include/linux/memory-tiers.h >> @@ -35,6 +35,7 @@ struct memory_dev_type *init_node_memory_type(int node, struct memory_dev_type * >> #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) >> { >> @@ -45,6 +46,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 >> @@ -64,5 +70,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 834f288b3769..8405662646e9 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 84e2be31a853..36d87dc422ab 100644 >> --- a/mm/memory-tiers.c >> +++ b/mm/memory-tiers.c >> @@ -30,6 +30,7 @@ static DEFINE_MUTEX(memory_tier_lock); >> static LIST_HEAD(memory_tiers); >> struct memory_dev_type *node_memory_types[MAX_NUMNODES]; >> #ifdef CONFIG_MIGRATION >> +static int top_tier_adistance; >> /* >> * node_demotion[] examples: >> * >> @@ -159,6 +160,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; >> @@ -315,6 +341,22 @@ 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 on is not allowed. >> + */ >> + list_for_each_entry(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)) { >> + top_tier_adistance = memtier->adistance_start; > > IMHO, this should be, > > top_tier_adistance = memtier->adistance_start + MEMTIER_CHUNK_SIZE; > Good catch. Will update. BTW i did send v12 version of the patchset already to the list. -aneesh