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 2BBC7C433EF for ; Fri, 22 Apr 2022 17:34:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B8A96B0073; Fri, 22 Apr 2022 13:34:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 967B56B0074; Fri, 22 Apr 2022 13:34:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E2AE6B0075; Fri, 22 Apr 2022 13:34:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 6F87B6B0073 for ; Fri, 22 Apr 2022 13:34:07 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 444C6120931 for ; Fri, 22 Apr 2022 17:34:07 +0000 (UTC) X-FDA: 79385213334.18.61FB523 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf21.hostedemail.com (Postfix) with ESMTP id 151341C002C for ; Fri, 22 Apr 2022 17:34:04 +0000 (UTC) Received: by mail-pl1-f170.google.com with SMTP id b7so12338035plh.2 for ; Fri, 22 Apr 2022 10:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QiXv4gRA4sTObvIQ+FoZbquWQgdoIl4ETDd06lrJqYI=; b=j1kJ+/P6c1H11XFyMz2fXLe7XysDwsCdF9a79eOUYcvtLdxf9Tx3Eny+Pb3enhMss6 04ovK/+SnfhDeRevELEOpWSR1VcwaJTfHWKYkiWg4FRlhxiRSBEDrmYgzdfB8eFbAEtb 76X8pK+PaE7/0ubmPPOmWhWqa7QT+SdZlAi5HewV0Gj+lB2YMQLhfQZ/QkPTfKgA3D9F aPBfaMe2M3q4C9A2dw8u1uuX7nhKaoxy4lymOUm3zPAYbZVxEVEOXlwE3rsJUHVZkBJs xSV0Z0mQ/rMafG39d34kIxoKIoBsEBA0qm8Nke2p60oFKdYkQptdQ1rwyx/i6zHsir2N F+mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QiXv4gRA4sTObvIQ+FoZbquWQgdoIl4ETDd06lrJqYI=; b=Ix/QcgQa/ePIOkdrwl6sWZsjZjUmL/UgpD5Ag025Ssc7snltP1a5+E0oC1zu82/8Kg kpZSVXZ8Mla7eCIvDzLfnNlb2LlLhfwy9f11ZMDTl9jmGz4fXr4PAK39SZD1apPJoyLi I95GJFiCU4Fh7I1ZY3KpADFIPp/xdG+Hyf/gHAQjaFf2B0ZV4ETsUhXXarscyE8GIiZ0 gpAww/Ct9P5b44TqRhOdVL+lbP7qKrBaOHKu/wXoeULOz9F8ciGabp9B/RyxcKGJwqCn 5zpp7pT2zDM3iCrIPE424F67TYs0mL2phapAu/XNMVXSLrHDEFqwb2NpzqRegmUy96b9 0DkQ== X-Gm-Message-State: AOAM531NZcVjjtPeKRJjN83FtyjBT++konPtxKHdhAWTCDVb4H+8Ygcn xTFo1MHQnIJUayYvR+AnrxzN27tbhvgBoGEMqfE= X-Google-Smtp-Source: ABdhPJwDtXXK2rudfcxu6wHXZuUanIAPzm53VgsV1cCq2vwpLT/lRskHReTO45q5f74JiCAzll30576kEc3oqOCCZ34= X-Received: by 2002:a17:902:d5c3:b0:154:c472:de80 with SMTP id g3-20020a170902d5c300b00154c472de80mr5593008plh.87.1650648845908; Fri, 22 Apr 2022 10:34:05 -0700 (PDT) MIME-Version: 1.0 References: <20220416053902.68517-1-dave@stgolabs.net> <20220416053902.68517-6-dave@stgolabs.net> In-Reply-To: From: Yang Shi Date: Fri, 22 Apr 2022 10:33:53 -0700 Message-ID: Subject: Re: [PATCH 5/6] mm/migration: export demotion_path of a node via sysfs To: Davidlohr Bueso , jvgediya@linux.ibm.com, ying.huang@intel.com, weixugc@google.com Cc: linux-mm@kvack.org, mhocko@kernel.org, akpm@linux-foundation.org, rientjes@google.com, yosryahmed@google.com, hannes@cmpxchg.org, shakeelb@google.com, dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, roman.gushchin@linux.dev, gthelen@google.com, a.manzanares@samsung.com, heekwon.p@samsung.com, gim.jongmin@samsung.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="j1kJ+/P6"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of shy828301@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 151341C002C X-Rspam-User: X-Stat-Signature: 6koytgwj1ficga68umxoqpgdkcdrfzwc X-HE-Tag: 1650648844-482978 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 Fri, Apr 22, 2022 at 10:31 AM Yang Shi wrote: > > On Fri, Apr 15, 2022 at 10:39 PM Davidlohr Bueso wrote: > > > > Add a /sys/devices/system/node/nodeX/demotion_path file > > to export the possible target(s) in node_demotion[node]. > > I'm not sure if you noticed that Jagdish Gediya is working on the > similar patch, please see > https://lore.kernel.org/linux-mm/20220413092206.73974-1-jvgediya@linux.ibm.com/ Loop in Jagdish Gediya, Ying Huang and Wei Xu. > > It would be better to combine the two to avoid duplicate effort. > > > > > Signed-off-by: Davidlohr Bueso > > --- > > Documentation/ABI/stable/sysfs-devices-node | 6 ++++ > > drivers/base/node.c | 39 +++++++++++++++++++++ > > include/linux/migrate.h | 15 ++++++++ > > mm/migrate.c | 15 +------- > > 4 files changed, 61 insertions(+), 14 deletions(-) > > > > diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node > > index 3c935e1334f7..f620c6ae013c 100644 > > --- a/Documentation/ABI/stable/sysfs-devices-node > > +++ b/Documentation/ABI/stable/sysfs-devices-node > > @@ -192,3 +192,9 @@ Description: > > When it completes successfully, the specified amount or more memory > > will have been reclaimed, and -EAGAIN if less bytes are reclaimed > > than the specified amount. > > + > > +What: /sys/devices/system/node/nodeX/demotion_path > > +Date: April 2022 > > +Contact: Davidlohr Bueso > > +Description: > > + Shows nodes within the next tier of slower memory below this node. > > diff --git a/drivers/base/node.c b/drivers/base/node.c > > index d80c478e2a6e..ab4bae777535 100644 > > --- a/drivers/base/node.c > > +++ b/drivers/base/node.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -560,11 +561,49 @@ static ssize_t node_read_distance(struct device *dev, > > } > > static DEVICE_ATTR(distance, 0444, node_read_distance, NULL); > > > > +static ssize_t node_read_demotion_path(struct device *dev, > > + struct device_attribute *attr, char *buf) > > +{ > > + int nid = dev->id; > > + int len = 0; > > + int i; > > + struct demotion_nodes *nd; > > + > > + /* > > + * buf is currently PAGE_SIZE in length and each node needs 4 chars > > + * at the most (target + space or newline). > > + */ > > + BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE); > > + > > + if (!node_demotion) { > > + len += sysfs_emit_at(buf, len, "%d", NUMA_NO_NODE); > > + goto done; > > + } > > + > > + nd = &node_demotion[nid]; > > + > > + rcu_read_lock(); > > + if (nd->nr == 0) > > + len += sysfs_emit_at(buf, len, "%d", NUMA_NO_NODE); > > + else { > > + for (i = 0; i < nd->nr; i++) { > > + len += sysfs_emit_at(buf, len, "%s%d", > > + i ? " " : "", nd->nodes[i]); > > + } > > + } > > + rcu_read_unlock(); > > +done: > > + len += sysfs_emit_at(buf, len, "\n"); > > + return len; > > +} > > +static DEVICE_ATTR(demotion_path, 0444, node_read_demotion_path, NULL); > > + > > 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_path.attr, > > NULL > > }; > > > > diff --git a/include/linux/migrate.h b/include/linux/migrate.h > > index 90e75d5a54d6..b0ac6a717e44 100644 > > --- a/include/linux/migrate.h > > +++ b/include/linux/migrate.h > > @@ -111,6 +111,21 @@ static inline int migrate_misplaced_page(struct page *page, > > } > > #endif /* CONFIG_NUMA_BALANCING */ > > > > +#define DEFAULT_DEMOTION_TARGET_NODES 15 > > + > > +#if MAX_NUMNODES < DEFAULT_DEMOTION_TARGET_NODES > > +#define DEMOTION_TARGET_NODES (MAX_NUMNODES - 1) > > +#else > > +#define DEMOTION_TARGET_NODES DEFAULT_DEMOTION_TARGET_NODES > > +#endif > > + > > +struct demotion_nodes { > > + unsigned short nr; > > + short nodes[DEMOTION_TARGET_NODES]; > > +}; > > + > > +extern struct demotion_nodes *node_demotion __read_mostly; > > + > > #ifdef CONFIG_MIGRATION > > > > /* > > diff --git a/mm/migrate.c b/mm/migrate.c > > index 6c31ee1e1c9b..e47ea25fcfe8 100644 > > --- a/mm/migrate.c > > +++ b/mm/migrate.c > > @@ -2172,20 +2172,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, > > * must be held over all reads to ensure that no cycles are > > * observed. > > */ > > -#define DEFAULT_DEMOTION_TARGET_NODES 15 > > - > > -#if MAX_NUMNODES < DEFAULT_DEMOTION_TARGET_NODES > > -#define DEMOTION_TARGET_NODES (MAX_NUMNODES - 1) > > -#else > > -#define DEMOTION_TARGET_NODES DEFAULT_DEMOTION_TARGET_NODES > > -#endif > > - > > -struct demotion_nodes { > > - unsigned short nr; > > - short nodes[DEMOTION_TARGET_NODES]; > > -}; > > - > > -static struct demotion_nodes *node_demotion __read_mostly; > > +struct demotion_nodes *node_demotion __read_mostly; > > > > /** > > * next_demotion_node() - Get the next node in the demotion path > > -- > > 2.26.2 > > > >