linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <shy828301@gmail.com>
To: Davidlohr Bueso <dave@stgolabs.net>,
	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
Subject: Re: [PATCH 5/6] mm/migration: export demotion_path of a node via sysfs
Date: Fri, 22 Apr 2022 10:33:53 -0700	[thread overview]
Message-ID: <CAHbLzkr4w-20H11uNrf-9ZJd=oHGTXTatd5OJ0JAO1KwojySdA@mail.gmail.com> (raw)
In-Reply-To: <CAHbLzkruFaKF_92w2qsZz4sH24C-TARXaL-byT6doVVe6VQ4Zg@mail.gmail.com>

On Fri, Apr 22, 2022 at 10:31 AM Yang Shi <shy828301@gmail.com> wrote:
>
> On Fri, Apr 15, 2022 at 10:39 PM Davidlohr Bueso <dave@stgolabs.net> 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 <dave@stgolabs.net>
> > ---
> >  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 <dave@stgolabs.net>
> > +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 <linux/nodemask.h>
> >  #include <linux/cpu.h>
> >  #include <linux/device.h>
> > +#include <linux/migrate.h>
> >  #include <linux/pm_runtime.h>
> >  #include <linux/swap.h>
> >  #include <linux/slab.h>
> > @@ -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
> >
> >


  reply	other threads:[~2022-04-22 17:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16  5:38 [PATCH RFC lsfmm 0/6] mm: proactive reclaim and memory tiering topics Davidlohr Bueso
2022-04-16  5:38 ` [PATCH 1/6] drivers/base/node: cleanup register_node() Davidlohr Bueso
2022-04-25 22:30   ` Adam Manzanares
2022-05-03 18:17   ` David Hildenbrand
2022-05-04  4:33   ` David Rientjes
2022-04-16  5:38 ` [PATCH 2/6] mm/vmscan: use node_is_toptier helper in node_reclaim Davidlohr Bueso
2022-04-25 22:32   ` Adam Manzanares
2022-05-04  4:33   ` David Rientjes
2022-05-04  7:26   ` Jagdish Gediya
2022-05-31 11:50   ` Aneesh Kumar K.V
2022-06-01  6:12     ` Ying Huang
2022-04-16  5:38 ` [PATCH 3/6] mm: make __node_reclaim() more flexible Davidlohr Bueso
2022-04-16  5:39 ` [PATCH 4/6] mm: introduce per-node proactive reclaim interface Davidlohr Bueso
2022-04-19  0:00   ` Tim Chen
2022-04-16  5:39 ` [PATCH 5/6] mm/migration: export demotion_path of a node via sysfs Davidlohr Bueso
2022-04-22 17:31   ` Yang Shi
2022-04-22 17:33     ` Yang Shi [this message]
2022-04-22 17:50       ` Davidlohr Bueso
2022-04-17  3:49 ` [PATCH 6/6] mm/migrate: export whether or not node is toptier in sysf Davidlohr Bueso
2022-04-18 15:34   ` Dave Hansen
2022-04-18 16:45     ` Davidlohr Bueso
2022-04-18 16:50       ` Dave Hansen
2022-04-22 17:37   ` Yang Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHbLzkr4w-20H11uNrf-9ZJd=oHGTXTatd5OJ0JAO1KwojySdA@mail.gmail.com' \
    --to=shy828301@gmail.com \
    --cc=a.manzanares@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave@stgolabs.net \
    --cc=gim.jongmin@samsung.com \
    --cc=gthelen@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=heekwon.p@samsung.com \
    --cc=jvgediya@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=weixugc@google.com \
    --cc=ying.huang@intel.com \
    --cc=yosryahmed@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox