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 74DD6C46CD2 for ; Wed, 31 Jan 2024 01:15:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0670E6B008A; Tue, 30 Jan 2024 20:15:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 016B86B008C; Tue, 30 Jan 2024 20:15:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E20CD6B0092; Tue, 30 Jan 2024 20:15:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D1FF46B008A for ; Tue, 30 Jan 2024 20:15:37 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B274D1A055D for ; Wed, 31 Jan 2024 01:15:37 +0000 (UTC) X-FDA: 81737838714.24.30A5FD2 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by imf23.hostedemail.com (Postfix) with ESMTP id 0C13014000A for ; Wed, 31 Jan 2024 01:15:34 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=EyALiqN8; spf=pass (imf23.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706663736; 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=2ALXdSQb/J7ZXgyK2XWCTa+SqVB9Ap/vak54gPqakSg=; b=0F5S5yIqdAs0sVY41aor1u9ym4WpVj0haJfrkKGxagXeM9KDtYz725qKFYtqHSj7VG+by7 xxH1Jkl5DSIv+kecosGC3JcOFQiqliLiGxGeX9kD56yNh7c/zwv7qTyQzzBqsqnxcq1MSF pizOckW8XonTs5m8vdC2RoZouOFOv14= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=EyALiqN8; spf=pass (imf23.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.93 as permitted sender) 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=1706663736; a=rsa-sha256; cv=none; b=vON9NH3glNGYdqDBxahS0wVwfTiVzJHAdcrEAu/yKu+eYZN67qzlE1r6B12e4knuEs2Csk b0+N7yHUXtox66Iwl5+GFX6XOpPZY+J3RGnlRJ4SjvMQpmDCGDexk3tuMyKN3okvYiyT20 gesLuqziVEVRuX9lefo4Z4YKS9fO+XQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706663735; x=1738199735; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=2CxRRDR7ZlRSz7oWnLrjOTlGJOFRITskO+5cvnrKENI=; b=EyALiqN8fQ/rYWeCj7WCLC4OYGEPSlmPMdG/4YUHc2nN9Si0SZ0rFh1J 0qGWvTBOB7jWHKn4Jap3+JkoDlzYBKu1T2LItreyS3HBoJvRoz/9/Unml wtP/1mRPPn8JBcewaDWMsPBScDLu1a3x5Zl7kVpzzTFIbEPnnbYA1I5NY Q88JJKaunP4dAHAzuaZLUb08sjQcbs6sjVq3HRVuf9/5MX/HDq1gVTNM/ tRX+ESge4yW9Y7EDrW0J5SIqMitpXITFyIDdz9Ub+oUdRysXPfKELA04U d9Da63kVf/OvuLH0x4knoXE0K3ZaEyGI3Rbd2eWAHHLiFMcS1VMwgFD4i A==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="400596644" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="400596644" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 17:15:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="878632654" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="878632654" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 17:15:31 -0800 From: "Huang, Ying" To: Li Zhijian Cc: Andrew Morton , Greg Kroah-Hartman , rafael@kernel.org, linux-mm@kvack.org, y-goto@fujitsu.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC 1/4] drivers/base/node: Add demotion_nodes sys infterface In-Reply-To: (Li Zhijian's message of "Tue, 30 Jan 2024 16:53:10 +0800") References: <20231102025648.1285477-1-lizhijian@fujitsu.com> <20231102025648.1285477-2-lizhijian@fujitsu.com> <878r7g3ktj.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Wed, 31 Jan 2024 09:13:35 +0800 Message-ID: <87fryegv9c.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 0C13014000A X-Rspam-User: X-Stat-Signature: wpjww53c6r9hhcdbwmhxjwges5oww88s X-Rspamd-Server: rspam01 X-HE-Tag: 1706663734-700584 X-HE-Meta: U2FsdGVkX1/FW/Ra03A4ut/CkZZqoGV/QbeZJvyCSZO5KbGQASM2TGmdI965FF35TsO9KUZH5VHveTLnP1L/9ITmztmbUo8XjEyDGeNTG0mE2HzKwRZZuefP+2+QOc0oNqf9J63F7bETowkH7l2pxOaS5tOmWx+1zHy/1VoxuPUhQ4iKzYa7Pe3+1zaMpYNbqsQ+MzBCKo09IOau3DEDzy6FaODZM77R8EgYfZrTRZj6lLwYOKzdGOs/eI4SNr/kwKalcm9r2nGg0TStzENngL52JB3i935BXKH30S8e4C9MYzgCs6eFRQQercci0hsnVbEkGpNXpYy5P0vs8ad3LHGvsFsngbRFwVeDKxeyeoH/1HYdtn3/ACPeWjF1aDyKagL+5u7FUFt1KBXCbp3u4c3nOopFXRZ3YOYlOyCou9quqOZHWlJM+NlMK1Wzs79IY4gTYHYLyqvuAjUynA3mRaHY7VCC/s1Y/QDzOpTbO7mcwtHgc8P1DooaKcUcU4/p4Cw2a019I+dzW8NA3RyMPI4vrlf21Ar/UVu5jM2eLRtZZRmtZjPFtOe7Xw+KdOwCQMF1symxMsEi/oj9fSYSEQ97WAURBQgJx/AeC/0HQzvt9XaR3N/erzgOoJ7YVYc6b+No49pem97GdxFZUJ2uN4+uJlWs59siHuFfXnBaN62fp2qeXOdr5V4l8YMsKVddoxu717TLBwL8kDauy8NiUZrZIUp2FIgovy+XpDMaLkqDtSTLalEHVCCohR5qHwv061+3jLC7seQerRszbr/a9CRcDlkJkrYsn6G6ncMP9z5j28mKyoHHysuTbXoynolLqhCiobY+loGLRr7kGr2TJ2O50N/8QHu9KazmO7RTPfo3O3hGf/DYtocxGkTtdYndqJgDbFTsmao= 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: List-Subscribe: List-Unsubscribe: Li Zhijian writes: > Hi Ying > > > I need to pick up this thread/patch again. > >> We have /sys/devices/virtual/memory_tiering/memory_tier*/nodelist >> already. A node in a higher tier can demote to any node in the lower >> tiers. What's more need to be displayed in nodeX/demotion_nodes? >> > > Yes, it's believed that /sys/devices/virtual/memory_tiering/memory_tierN/nodelist > are intended to show nodes in memory_tierN. But IMHO, it's not enough, especially > for the preferred demotion node(s). > > Currently, when a demotion occurs, it will prioritize selecting a node > from the preferred nodes as the destination node for the demotion. If > the preferred nodes does not meet the requirements, it will try from all > the lower memory tier nodes until it finds a suitable demotion destination > node or ultimately fails. > However, > currently it only lists the nodes of each tier. If the > administrators want to know all the possible demotion destinations for a > given node, they need to calculate it themselves: > Step 1, find the memory tier where the given node is located > Step 2, list all nodes under all its lower tiers > It > will be even more difficult to know the preferred nodes which depend > on > more factors, distance etc. For the following example, we may have 6 nodes > splitting into three memory tiers. > For > emulated hmat numa topology example: >> $ numactl -H >> available: 6 nodes (0-5) >> node 0 cpus: 0 >> node 0 size: 1974 MB >> node 0 free: 1767 MB >> node 1 cpus: 1 >> node 1 size: 1694 MB >> node 1 free: 1454 MB >> node 2 cpus: >> node 2 size: 896 MB >> node 2 free: 896 MB >> node 3 cpus: >> node 3 size: 896 MB >> node 3 free: 896 MB >> node 4 cpus: >> node 4 size: 896 MB >> node 4 free: 896 MB >> node 5 cpus: >> node 5 size: 896 MB >> node 5 free: 896 MB >> node distances: >> node 0 1 2 3 4 5 >> 0: 10 31 21 41 21 41 >> 1: 31 10 41 21 41 21 >> 2: 21 41 10 51 21 51 >> 3: 31 21 51 10 51 21 >> 4: 21 41 21 51 10 51 >> 5: 31 21 51 21 51 10 >> $ cat memory_tier4/nodelist >> 0-1 >> $ cat memory_tier12/nodelist >> 2,5 >> $ cat memory_tier54/nodelist >> 3-4 > For > above topology, memory-tier will build the demotion path for each node > like this: > node[0].preferred = 2 > node[0].demotion_targets = 2-5 > node[1].preferred = 5 > node[1].demotion_targets = 2-5 > node[2].preferred = 4 > node[2].demotion_targets = 3-4 > node[3].preferred = > node[3].demotion_targets = > node[4].preferred = > node[4].demotion_targets = > node[5].preferred = 3 > node[5].demotion_targets = 3-4 > But > this demotion path is not explicitly known to administrator. And with > the > feedback from our customers, they also think it is helpful to know demotion > path built by kernel to understand the demotion behaviors. > > So i think we should have 2 new interfaces for each node: > > /sys/devices/system/node/nodeN/demotion_allowed_nodes > /sys/devices/system/node/nodeN/demotion_preferred_nodes > > I value your opinion, and I'd like to know what you think about... Per my understanding, we will not expose everything inside kernel to user space. For page placement in a tiered memory system, demotion is just a part of the story. For example, if the DRAM of a system becomes full, new page allocation will fall back to the CXL memory. Have we exposed the default page allocation fallback order to user space? All in all, in my opinion, we only expose as little as possible to user space because we need to maintain the ABI for ever. -- Best Regards, Huang, Ying > > On 02/11/2023 11:17, Huang, Ying wrote: >> Li Zhijian writes: >> >>> It shows the demotion target nodes of a node. Export this information to >>> user directly. >>> >>> Below is an example where node0 node1 are DRAM, node3 is a PMEM node. >>> - Before PMEM is online, no demotion_nodes for node0 and node1. >>> $ cat /sys/devices/system/node/node0/demotion_nodes >>> >>> - After node3 is online as kmem >>> $ daxctl reconfigure-device --mode=system-ram --no-online dax0.0 && daxctl online-memory dax0.0 >>> [ >>> { >>> "chardev":"dax0.0", >>> "size":1054867456, >>> "target_node":3, >>> "align":2097152, >>> "mode":"system-ram", >>> "online_memblocks":0, >>> "total_memblocks":7 >>> } >>> ] >>> $ cat /sys/devices/system/node/node0/demotion_nodes >>> 3 >>> $ cat /sys/devices/system/node/node1/demotion_nodes >>> 3 >>> $ cat /sys/devices/system/node/node3/demotion_nodes >>> >> We have /sys/devices/virtual/memory_tiering/memory_tier*/nodelist >> already. A node in a higher tier can demote to any node in the lower >> tiers. What's more need to be displayed in nodeX/demotion_nodes? >> -- >> Best Regards, >> Huang, Ying >> >>> Signed-off-by: Li Zhijian >>> --- >>> drivers/base/node.c | 13 +++++++++++++ >>> include/linux/memory-tiers.h | 6 ++++++ >>> mm/memory-tiers.c | 8 ++++++++ >>> 3 files changed, 27 insertions(+) >>> >>> diff --git a/drivers/base/node.c b/drivers/base/node.c >>> index 493d533f8375..27e8502548a7 100644 >>> --- a/drivers/base/node.c >>> +++ b/drivers/base/node.c >>> @@ -7,6 +7,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> #include >>> @@ -569,11 +570,23 @@ static ssize_t node_read_distance(struct device *dev, >>> } >>> static DEVICE_ATTR(distance, 0444, node_read_distance, NULL); >>> +static ssize_t demotion_nodes_show(struct device *dev, >>> + struct device_attribute *attr, char *buf) >>> +{ >>> + int ret; >>> + nodemask_t nmask = next_demotion_nodes(dev->id); >>> + >>> + ret = sysfs_emit(buf, "%*pbl\n", nodemask_pr_args(&nmask)); >>> + return ret; >>> +} >>> +static DEVICE_ATTR_RO(demotion_nodes); >>> + >>> static struct attribute *node_dev_attrs[] = { >>> &dev_attr_meminfo.attr, >>> &dev_attr_numastat.attr, >>> &dev_attr_distance.attr, >>> &dev_attr_vmstat.attr, >>> + &dev_attr_demotion_nodes.attr, >>> NULL >>> }; >>> diff --git a/include/linux/memory-tiers.h >>> b/include/linux/memory-tiers.h >>> index 437441cdf78f..8eb04923f965 100644 >>> --- a/include/linux/memory-tiers.h >>> +++ b/include/linux/memory-tiers.h >>> @@ -38,6 +38,7 @@ void init_node_memory_type(int node, struct memory_dev_type *default_type); >>> void clear_node_memory_type(int node, struct memory_dev_type *memtype); >>> #ifdef CONFIG_MIGRATION >>> int next_demotion_node(int node); >>> +nodemask_t next_demotion_nodes(int node); >>> void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets); >>> bool node_is_toptier(int node); >>> #else >>> @@ -46,6 +47,11 @@ static inline int next_demotion_node(int node) >>> return NUMA_NO_NODE; >>> } >>> +static inline next_demotion_nodes next_demotion_nodes(int node) >>> +{ >>> + return NODE_MASK_NONE; >>> +} >>> + >>> static inline void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets) >>> { >>> *targets = NODE_MASK_NONE; >>> diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c >>> index 37a4f59d9585..90047f37d98a 100644 >>> --- a/mm/memory-tiers.c >>> +++ b/mm/memory-tiers.c >>> @@ -282,6 +282,14 @@ void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets) >>> rcu_read_unlock(); >>> } >>> +nodemask_t next_demotion_nodes(int node) >>> +{ >>> + if (!node_demotion) >>> + return NODE_MASK_NONE; >>> + >>> + return node_demotion[node].preferred; >>> +} >>> + >>> /** >>> * next_demotion_node() - Get the next node in the demotion path >>> * @node: The starting node to lookup the next node