Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1038592iob; Fri, 13 May 2022 20:37:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzao+DKv4qAm6l+KdMPFkiB+q05h7d3Km1hlyswPAgEqFUK6veS5UYIEoEWIY1vsjruymKu X-Received: by 2002:a05:6000:188f:b0:20c:5a1c:b7c with SMTP id a15-20020a056000188f00b0020c5a1c0b7cmr6237778wri.65.1652499475652; Fri, 13 May 2022 20:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652499475; cv=none; d=google.com; s=arc-20160816; b=eO5ghUnj3zyDZXeQpBBCNhdDc3l6Wscpio+MJ9u/9Bby5uFPHtqN63mX6A4eYkrb7D fb2mB8jQX1GqopOHndc3O7CKgNDciJxn1uKJp9Y47RCtNInK4N7hfdVd/PepKlSCvKwz 31Q8BffSm+yrgSKsy/N2mJidlfTb7XMH8bAcOFFVRJwgVTxHa69RH2OhmD23+2HbTe/A E8iEadvJzO+9IEwFRFsMF9MWm8NJW572SRouLV6wC0mSzDvIuRMXb2s14TyE47iEUDNP 67HdQxlFLSFkYBWVa6zueKAMr7o+YQZ1i6h3ZmtdkgxBkADL5+cPaBgukWHK2FSkM3Fh u1zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=WO5/5LAEyF4R2+iPg7A/qhnxrs4M/JET+Pp4TkcoHHk=; b=fB2ABcmpCLBuSZwIWGxMhijYeqx9BxajhDTkxCnAwVhzt7vPFLuAdInaCpx5O6PREU a0bLwiFgnDWl3aW8cwkNQqr4iMxaspSVe1rnc9WHG17OglOJfx6rrm5yiCRcvhQfb1Nz 7Ra2LuEqLQ8pPk6+Z43TLJIvgTaNund4COB860c6Ki1ji2jk/0KKkVoTsX2nFZ8E4LjC USWBOPaaolElBv5ThvZZL9sHywnzGCzP9bqOCBssJgj9v9tSbw6LYPi73m3tyArRuq9x zTbFxB0A9k6D88JDd11NJVMzdGR6fZemSyOP3AkxvgkVtHWLZCmi3CnQFKAN8u7sERj9 jmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hST1m1D/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u3-20020a5d6da3000000b0020cf8c56ab9si853688wrs.141.2022.05.13.20.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:37:55 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="hST1m1D/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9421C445CC4; Fri, 13 May 2022 17:13:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243534AbiELIiO (ORCPT + 99 others); Thu, 12 May 2022 04:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351589AbiELIiD (ORCPT ); Thu, 12 May 2022 04:38:03 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6E371207F4 for ; Thu, 12 May 2022 01:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652344672; x=1683880672; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q3HSBah4b2SHu/QAANeRqmuxmcVixTWpiSkP1xMK0KU=; b=hST1m1D/6vPEeAMmvnBdUky5SwL7qh9HAv1I/5MVRtZL+90ZyVZUbi4B iRW3paabG6YgE5aThVphxV5rGy4vkduzVnVXUIF1RFWkwkWH0mISAGQgw wTxphBDwjKfiMS7nNTJ6IaCcmKiLnnwIj1y/G+a2BO2TajsnWQ6eVkII7 N9+S067Olm2ulAipQ9gACizkdVcysENwEe8JuY8zPIHpzdCpfxZnSrrfl UR694fb2ZyDjaisTHhnZRd91jfuifq5pUpwgFnKziuMnABo9Ry7FOrS4d jDwCDdvgWDic/q8SwCTlXb0QQN2b8bM9sb0u7cY7YVXoybtuqdqhKls6W A==; X-IronPort-AV: E=McAfee;i="6400,9594,10344"; a="267521116" X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="267521116" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 01:37:51 -0700 X-IronPort-AV: E=Sophos;i="5.91,219,1647327600"; d="scan'208";a="594566236" Received: from ruonanwa-mobl.ccr.corp.intel.com ([10.254.212.157]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 01:37:46 -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: Thu, 12 May 2022 16:37:38 +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-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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? 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