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 3C72CC433EF for ; Fri, 13 May 2022 02:53:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C63D48D0001; Thu, 12 May 2022 22:53:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C117F6B0075; Thu, 12 May 2022 22:53:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8BA08D0001; Thu, 12 May 2022 22:53:11 -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 990366B0073 for ; Thu, 12 May 2022 22:53:11 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 56FCB21243 for ; Fri, 13 May 2022 02:53:11 +0000 (UTC) X-FDA: 79459198182.20.754A1D2 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf08.hostedemail.com (Postfix) with ESMTP id 0C29F160099 for ; Fri, 13 May 2022 02:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652410388; x=1683946388; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=JPC6dlUogmhAYLUiSLbX/tviFaxYHSUYu+d6BDiKwJg=; b=WT5z7K8SNP8HB9THQy7SwrQmj4/o3CcQkqdgbfM1Xa/gigLVPkMLD8QP 8FteSwlXy2l3ofrqIJ9dkM93dBz4x6Sc/mmPvZ6eNSSOfd7i14gubEUEz 9uoOcyQwEdRTjcMWdxHTnuraS6k48Txr8p+KK1Ep6uNNvihqnPxE5thEe fKQ4ZuyOFSFJi7twdDDau80RhSSpLbNwFt6j1OeeK02OCCIU2xnwBTu3j u83ZAlhwWRysLhe3ar9CXCXQN6yw+J5ENsn/VGUsSYM9clAf+A+Du413c Yp9QqWdKEx3tpMVHbfY1o0I/N2FJW1c09Blue5jF0PI4RTtXmS3tMoHUi g==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="356624881" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="356624881" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 19:53:05 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="594997869" Received: from jliu69-mobl.ccr.corp.intel.com ([10.254.212.158]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 19:53:00 -0700 Message-ID: Subject: Re: RFC: Memory Tiering Kernel Interfaces (v2) From: "ying.huang@intel.com" To: Wei Xu , "Aneesh Kumar K.V" Cc: Andrew Morton , Greg Thelen , Yang Shi , Linux Kernel Mailing List , Jagdish Gediya , Michal Hocko , Tim C Chen , Dave Hansen , Alistair Popple , Baolin Wang , Feng Tang , Jonathan Cameron , Davidlohr Bueso , Dan Williams , David Rientjes , Linux MM , Brice Goglin , Hesham Almatary Date: Fri, 13 May 2022 10:52:58 +0800 In-Reply-To: References: <56b41ce6922ed5f640d9bd46a603fa27576532a9.camel@intel.com> <87y1z7jj85.fsf@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0C29F160099 X-Stat-Signature: nebgiwhm8q34eyyajxqao5eppi8uoncg Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WT5z7K8S; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf08.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 192.55.52.43) smtp.mailfrom=ying.huang@intel.com X-Rspam-User: X-HE-Tag: 1652410373-701021 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: On Thu, 2022-05-12 at 16:37 +0800, ying.huang@intel.com wrote: > On Thu, 2022-05-12 at 01:15 -0700, Wei Xu wrote: > > On Thu, May 12, 2022 at 12:36 AM Aneesh Kumar K.V > > wrote: > > > > > > Wei Xu writes: > > > > > > > On Thu, May 12, 2022 at 12:12 AM Aneesh Kumar K V > > > > wrote: > > > > > > > > > > On 5/12/22 12:33 PM, ying.huang@intel.com wrote: > > > > > > On Wed, 2022-05-11 at 23:22 -0700, Wei Xu wrote: > > > > > > > Sysfs Interfaces > > > > > > > ================ > > > > > > > > > > > > > > * /sys/devices/system/memtier/memtierN/nodelist > > > > > > > > > > > > > >    where N = 0, 1, 2 (the kernel supports only 3 tiers for now). > > > > > > > > > > > > > >    Format: node_list > > > > > > > > > > > > > >    Read-only. When read, list the memory nodes in the specified tier. > > > > > > > > > > > > > >    Tier 0 is the highest tier, while tier 2 is the lowest tier. > > > > > > > > > > > > > >    The absolute value of a tier id number has no specific meaning. > > > > > > >    What matters is the relative order of the tier id numbers. > > > > > > > > > > > > > >    When a memory tier has no nodes, the kernel can hide its memtier > > > > > > >    sysfs files. > > > > > > > > > > > > > > * /sys/devices/system/node/nodeN/memtier > > > > > > > > > > > > > >    where N = 0, 1, ... > > > > > > > > > > > > > >    Format: int or empty > > > > > > > > > > > > > >    When read, list the memory tier that the node belongs to. Its value > > > > > > >    is empty for a CPU-only NUMA node. > > > > > > > > > > > > > >    When written, the kernel moves the node into the specified memory > > > > > > >    tier if the move is allowed. The tier assignment of all other nodes > > > > > > >    are not affected. > > > > > > > > > > > > > >    Initially, we can make this interface read-only. > > > > > > > > > > > > It seems that "/sys/devices/system/node/nodeN/memtier" has all > > > > > > information we needed. Do we really need > > > > > > "/sys/devices/system/memtier/memtierN/nodelist"? > > > > > > > > > > > > That can be gotten via a simple shell command line, > > > > > > > > > > > > $ grep . /sys/devices/system/node/nodeN/memtier | sort -n -k 2 -t ':' > > > > > > > > > > > > > > > > It will be really useful to fetch the memory tier node list in an easy > > > > > fashion rather than reading multiple sysfs directories. If we don't have > > > > > other attributes for memorytier, we could keep > > > > > "/sys/devices/system/memtier/memtierN" a NUMA node list there by > > > > > avoiding /sys/devices/system/memtier/memtierN/nodelist > > > > > > > > > > -aneesh > > > > > > > > It is harder to implement memtierN as just a file and doesn't follow > > > > the existing sysfs pattern, either. Besides, it is extensible to have > > > > memtierN as a directory. > > > > > > diff --git a/drivers/base/node.c b/drivers/base/node.c > > > index 6248326f944d..251f38ec3816 100644 > > > --- a/drivers/base/node.c > > > +++ b/drivers/base/node.c > > > @@ -1097,12 +1097,49 @@ static struct attribute *node_state_attrs[] = { > > >         NULL > > >  }; > > > > > > +#define MAX_TIER 3 > > > +nodemask_t memory_tier[MAX_TIER]; > > > + > > > +#define _TIER_ATTR_RO(name, tier_index) \ > > > + { __ATTR(name, 0444, show_tier, NULL), tier_index, NULL } > > > + > > > +struct memory_tier_attr { > > > + struct device_attribute attr; > > > + int tier_index; > > > + int (*write)(nodemask_t nodes); > > > +}; > > > + > > > +static ssize_t show_tier(struct device *dev, > > > + struct device_attribute *attr, char *buf) > > > +{ > > > + struct memory_tier_attr *mt = container_of(attr, struct memory_tier_attr, attr); > > > + > > > + return sysfs_emit(buf, "%*pbl\n", > > > + nodemask_pr_args(&memory_tier[mt->tier_index])); > > > +} > > > + > > >  static const struct attribute_group memory_root_attr_group = { > > >         .attrs = node_state_attrs, > > >  }; > > > > > > + > > > +#define TOP_TIER 0 > > > +static struct memory_tier_attr memory_tiers[] = { > > > + [0] = _TIER_ATTR_RO(memory_top_tier, TOP_TIER), > > > +}; > > > + > > > +static struct attribute *memory_tier_attrs[] = { > > > + &memory_tiers[0].attr.attr, > > > + NULL > > > +}; > > > + > > > +static const struct attribute_group memory_tier_attr_group = { > > > + .attrs = memory_tier_attrs, > > > +}; > > > + > > >  static const struct attribute_group *cpu_root_attr_groups[] = { > > >         &memory_root_attr_group, > > > + &memory_tier_attr_group, > > >         NULL, > > >  }; > > > > > > > > > As long as we have the ability to see the nodelist, I am good with the > > > proposal. > > > > > > -aneesh > > > > I am OK with moving back the memory tier nodelist into node/. When > > there are more memory tier attributes needed, we can then create the > > memory tier subtree and replace the tier nodelist in node/ with > > symlinks. > > What attributes do you imagine that we may put in memory_tierX/ sysfs > directory? If we have good candidates in mind, we may just do that. > What I can imagine now is "demote", like "memory_reclaim" in nodeX/ or > node/ directory you proposed before. Is it necessary to show something > like "meminfo", "vmstat" there? My words may be confusing, so let me say it in another way. Just for brainstorm, if we have /sys/devices/system/memtier/memtierN/ What can we put in it in addition to "nodelist" or links to the nodes? For example, /sys/devices/system/memtier/memtierN/demote When write a page number to it, the specified number of pages will be demoted from memtierN to memtierN+1, like the /sys/devices/system/node/memory_reclaim interface you proposed before. Or, is it necessary to add /sys/devices/system/memtier/memtierN/meminfo /sys/devices/system/memtier/memtierN/vmstat I don't mean to propose these. Just want to know whether there's requirement for these kind of stuff? And what else may be required. Best Regards, Huang, Ying > > > > So the revised sysfs interfaces are: > > > > * /sys/devices/system/node/memory_tierN (read-only) > > > >   where N = 0, 1, 2 > > > >   Format: node_list > > > > * /sys/devices/system/node/nodeN/memory_tier (read/write) > > > >   where N = 0, 1, ... > > > >   Format: int or empty >