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 88163C433EF for ; Mon, 25 Jul 2022 08:54:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8F0B940009; Mon, 25 Jul 2022 04:54:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3E968E0001; Mon, 25 Jul 2022 04:54:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0614940009; Mon, 25 Jul 2022 04:54:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AEB7C8E0001 for ; Mon, 25 Jul 2022 04:54:22 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9022A8030B for ; Mon, 25 Jul 2022 08:54:22 +0000 (UTC) X-FDA: 79725010764.02.0A91185 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf30.hostedemail.com (Postfix) with ESMTP id 8E281800BB for ; Mon, 25 Jul 2022 08:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658739261; x=1690275261; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=OrzwBXpnNbo5Nk2jFhqfvGwcX5FcuWicAaomGIwDPHo=; b=jIAgdPvqrLMUPAocGZ71is0OKLpqFXrYZSqt39Rsj1KcAp9SyFofITJ5 R8Enksh8xmY+0GzRGxpjU9ff0c9vr5PeBQc80lbiAkTL2kkt6Soc/An6H JEhbKEJgqxw1fQlNPzO695RylqgnTVcyzAwd3nhk7tCnPjEcFr8+TibgC R+SVRNVUDcMo9EX8UkSfd76HzNIGng6T2t20vK6mPg0cKhYPadDzbbdbK ooGu8eMMuSsYhJtpSqeVgAm9jwuS17j2VdBAn7bf038tV8rbp9mAXxRvx 2oDo5uscp0Mp5Cu7TfjqUAHDz+xudAOz+7Wh1/yPHh3HWTwaUMW87Uqu6 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="267421954" X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="267421954" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 01:54:20 -0700 X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="632283294" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 01:54:16 -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 v10 8/8] mm/demotion: Update node_is_toptier to work with memory tiers References: <20220720025920.1373558-1-aneesh.kumar@linux.ibm.com> <20220720025920.1373558-9-aneesh.kumar@linux.ibm.com> Date: Mon, 25 Jul 2022 16:54:11 +0800 In-Reply-To: <20220720025920.1373558-9-aneesh.kumar@linux.ibm.com> (Aneesh Kumar K. V.'s message of "Wed, 20 Jul 2022 08:29:20 +0530") Message-ID: <87ilnly3m4.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658739262; 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=X1hh871wvEDhZ1ODts4Zqkr+hqUzwnx5QI/Q7twpJPM=; b=NaX80GTVYu5oDO0zKYhHF8ZjScgL1zx0YoLM4WOyYsEp8AXT2GlX4RmW1C5rLpOazwBDqT r5dB7F+UM2OfqHrVSnSf+rI33+9+Vn9fDG5W/+kU1/v6kvs1KZpVG8ztWiuKuwJM2vrPj/ XL20O5POEWVJ1j/VfSdME2CUV4/6WrI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jIAgdPvq; spf=none (imf30.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.136) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658739262; a=rsa-sha256; cv=none; b=NZUuFcWUnZeVZVJe5aYtv1Esrriig9XuuM8fiZlqFuPr5ZyMg1EFBELDkEgY7iU2tmQk84 6XSTFL+ibTjCJj5vdmHaNtgNnUKHpKXIdWA50yUePoxW76i6QYnZ5jmIBTPRySN+B/EexB Cc09YNkqAPwKEKku/NJgrcnHFp5WAR0= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8E281800BB X-Stat-Signature: mey8c7yif864ab4zxzf5k651urj3nhaj X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jIAgdPvq; spf=none (imf30.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.136) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1658739261-167995 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 | 43 ++++++++++++++++++++++++++++++++++++ > mm/migrate.c | 1 + > mm/mprotect.c | 1 + > 6 files changed, 57 insertions(+), 5 deletions(-) > > diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h > index 0e58588fa066..085dd815bf73 100644 > --- a/include/linux/memory-tiers.h > +++ b/include/linux/memory-tiers.h > @@ -20,6 +20,7 @@ extern bool numa_demotion_enabled; > #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) > { > @@ -30,6 +31,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 > @@ -44,5 +50,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 a2a16d4104fd..d0432db18094 100644 > --- a/include/linux/node.h > +++ b/include/linux/node.h > @@ -191,9 +191,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 4a96e4213d66..f0515bfd4051 100644 > --- a/mm/memory-tiers.c > +++ b/mm/memory-tiers.c > @@ -13,6 +13,7 @@ > > struct memory_tier { > struct list_head list; > + int id; > int perf_level; > nodemask_t nodelist; > nodemask_t lower_tier_mask; > @@ -26,6 +27,7 @@ static LIST_HEAD(memory_tiers); > static DEFINE_MUTEX(memory_tier_lock); > > #ifdef CONFIG_MIGRATION > +static int top_tier_id; > /* > * node_demotion[] examples: > * > @@ -129,6 +131,7 @@ static struct memory_tier *find_create_memory_tier(unsigned int perf_level) > if (!new_memtier) > return ERR_PTR(-ENOMEM); > > + new_memtier->id = perf_level >> MEMTIER_CHUNK_BITS; > new_memtier->perf_level = perf_level; > if (found_slot) > list_add_tail(&new_memtier->list, ent); > @@ -154,6 +157,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->id >= top_tier_id) > + 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; > @@ -304,6 +332,21 @@ static void establish_migration_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) { > + nodes_and(used, node_states[N_CPU], memtier->nodelist); > + if (!nodes_empty(used)) { > + top_tier_id = memtier->id; I don't think we need to introduce memory tier ID for this. We can add a top_tier_perf_level, set it here and use it in node_is_toptier(). 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