Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp123997rdb; Wed, 1 Nov 2023 20:19:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAv3PrdhTQIWDVujMau4DMbeTD58uhqhBYOKGQeodWHuSii3xF68novZ5ZHO5MEJX7D4N7 X-Received: by 2002:a05:6a21:328a:b0:17b:2c56:70bc with SMTP id yt10-20020a056a21328a00b0017b2c5670bcmr11425130pzb.10.1698895199384; Wed, 01 Nov 2023 20:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698895199; cv=none; d=google.com; s=arc-20160816; b=NCNroWLouArEzMP7yo8VmXNBDsDJXfuDkK0fPN3tfjrcvEF8zeDfZhCiEYQA4ODYMB zrw5hNJjGYWRoqQAYwpPWBBPbIxnX9vHIR00W0rpO6DqsCoY4qfu0k1pXUH//CpAWKAh YlB6MfluEuxzoeB7+ecscAjKoyZG20O5xOvuWEi9fYJrxSuPxCAuWi2bcSCC2lQVeH8W tDOOwCQn/XRWqnEnNJ3MBKow0Og487kF8ArtbfM4qw53n4yNa8oMdvL32TSHA+DXmQVU pmta6Yj+2hbM9Ue0g393WuoiMzmKyoGtaZq1QV1CTDamDlJcg42BVlAHddXY4hMHoTs4 T5VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:dkim-signature; bh=1ySBylLb/ENssumzqJ7m53ZybGXvrRrspVclSfUafSM=; fh=3WzbsbXAftqMZ1BW2X/rFK0NHKDyzITgpciQ/VRXaRU=; b=fOGMMC6KFTFtj+ojdy5kctCW7aOjOEBPuzE24cDtieNOPjpwJ47IOnEetpL8JYCaLS WF6YCtXs67g6FrDS/bGr8r+cQP7AJFLFzvjJKV8qKkHMuib9BD/DOWeteryAKo3vBPEd DlDnS69HD500LdEHe9JqYpv9aZIYco1PfGg6n8BmDu6xu+LtRJIu9X5RGZ2uJ/5lOkuT uSo5lDNW+Yr2teIcHliEaMcJWUYEYUM7d6ak/A0y1u48J8V7XwHq9xHjpDBCPSSN/9LN LXOrkyJYHIJMvKO/53ctQCuzlVBg7R/nYt7iYKKcL7RqI0rxM71LDX/4tkZInDwyB9di MYVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HrsdzAPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id fj6-20020a056a003a0600b0068fb8fa1e71si3084804pfb.207.2023.11.01.20.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 20:19:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HrsdzAPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4AB27809E705; Wed, 1 Nov 2023 20:19:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348330AbjKBDT4 (ORCPT + 99 others); Wed, 1 Nov 2023 23:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348268AbjKBDTz (ORCPT ); Wed, 1 Nov 2023 23:19:55 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF2C89F for ; Wed, 1 Nov 2023 20:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698895189; x=1730431189; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=iBLPvwCSOspG+bzCGzZm2j9t2qHkZ+ra3oCn0zk86X0=; b=HrsdzAPWnT0rf8czxfMmzonEGuPfAK7biSvH8Ab9+lTsSVe2BPZfQlXi apIcwWFMTuFHeiMDDnZUC3tIOHZ+aUOd3as2ftIP3cUn+YLusC4HSR9Pk 3J5tBaWH1kTAYnU2Tp0A7+eT0FC/FY5FY24Z2Y3bmYDaA+BtinJ/2oGRR q+NCHB4lbtbL6aDT4vInwknGG2ynPyyTGE8bcaSHmRgyZ+YZny9tYNtvg OdXcWOrPaXgjYXOJPz/G8xlwVcDdM5qTPku9I0nn3xTFkwVOyTqGNmjtN 7nPfeFepZWfWg6bfJI0a4/PR/hWb2uO/6PNZknzLU9ngg+ZE1c3+jYwyE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="7264557" X-IronPort-AV: E=Sophos;i="6.03,270,1694761200"; d="scan'208";a="7264557" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 20:19:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="737609632" X-IronPort-AV: E=Sophos;i="6.03,270,1694761200"; d="scan'208";a="737609632" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 20:19:46 -0700 From: "Huang, Ying" To: Li Zhijian Cc: Andrew Morton , Greg Kroah-Hartman , , , , Subject: Re: [PATCH RFC 1/4] drivers/base/node: Add demotion_nodes sys infterface In-Reply-To: <20231102025648.1285477-2-lizhijian@fujitsu.com> (Li Zhijian's message of "Thu, 2 Nov 2023 10:56:45 +0800") References: <20231102025648.1285477-1-lizhijian@fujitsu.com> <20231102025648.1285477-2-lizhijian@fujitsu.com> Date: Thu, 02 Nov 2023 11:17:44 +0800 Message-ID: <878r7g3ktj.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-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 20:19:58 -0700 (PDT) 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