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 19FC1C43334 for ; Tue, 26 Jul 2022 04:04:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DD038E0002; Tue, 26 Jul 2022 00:04:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6656A8E0001; Tue, 26 Jul 2022 00:04:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B77E8E0002; Tue, 26 Jul 2022 00:04:09 -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 35B8D8E0001 for ; Tue, 26 Jul 2022 00:04:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D4EEDC06E5 for ; Tue, 26 Jul 2022 04:04:08 +0000 (UTC) X-FDA: 79727908176.14.A4DF97E Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf30.hostedemail.com (Postfix) with ESMTP id E623E800C1 for ; Tue, 26 Jul 2022 04:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658808247; x=1690344247; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=oVa3FHsyt3TXJj0D7uZDaBI94swmdsKGF+L8lychpBU=; b=hkG6hwnQmhN0D0Z4t605vc3k9g+L/W1vyYVWAktU9whw2zXEga3+2V0G lO5vMao/vN3ZCChdZnEXZYbFWIH3sfaY2jLicPdvQRRUeCDnT9AnTEo4S Ly6pDWCdDpB+EksR2K8CW93KvNHgLZcZIPYMxHnodorXdtTp/Klfr166z PEJeZ+vUFjH8iwV2ZgD3v66jdgFH0fZ5HTOsVlTXFlHPQf+G3hDnBFGKA oJ2xaaVeVF8qoqvGChvZFxTNyYP/jGWNLCTxv5cb3q1k1qGarsq/BKbj1 t2EpE6ALmMApy8dzJU9yNBWjwhlMXuS9+RXFMlQwV3RCjWxW7No6qKFeB A==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="349555320" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="349555320" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 21:04:06 -0700 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="575326791" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 21:04:02 -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 3/8] mm/demotion: Add hotplug callbacks to handle new numa node onlined References: <20220720025920.1373558-1-aneesh.kumar@linux.ibm.com> <20220720025920.1373558-4-aneesh.kumar@linux.ibm.com> Date: Tue, 26 Jul 2022 12:03:58 +0800 In-Reply-To: <20220720025920.1373558-4-aneesh.kumar@linux.ibm.com> (Aneesh Kumar K. V.'s message of "Wed, 20 Jul 2022 08:29:15 +0530") Message-ID: <87fsiowmdt.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=1658808248; a=rsa-sha256; cv=none; b=P7xUWg0v3WZJkuoZp2hexdRiaQA/YdKxNcyk0w9rLsrwRoJCk5E6SOcjJ30DpEBSD3TXSe GqMcn/s71SLeXKEDoCJsRgD4Z1UY/7vqWJsTTx9MfubuRpIUtYDGlf/r6kTYPa15N7+FFp xyr4KPvPEBRBVrKkCiRQK9ZIWTvQGnM= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=hkG6hwnQ; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf30.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658808248; 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=/TVqKG7Gsc0nLj3cuBmCsz0nZKt1oYnBHRGFeeQkCwc=; b=Nuip7maCTxmpS/iz5bVa1fYnnAmTk5u76dA+co/SrwFj52f8fAVRYYCc51umgEeFi2M6gR +W+kSBXk7OVVMdpI6v8sk3LdcO865GwDOSvDI+LL2NtMrnAXfmbMypv4cBBMVur5Hji2aC 1FyjUAqzocxGSJksJtVLiMlVqC7adj8= X-Rspamd-Queue-Id: E623E800C1 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=hkG6hwnQ; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf30.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=ying.huang@intel.com X-Stat-Signature: 47w5hq4gx7rq75bt8uj84jw7ogkyb954 X-Rspamd-Server: rspam03 X-HE-Tag: 1658808247-241789 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: > If the new NUMA node onlined doesn't have a performance level assigned, > the kernel adds the NUMA node to default memory tier. > > Signed-off-by: Aneesh Kumar K.V > --- > include/linux/memory-tiers.h | 1 + > mm/memory-tiers.c | 75 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 76 insertions(+) > > diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h > index ef380a39db3a..3d5f14d57ae6 100644 > --- a/include/linux/memory-tiers.h > +++ b/include/linux/memory-tiers.h > @@ -14,6 +14,7 @@ > #define MEMTIER_PERF_LEVEL_DRAM (1 << (MEMTIER_CHUNK_BITS + 2)) > /* leave one tier below this slow pmem */ > #define MEMTIER_PERF_LEVEL_PMEM (1 << MEMTIER_CHUNK_BITS) > +#define MEMTIER_HOTPLUG_PRIO 100 > > extern bool numa_demotion_enabled; > > diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c > index 41a21cc5ae55..cc3a47ec18e4 100644 > --- a/mm/memory-tiers.c > +++ b/mm/memory-tiers.c > @@ -5,6 +5,7 @@ > #include > #include > #include > +#include > #include > > struct memory_tier { > @@ -64,6 +65,78 @@ static struct memory_tier *find_create_memory_tier(unsigned int perf_level) > return new_memtier; > } > > +static struct memory_tier *__node_get_memory_tier(int node) > +{ > + struct memory_tier *memtier; > + > + list_for_each_entry(memtier, &memory_tiers, list) { > + if (node_isset(node, memtier->nodelist)) > + return memtier; > + } > + return NULL; > +} > + > +static void init_node_memory_tier(int node) set_node_memory_tier()? > +{ > + int perf_level; > + struct memory_tier *memtier; > + > + mutex_lock(&memory_tier_lock); > + > + memtier = __node_get_memory_tier(node); > + if (!memtier) { > + perf_level = node_devices[node]->perf_level; > + memtier = find_create_memory_tier(perf_level); > + node_set(node, memtier->nodelist); > + } > + mutex_unlock(&memory_tier_lock); > +} > + > +static void clear_node_memory_tier(int node) > +{ > + struct memory_tier *memtier; > + > + mutex_lock(&memory_tier_lock); > + memtier = __node_get_memory_tier(node); > + if (memtier) > + node_clear(node, memtier->nodelist); When memtier->nodelist becomes empty, we need to free memtier? > + mutex_unlock(&memory_tier_lock); > +} > + > +/* > + * This runs whether reclaim-based migration is enabled or not, > + * which ensures that the user can turn reclaim-based migration > + * at any time without needing to recalculate migration targets. > + */ The comments doesn't apply here. > +static int __meminit migrate_on_reclaim_callback(struct notifier_block *self, > + unsigned long action, void *_arg) Now we are building memory tiers instead of working on demotion. So I think we should rename the function to memtier_hotplug_callback(). > +{ > + struct memory_notify *arg = _arg; > + > + /* > + * Only update the node migration order when a node is > + * changing status, like online->offline. > + */ > + if (arg->status_change_nid < 0) > + return notifier_from_errno(0); > + > + switch (action) { > + case MEM_OFFLINE: > + clear_node_memory_tier(arg->status_change_nid); > + break; > + case MEM_ONLINE: > + init_node_memory_tier(arg->status_change_nid); > + break; > + } > + > + return notifier_from_errno(0); > +} > + > +static void __init migrate_on_reclaim_init(void) > +{ > + hotplug_memory_notifier(migrate_on_reclaim_callback, MEMTIER_HOTPLUG_PRIO); > +} I suggest to call hotplug_memory_notifier() in memory_tier_init() directly. We are not working on demotion here. > + > static int __init memory_tier_init(void) > { > int node; > @@ -96,6 +169,8 @@ static int __init memory_tier_init(void) > node_property->perf_level = default_memtier_perf_level; > } > mutex_unlock(&memory_tier_lock); > + > + migrate_on_reclaim_init(); > return 0; > } > subsys_initcall(memory_tier_init); Best Regards, Huang, Ying