cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: Yuanchu Xie <yuanchu@google.com>
Cc: David Hildenbrand <david@redhat.com>,
	 "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	 Khalid Aziz <khalid.aziz@oracle.com>,
	Henry Huang <henry.hj@antgroup.com>,  Yu Zhao <yuzhao@google.com>,
	 Dan Williams <dan.j.williams@intel.com>,
	 Gregory Price <gregory.price@memverge.com>,
	 Kalesh Singh <kaleshsingh@google.com>,
	 Wei Xu <weixugc@google.com>,
	 David Rientjes <rientjes@google.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 "Rafael J. Wysocki" <rafael@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	 Michal Hocko <mhocko@kernel.org>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	 Muchun Song <muchun.song@linux.dev>,
	Shuah Khan <shuah@kernel.org>,
	 Yosry Ahmed <yosryahmed@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	 Sudarshan Rajagopalan <quic_sudaraja@quicinc.com>,
	 Kairui Song <kasong@tencent.com>,
	 "Michael S. Tsirkin" <mst@redhat.com>,
	 Vasily Averin <vasily.averin@linux.dev>,
	Nhat Pham <nphamcs@gmail.com>,  Miaohe Lin <linmiaohe@huawei.com>,
	 Qi Zheng <zhengqi.arch@bytedance.com>,
	 Abel Wu <wuyun.abel@bytedance.com>,
	"Vishal Moola (Oracle)" <vishal.moola@gmail.com>,
	 Kefeng Wang <wangkefeng.wang@huawei.com>,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	 cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v1 0/7] mm: workingset reporting
