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 0C627C00144 for ; Fri, 29 Jul 2022 06:39:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 701E36B0071; Fri, 29 Jul 2022 02:39:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B19D6B0072; Fri, 29 Jul 2022 02:39:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 578A08E0001; Fri, 29 Jul 2022 02:39:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4CF856B0071 for ; Fri, 29 Jul 2022 02:39:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 23F181A1198 for ; Fri, 29 Jul 2022 06:39:33 +0000 (UTC) X-FDA: 79739186226.06.0223D8C Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf06.hostedemail.com (Postfix) with ESMTP id 642EE1800AD for ; Fri, 29 Jul 2022 06:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659076772; x=1690612772; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=QxPIsZYp1dzDk4XgY8+hubI+o2ZQeHuKi4/q6YVnXDU=; b=Yab9+f4wS6ghxC3ySZ/aPZvoCFjOHzGVg3ijDp91ct013LfJ2o023F0W 45WZVRzRlGYHX8h+jf5xI1h7lAAG23jG90hKIQVVqsS5emfeLxzM3FF7G r47a5xO1oRJc0tmTrV5QrT8Se8bz6IeVjBy+vTzieRGBiP1qvNvqZ65M+ /Q9gQM3PGzxH5JEhDk8Q62JuhgnMpkJ802U74Yp3KJ2nnqp5heIEapSNi X8VF6Q0EUxraYNBK0UF0NLPj9lYa0IMxn8yaE+k1KI/8c91ZyPfyEeNXq TKxe3c4lQ33FK0WOBKaWXUCnXur0bZJWql2EMWH+pthG43ReDDK/4t8dW Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10422"; a="375007493" X-IronPort-AV: E=Sophos;i="5.93,200,1654585200"; d="scan'208";a="375007493" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2022 23:39:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,200,1654585200"; d="scan'208";a="690640882" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2022 23:39:27 -0700 From: "Huang, Ying" To: "Aneesh Kumar K.V" 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 Subject: Re: [PATCH v11 8/8] mm/demotion: Update node_is_toptier to work with memory tiers References: <20220728190436.858458-1-aneesh.kumar@linux.ibm.com> <20220728190436.858458-9-aneesh.kumar@linux.ibm.com> Date: Fri, 29 Jul 2022 14:39:23 +0800 In-Reply-To: <20220728190436.858458-9-aneesh.kumar@linux.ibm.com> (Aneesh Kumar K. V.'s message of "Fri, 29 Jul 2022 00:34:36 +0530") Message-ID: <87sfmkl8x0.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659076772; a=rsa-sha256; cv=none; b=BeccfSPjnlC46nWNfL9nPOootqbtNMu/3NOq2hEssXSSlAvAptzu3uw7mGpHd/esi3KHLu 5KdjJ7hRPTmf9yeVcBV8mWEuMwj2ylcLyK89r0XCSDnpWgkweAy3+H0x3GSprljwJxcMMK iFJGKYMq8LGJ0Ie1XGKTPxVTeBN5tKk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Yab9+f4w; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf06.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659076772; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mD++4C7Dtl0n76EmJBmhP/xxwObb1Xvb/ASmYc/2nLw=; b=T2lC9bkW+KCxlj0L68FsDVoQ2+TPAN3UzZhA7lrDIyLbXYm0Mb9hQPT5vY3dxMV0YphFkX q32T7rJshPemlLkEhe7w4k+R/IpcnQm+nQiE/9hsNiqW18y5tqhdXBypNLJ2fPXrIdQ3V2 o4/TdxniYt+5eajTmuxCFK0dohelVDA= X-Rspamd-Queue-Id: 642EE1800AD X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Yab9+f4w; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf06.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com X-Rspamd-Server: rspam09 X-Stat-Signature: qc4u5bns6z3jddhp545r3xofhpfjsqs8 X-HE-Tag: 1659076772-716843 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: "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; Best Regards, Huang, Ying > + 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 c758c9c21d7d..1da81136eaaa 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