From patchwork Tue Jun 4 02:05:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanchu Xie X-Patchwork-Id: 13684575 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 EF4ADC27C50 for ; Tue, 4 Jun 2024 02:06:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A71026B009D; Mon, 3 Jun 2024 22:06:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 980136B009F; Mon, 3 Jun 2024 22:06:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D2906B00A0; Mon, 3 Jun 2024 22:06:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5C41D6B009D for ; Mon, 3 Jun 2024 22:06:25 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1E637140FF4 for ; Tue, 4 Jun 2024 02:06:25 +0000 (UTC) X-FDA: 82191566730.07.18621DC Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf18.hostedemail.com (Postfix) with ESMTP id 573BC1C0023 for ; Tue, 4 Jun 2024 02:06:23 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J11DFuAs; spf=pass (imf18.hostedemail.com: domain of 3nnZeZgcKCD8zvbodivhpphmf.dpnmjovy-nnlwbdl.psh@flex--yuanchu.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3nnZeZgcKCD8zvbodivhpphmf.dpnmjovy-nnlwbdl.psh@flex--yuanchu.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717466783; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TnO0wJpr9VrNuJfB7YNxreIL5h7wQch0G6mtECTuPNI=; b=kX682s3ZPC5cavh8/4pobwxpPlS6zCGes/bxxM6xKD/KDvu1gMWWwHp1enWwk51vOtdf6A rZTdLqdF2Ki7owvaqKQMR9dmARzQpceSv6WCVs6NXU5Cjyd+L7dE/7gqdM0l37hVZpX2C6 qj/P6GOhRDgWWg+47eCHprY3EA7x/HU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717466783; a=rsa-sha256; cv=none; b=d37khyfjuFOst77rNKE54Mqv7tSQDMH7yJByArZm2nRBWvp/FPy2HsfDDomBuokOSuPLKV 0VPDNBumrhviRAKFaERAshK/SrphFyY6lW4zfJ405GrlrAK9y4tumVc+39AIHmzmWjI9sv g0dunt8mAmdpSRSh0pPOG9fjEwthqbE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=J11DFuAs; spf=pass (imf18.hostedemail.com: domain of 3nnZeZgcKCD8zvbodivhpphmf.dpnmjovy-nnlwbdl.psh@flex--yuanchu.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3nnZeZgcKCD8zvbodivhpphmf.dpnmjovy-nnlwbdl.psh@flex--yuanchu.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62a1e9807c0so64404257b3.0 for ; Mon, 03 Jun 2024 19:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717466782; x=1718071582; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TnO0wJpr9VrNuJfB7YNxreIL5h7wQch0G6mtECTuPNI=; b=J11DFuAsKRZPChm+BMNQlUXZoQxSHeSm2F12+yiD/WqdGK6NC3QcFg52TDctuR0uIm m0TIts7uOOi6jktS4wKdemLKf/spk76naC9hRX2oaBY2g60UlBKLLHKs6/Vk4NQU1T+H jxn6pf4lAlBAlVcXVy/bXWZrKvNV650jB8kHTzcwNWLZH7RjPbvmVuejO+yGYW8PzQCG uh3E7+zZG32L3AkZ23ZThhrhwM2c4f7psmeZ9I3sZzK63nxi/JzYJXhI4paZ4AZFx1he 3kzk5cI02LXRQ1c8ZeF3irlcOKR2lph9hr6EoDTGaf9CY2T+0WxdGbq7XFxHTXZfgMRv s/Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717466782; x=1718071582; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TnO0wJpr9VrNuJfB7YNxreIL5h7wQch0G6mtECTuPNI=; b=ThrQQp1VSDJ5jasGxDAIoC/k+hdJmV8QupL5tTAcYVxOR/3ynNEI51dllYvfAfqgJM iikuPWUvI5g8GSdF6xXd6kDRN6T9Y8B/uYLinV6BVX996rRIu2AT41vdS3CBN95Pwmla 5BbVu5JtU1GZwmuaxMjJcHWoXaTgtf1gnmyV6JxqmK0xPwlD4+qBphq8slhwg9C2l4RA nnKtMIK1+mj7BR7EJOf49UmtYdD/lekzKNGsJGYGrvr9sohYtaMHpycZAk+OKOtbenw9 +XsYOfl/gBs0cAzFteotyOsX3YT99+mI6CCqNbwRqiE3nwEW/YrQY+wEfzl48Njnb0ol YcUw== X-Forwarded-Encrypted: i=1; AJvYcCUIo7GvvYO3+U+KaJeTuNuVqdaRaSw9RkXFkn/K8eeMZgB0934XK/EG8rcXt8tp7Zl2EvohRHPMkhTGuTf4T8ks0dM= X-Gm-Message-State: AOJu0YzkIzZGY2xhrugqhBo1ICVJdGPjzFcGmUkSrNFMuv60nCG0JNr+ HhCQgS/+yxui732dmDJJ8N2nNQBPNZ6z3RHjHPOl2lwL8N/bScjs86Xm74+Bo9q+6RyHtEfZrmI DxagMaQ== X-Google-Smtp-Source: AGHT+IGZTKhErP0mteEdLmLII+zOO1bIGHOtdpRtyYGuauHmWRG/AEKax0/K3QpTHO4KkINtPULvAXTKU6Gn X-Received: from yuanchu-desktop.svl.corp.google.com ([2620:15c:2a3:200:367f:7387:3dd2:73f1]) (user=yuanchu job=sendgmr) by 2002:a81:c906:0:b0:618:9348:6b92 with SMTP id 00721157ae682-62cabc4cd34mr3112857b3.1.1717466782241; Mon, 03 Jun 2024 19:06:22 -0700 (PDT) Date: Mon, 3 Jun 2024 19:05:49 -0700 In-Reply-To: <20240604020549.1017540-1-yuanchu@google.com> Mime-Version: 1.0 References: <20240604020549.1017540-1-yuanchu@google.com> X-Mailer: git-send-email 2.45.1.467.gbab1589fc0-goog Message-ID: <20240604020549.1017540-9-yuanchu@google.com> Subject: [PATCH v2 8/8] Docs/admin-guide/mm/workingset_report: document sysfs and memcg interfaces From: Yuanchu Xie To: David Hildenbrand , "Aneesh Kumar K.V" , Khalid Aziz , Henry Huang , Yu Zhao , Dan Williams , Gregory Price , Huang Ying , Muhammad Usama Anjum Cc: Kalesh Singh , Wei Xu , David Rientjes , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Shuah Khan , Yosry Ahmed , Matthew Wilcox , Sudarshan Rajagopalan , Kairui Song , "Michael S. Tsirkin" , Vasily Averin , Nhat Pham , Miaohe Lin , Qi Zheng , Abel Wu , "Vishal Moola (Oracle)" , Kefeng Wang , Yuanchu Xie , linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org X-Rsp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i3Iv7AYFOi WE4fqVG3 26VwVCxPy+W9iOU7PPDOerdJd4OJtXufUVdympyDjWur2W9fPx+2Bgvb4OGJsVgNJR2fj8ryu1DSzMwLph8p96eL5kM5d7Tl734qJSQ/F72JK7yVQ/SiXqr/3OWyhHtlrL+PDU5z9eNu3mOXUZo1zj2/pN055VvlK+W3xbTeFwWdl5C/4ql0kydmJ8ALE5r8SOyRufMPYxEWkkby42G2v2qlzhpYHEwxqcCAy//2wP1l0oVZ+dim1LBEohC0OO3iSjh5ugCAaDoPPZWDiYChquCq/fdVZ7cs4bcRfaaKcciAIuWLIbtWSavYpODsFdRldEelCXMVQ7cNH99BUAX9QAcKOnn+XksG46AN/kbMJfYUEEiCmIW2ekJy4IhH2HPboi56916RD8Tn7yE4U2f5DYB7lZT03rOGKhQByqoqg056lUDWMqoaoMeFQQ7cpNVgtn1bU15K96Pj/XfP/4+ExyW1NmdhUSAaMpkaXEHDjqVkqEhxaWKvxXr7POtwpsCb78BKIPQflF7+9Tbs54p7OWelABaQEqPU9MgY2R3gBCFK/sQznOTH4wVEKeFkBpQcLPmxbBCQRuC1jXRvU2OPkFVCoe3ZQQAIH26U1F/yggkQCaS3DU7RDA5Tg23FPR8IV9xhyl7HPvqx11sC3dSySGc6E3XUQW47Enqj0y1NAYYROoVBK0/WQREtRG3rbhGGt+MyaD/InpNtoqtVfdjEHsbVf23C3IGJmkno/PGeA9pcR0OU= 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: List-Subscribe: List-Unsubscribe: Add workingset reporting documentation for better discoverability of its sysfs and memcg interfaces. Also document the required kernel config to enable workingset reporting. Signed-off-by: Yuanchu Xie --- Documentation/admin-guide/mm/index.rst | 1 + .../admin-guide/mm/workingset_report.rst | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 Documentation/admin-guide/mm/workingset_report.rst diff --git a/Documentation/admin-guide/mm/index.rst b/Documentation/admin-guide/mm/index.rst index 1f883abf3f00..fba987de8997 100644 --- a/Documentation/admin-guide/mm/index.rst +++ b/Documentation/admin-guide/mm/index.rst @@ -41,4 +41,5 @@ the Linux memory management. swap_numa transhuge userfaultfd + workingset_report zswap diff --git a/Documentation/admin-guide/mm/workingset_report.rst b/Documentation/admin-guide/mm/workingset_report.rst new file mode 100644 index 000000000000..f455ae93b30e --- /dev/null +++ b/Documentation/admin-guide/mm/workingset_report.rst @@ -0,0 +1,105 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================= +Workingset Report +================= +Workingset report provides a view of memory coldness in user-defined +time intervals, i.e. X bytes are Y milliseconds cold. It breaks down +the user pages in the system per-NUMA node, per-memcg, for both +anonymous and file pages into histograms that look like: +:: + + 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 + +The workingset reports can be used to drive proactive reclaim, by +identifying the number of cold bytes in a memcg, then writing to +``memory.reclaim``. + +Quick start +=========== +Build the kernel with the following configurations. The report relies +on Multi-gen LRU for page coldness. + +* ``CONFIG_LRU_GEN=y`` +* ``CONFIG_LRU_GEN_ENABLED=y`` +* ``CONFIG_WORKINGSET_REPORT=y`` + +Optionally, the aging kernel daemon can be enabled with the following +configuration. +* ``CONFIG_LRU_GEN_ENABLED=y`` + +Sysfs interfaces +================ +``/sys/devices/system/node/nodeX/page_age`` provides a per-node page +age histogram, showing an aggregate of the node's lruvecs. +Reading this file causes a hierarchical aging of all lruvecs, scanning +pages and creates a new Multi-gen LRU generation in each lruvec. +For example: +:: + + 1000 anon=0 file=0 + 2000 anon=0 file=0 + 100000 anon=5533696 file=5566464 + 18446744073709551615 anon=0 file=0 + +``/sys/devices/system/node/nodeX/page_age_interval`` is a comma +separated list of time in milliseconds that configures what the page +age histogram uses for aggregation. For the above histogram, +the intervals are: +:: + 1000,2000,100000 + +``/sys/devices/system/node/nodeX/workingset_report/refresh_interval`` +defines the amount of time the report is valid for in milliseconds. +When a report is still valid, reading the ``page_age`` file shows +the existing valid report, instead of generating a new one. + +``/sys/devices/system/node/nodeX/workingset_report/report_threshold`` +specifies how often the userspace agent can be notified for node +memory pressure, in milliseconds. When a node reaches its low +watermarks and wakes up kswapd, programs waiting on ``page_age`` are +woken up so they can read the histogram and make policy decisions. + +Memcg interface +=============== +While ``page_age_interval`` is defined per-node in sysfs. ``page_age``, +``refresh_interval`` and ``report_threshold`` are available per-memcg. + +``/sys/fs/cgroup/.../memory.workingset.page_age`` +The memcg equivalent of the sysfs workingset page age histogram, +breaks down the workingset of this memcg and its children into +page age intervals. Each node is prefixed with a node header and +a newline. Non-proactive direct reclaim on this memcg can also +wake up userspace agents that are waiting on this file. +e.g. +:: + + N0 + 1000 anon=0 file=0 + 2000 anon=0 file=0 + 3000 anon=0 file=0 + 4000 anon=0 file=0 + 5000 anon=0 file=0 + 18446744073709551615 anon=0 file=0 + +``/sys/fs/cgroup/.../memory.workingset.refresh_interval`` +The memcg equivalent of the sysfs refresh interval. A per-node +number of how much time a page age histogram is valid for, in +milliseconds. +e.g. +:: + + echo N0=2000 > memory.workingset.refresh_interval + +``/sys/fs/cgroup/.../memory.workingset.report_threshold`` +The memcg equivalent of the sysfs report threshold. A per-node +number of how often userspace agent waiting on the page age +histogram can be woken up, in milliseconds. +e.g. +:: + + echo N0=1000 > memory.workingset.report_threshold