Date: Thu, 16 May 2024 13:53:17 +0800	[thread overview]
Message-ID: <87v83eb8vm.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <20240504073011.4000534-1-yuanchu@google.com> (Yuanchu Xie's message of "Sat, 4 May 2024 00:30:04 -0700")

Hi, Yuanchu,

Yuanchu Xie <yuanchu@google.com> writes:

> Changes from RFC v3 -> PATCH v1:
> - Updated selftest to use ksft_print_msg instead of fprintf(stderr, ...)
>   (Muhammad Usama Anjum)
> - Included more detail in patch skipping pmd_young with force_scan
>   (Huang, Ying)
> - Deferred reaccess histogram as a followup
> - Removed per-memcg page age interval configs for simplicity
>
> Changes from RFC v2 -> RFC v3:
> - Update to v6.8
> - Added an aging kernel thread (gated behind config)
> - Added basic selftests for sysfs interface files
> - Track swapped out pages for reaccesses
> - Refactoring and cleanup
> - Dropped the virtio-balloon extension to make things manageable
>
> Changes from RFC v1 -> RFC v2:
> - Refactored the patchs into smaller pieces
> - Renamed interfaces and functions from wss to wsr (Working Set Reporting)
> - Fixed build errors when CONFIG_WSR is not set
> - Changed working_set_num_bins to u8 for virtio-balloon
> - Added support for per-NUMA node reporting for virtio-balloon
>
> [rfc v1]
> https://lore.kernel.org/linux-mm/20230509185419.1088297-1-yuanchu@google.com/
> [rfc v2]
> https://lore.kernel.org/linux-mm/20230621180454.973862-1-yuanchu@google.com/
> [rfc v3]
> https://lore.kernel.org/linux-mm/20240327213108.2384666-1-yuanchu@google.com/
>
> This patch series provides workingset reporting of user pages in
> lruvecs, of which coldness can be tracked by accessed bits and fd
> references. However, the concept of workingset applies generically to
> all types of memory, which could be kernel slab caches, discardable
> userspace caches (databases), or CXL.mem. Therefore, data sources might
> come from slab shrinkers, device drivers, or the userspace. IMO, the
> kernel should provide a set of workingset interfaces that should be
> generic enough to accommodate the various use cases, and be extensible
> to potential future use cases. The current proposed interfaces are not
> sufficient in that regard, but I would like to start somewhere, solicit
> feedback, and iterate.
>
> Use cases
> ==========
> Job scheduling
> On overcommitted hosts, workingset information allows the job scheduler
> to right-size each job and land more jobs on the same host or NUMA node,
> and in the case of a job with increasing workingset, policy decisions
> can be made to migrate other jobs off the host/NUMA node, or oom-kill
> the misbehaving job. If the job shape is very different from the machine
> shape, knowing the workingset per-node can also help inform page
> allocation policies.
>
> Proactive reclaim
> Workingset information allows the a container manager to proactively
> reclaim memory while not impacting a job's performance. While PSI may
> provide a reactive measure of when a proactive reclaim has reclaimed too
> much, workingset reporting allows the policy to be more accurate and
> flexible.
>
> Ballooning (similar to proactive reclaim)
> While this patch series does not extend the virtio-balloon device,
> balloon policies benefit from workingset to more precisely determine
> the size of the memory balloon. On desktops/laptops/mobile devices where
> memory is scarce and overcommitted, the balloon sizing in multiple VMs
> running on the same device can be orchestrated with workingset reports
> from each one.
>
> Promotion/Demotion
> Similar to proactive reclaim, a workingset report enables demotion to a
> slower tier of memory.
> For promotion, the workingset report interfaces need to be extended to
> report hotness and gather hotness information from the devices[1].
>
> [1]
> https://www.opencompute.org/documents/ocp-cms-hotness-tracking-requirements-white-paper-pdf-1

This mechanism can also provide a way to control the pages ping-pong
caused by promotion and demotion.  If different methods are used for
promotion and demotion, some pages may be migrated between the fast and
slow memory back and forth.  Because there's no connection between
promotion side and demotion side.  For example, if we use NUMA balancing
based promotion and MGLRU based demotion.

If we use workingset reporting on the fast memory nodes, then we can
establish the connection between demotion and promotion with it.  For
example, the promotion hot pages threshold (determined as accessed every
N seconds) should be set to make 80% of the fast memory pages pass the
threshold.  This can be calculated with the workingset reporting
statistics.

> Sysfs and Cgroup Interfaces
> ==========
> The interfaces are detailed in the patches that introduce them. The main
> idea here is we break down the workingset per-node per-memcg into time
> intervals (ms), e.g.
>
> 1000 anon=137368 file=24530
> 20000 anon=34342 file=0
> 30000 anon=353232 file=333608
> 40000 anon=407198 file=206052
> 9223372036854775807 anon=4925624 file=892892
>
> I realize this does not generalize well to hotness information, but I
> lack the intuition for an abstraction that presents hotness in a useful
> way. Please advise.
>
> Implementation
> ==========
> Currently, the reporting of user pages is based off of MGLRU, and
> therefore requires CONFIG_LRU_GEN=y. We would benefit from more MGLRU
> generations for a more fine-grained workingset report. I will make the
> generation count configurable in the next version. The workingset
> reporting mechanism is gated behind CONFIG_WORKINGSET_REPORT, and the
> aging thread is behind CONFIG_WORKINGSET_REPORT_AGING.
>
> Yuanchu Xie (7):
>   mm: multi-gen LRU: ignore non-leaf pmd_young for force_scan=true
>   mm: aggregate working set information into histograms
>   mm: use refresh interval to rate-limit workingset report aggregation
>   mm: report workingset during memory pressure driven scanning
>   mm: extend working set reporting to memcgs
>   mm: add kernel aging thread for workingset reporting
>   selftest: test system-wide workingset reporting
>
>  drivers/base/node.c                           |   6 +
>  include/linux/memcontrol.h                    |   5 +
>  include/linux/mmzone.h                        |   9 +
>  include/linux/workingset_report.h             |  97 ++++
>  mm/Kconfig                                    |  15 +
>  mm/Makefile                                   |   2 +
>  mm/internal.h                                 |  17 +
>  mm/memcontrol.c                               | 184 +++++-
>  mm/mm_init.c                                  |   2 +
>  mm/mmzone.c                                   |   2 +
>  mm/vmscan.c                                   |  85 ++-
>  mm/workingset_report.c                        | 545 ++++++++++++++++++
>  mm/workingset_report_aging.c                  | 127 ++++
>  tools/testing/selftests/mm/.gitignore         |   1 +
>  tools/testing/selftests/mm/Makefile           |   3 +
>  .../testing/selftests/mm/workingset_report.c  | 317 ++++++++++
>  .../testing/selftests/mm/workingset_report.h  |  39 ++
>  .../selftests/mm/workingset_report_test.c     | 332 +++++++++++
>  18 files changed, 1786 insertions(+), 2 deletions(-)
>  create mode 100644 include/linux/workingset_report.h
>  create mode 100644 mm/workingset_report.c
>  create mode 100644 mm/workingset_report_aging.c
>  create mode 100644 tools/testing/selftests/mm/workingset_report.c
>  create mode 100644 tools/testing/selftests/mm/workingset_report.h
>  create mode 100644 tools/testing/selftests/mm/workingset_report_test.c

--
Best Regards,
Huang, Ying

      parent reply	other threads:[~2024-05-16  5:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-04  7:30 [PATCH v1 0/7] mm: workingset reporting Yuanchu Xie
2024-05-04  7:30 ` [PATCH v1 1/7] mm: multi-gen LRU: ignore non-leaf pmd_young for force_scan=true Yuanchu Xie
2024-05-04  7:30 ` [PATCH v1 2/7] mm: aggregate working set information into histograms Yuanchu Xie
2024-05-04  7:30 ` [PATCH v1 3/7] mm: use refresh interval to rate-limit workingset report aggregation Yuanchu Xie
2024-05-04  7:30 ` [PATCH v1 4/7] mm: report workingset during memory pressure driven scanning Yuanchu Xie
2024-05-04  7:30 ` [PATCH v1 5/7] mm: extend working set reporting to memcgs Yuanchu Xie
2024-05-04  7:30 ` [PATCH v1 6/7] mm: add kernel aging thread for workingset reporting Yuanchu Xie
2024-05-04  7:30 ` [PATCH v1 7/7] selftest: test system-wide " Yuanchu Xie
2024-05-16 19:39   ` Muhammad Usama Anjum
2024-05-16  5:53 ` Huang, Ying [this message]

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=87v83eb8vm.fsf@yhuang6-desk2.ccr.corp.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=cgroups@vger.kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=david@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.price@memverge.com \
    --cc=hannes@cmpxchg.org \
    --cc=henry.hj@antgroup.com \
    --cc=kaleshsingh@google.com \
    --cc=kasong@tencent.com \
    --cc=khalid.aziz@oracle.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mst@redhat.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=quic_sudaraja@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shuah@kernel.org \
    --cc=vasily.averin@linux.dev \
    --cc=vishal.moola@gmail.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=weixugc@google.com \
    --cc=willy@infradead.org \
    --cc=wuyun.abel@bytedance.com \
    --cc=yosryahmed@google.com \
    --cc=yuanchu@google.com \
    --cc=yuzhao@google.com \
    --cc=zhengqi.arch@bytedance.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).