From patchwork Tue Aug 13 16:56:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanchu Xie X-Patchwork-Id: 13762350 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 A84F8C52D7C for ; Tue, 13 Aug 2024 16:59:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D06EF6B0082; Tue, 13 Aug 2024 12:59:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8BAC6B0089; Tue, 13 Aug 2024 12:59:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB50C6B00A4; Tue, 13 Aug 2024 12:59:53 -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 833BC6B0082 for ; Tue, 13 Aug 2024 12:59:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3C54C1209B8 for ; Tue, 13 Aug 2024 16:59:53 +0000 (UTC) X-FDA: 82447834266.25.5A23074 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf05.hostedemail.com (Postfix) with ESMTP id 3B33D10000D for ; Tue, 13 Aug 2024 16:59:51 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3W+3OL6J; spf=pass (imf05.hostedemail.com: domain of 3BZG7ZgcKCFIIEu7w1E08805y.w86527EH-664Fuw4.8B0@flex--yuanchu.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3BZG7ZgcKCFIIEu7w1E08805y.w86527EH-664Fuw4.8B0@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=1723568320; 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=hOP5SFFIvPyG4OwQTVSroxGri5wlFhobHFeL7lq0KZY=; b=KRXZTNHfwdjxzzp0NEavnc1AjyKse8NmxFx56j7QSJcBDdCLWD3zD/6XqbGTdYtbBiCWvd s7cGE44bPJBR0sMzsHkuYAQ6p3MsdmrV5hNzCe5ZB9cQVgRG5mTc+UiiTcXr2wJdywkGml ezN5IVJzoIonaDLmgLYLm0o7qRhIEbw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723568320; a=rsa-sha256; cv=none; b=4GXedSBSXZ3usyUik6h4Kih4ul2gwt0Dbhkjfz/qn8uyGeFH2P7uXBenNdW/nD5OMjsHbz c9rjxsH0WolO1kSjmKu/kZENOfSaUqorOxpz/Gu0e5ezXne0lbZfbuUUMeGdP9S5k0uD/5 geIMfqZPrNuwu5dhsTtPDPgJ8OqM6a4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3W+3OL6J; spf=pass (imf05.hostedemail.com: domain of 3BZG7ZgcKCFIIEu7w1E08805y.w86527EH-664Fuw4.8B0@flex--yuanchu.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3BZG7ZgcKCFIIEu7w1E08805y.w86527EH-664Fuw4.8B0@flex--yuanchu.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e05e3938a37so9427382276.2 for ; Tue, 13 Aug 2024 09:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723568390; x=1724173190; 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=hOP5SFFIvPyG4OwQTVSroxGri5wlFhobHFeL7lq0KZY=; b=3W+3OL6JrqQ64Z+r6HcWV+xWwPgzO1WGzI1DzfhbUgrxBSkqOdNSWpknCAE6Idtbmm 7qOlhu5a0eNbAOsdbkJesSdm4Tb2ne08OAbuS9GFGSO3o9GYNhM2i77qvtSj01UgVC6F zs2wMUmvVEZ1Qx4c/cZC6tBQeD2HPJA6tdXa8RvtPYZ4Ncq9pA5NUzgjnm7vYkNLy/aA V0gHlF84cApPzTLFLUAJl1fRReGg2im0BByzOmgy4AromKKnzMKd27LbEvtb8XUuFf+i QJXMqtqgF5GdkhOvxy9FLc1bzE1cBRsAIDqksJUFEQWrK8yfdUmi7WAPMTZNW8b5PJm+ fVDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723568390; x=1724173190; 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=hOP5SFFIvPyG4OwQTVSroxGri5wlFhobHFeL7lq0KZY=; b=iFTWZpIjUiNsQBv+FG8GzyoVs/ygx2rVrfaIGcuQkwMC1cW6nGUBY7qtWpZpAeyH+U m76B3+e1C31BlBvTnNc022aveFsSAHIkk4GHkrLpGI7IZK+wMjic/oZpOfhvsCeAUwXp S5Lzb7cgerFxK1GV7XP/T/6joaidPzQ/TW54eq2eHLgdXtUZbGGLtjarX0QuR5rS6nvX NCMqrpol2aEY4XkDCkNMj93SQmXypZuLkUNLfl5OarA3oXH2cvr3ogfziwvclgCxjJWv IKfaycChBOgEyldG9bET02emJn0sDSPoCe/OG6MhsUhgW7BAz3rvtApjjcqfc/WhvvaB r7ig== X-Forwarded-Encrypted: i=1; AJvYcCUZaQSybTELdtDKo+H/DhFwb5Rk2RAUotINUkzbd+34tV8/Ux+kRhwm7apSBjcuvPWh+nrEtS2M4JyXmWKYFf6SGmU= X-Gm-Message-State: AOJu0YzaC2j/zdBSZ7OO21oPXw36dGN5oqmntPudrRBdgaUSF/wBqSjI Pft8cHpBQNmMLGswjDve6UzYoQzihEYeq5jRglCAOsB5KG2/YnyEI8zRSVQKz4Qa3pqF3BfNXb5 pFoH9KA== X-Google-Smtp-Source: AGHT+IECAXtBsp42GLKJ5N1BoyX/FjeEZsFBUtplL8hab3FEghl0VDuEX9j5TFSLO+qQ7fOJRfdfV8wWTHGk X-Received: from yuanchu-desktop.svl.corp.google.com ([2620:15c:2a3:200:b50c:66e8:6532:a371]) (user=yuanchu job=sendgmr) by 2002:a25:7450:0:b0:e05:fc91:8935 with SMTP id 3f1490d57ef6-e1155a4ac06mr3055276.3.1723568389892; Tue, 13 Aug 2024 09:59:49 -0700 (PDT) Date: Tue, 13 Aug 2024 09:56:18 -0700 In-Reply-To: <20240813165619.748102-1-yuanchu@google.com> Mime-Version: 1.0 References: <20240813165619.748102-1-yuanchu@google.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Message-ID: <20240813165619.748102-8-yuanchu@google.com> Subject: [PATCH v3 7/7] 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 , Andrew Morton , Lance Yang , Randy Dunlap , Muhammad Usama Anjum Cc: Kalesh Singh , Wei Xu , David Rientjes , Greg Kroah-Hartman , "Rafael J. Wysocki" , 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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3B33D10000D X-Stat-Signature: 3wc7buw1cqp4hor4suzshgurcetie5dp X-HE-Tag: 1723568391-146996 X-HE-Meta: U2FsdGVkX1/2SRW5vPS9LmrVo1BL/nRi7Eft5Yy6evbJPXmGYa341WZbb+veTDQCqydPdQizQg0BxoWriZuh3S7FmE6dT6ANdAygGs0pwE7kKS9LluQRva9KQP/6htYoS8zSB/fHH4YxDVtZ/6xa1hfFXVQJIudu+JvU1ew1QkQeCkb1TbfPbwJlhiR33QV8vS99wyjAXryshh+X2PUgSTO70Ab/zp2CqF52KMaS9WJp468EGWyOaOnfV0OBG04Cb5ihiRSzStMiWFaF/M2dYqvw7R1oMDUKk6E97ciiPZoWXR8ztUAOBnATNDC2VmW+Q9v+oSq+rJ8YBSX0gHegnM2dF49T8uTXgtWjlS6kpjpKPPR/7no40Blt3bZmU+hHFo6KJGGPNADYGfM7QxaIM8Bh+q/FIbtDpY2+Kxw2aDDwgFF39+uYgUNPcsoS0OpOFExoStNkaew3qdI8Pvn1kuNfU0vxc6BgZbQWwyzL3E3q+jV0GUj+fW7lNlQAzPYfzfvNTYaAxtfGKEhIzFWcPSE6tvxUGP1sPAewloI3wnnoRLwFrxFEwBDdZnliaMln3a8O+nKIg+6mSJY5pDjcOw4mEjdK03vYJsZJXwp+Iyz8oWTuyqL3vfxqTh6kWr5pIK7R4XanJyewKKezYRnwIKjRND0lQO51ArnNKa9PhKQa/NqzSS3aX4WzDPsIpgXDCt+RZkmzFOGcEWG4sPlmSwp43JCxSToRPwTM4Jth2OafEDKtY5MmTzGCA/6TiDxVY7pW00k2vvRuQx4Gq59Bo4bvlnGDaW4FurydKMcrcoz2/cfAt40Zqpta/JOnAGO/cDd1hWWel4Kr/VRp/xkzuPp0E2+0BorNkFdo7XTMTgd9yZtuO6l1O3WUbhzUX/PKeVaNGrgAbX0+zNjHvBnshhv+I1txyfYxb3AfXX9xsXtjUc1m4FP2v6QhuE4npBetg5mSADEweMx+jDI4323 kM8TEsQ1 Nl/7Ur4Hz2q9592hMyBA4zjLWyd0zsWzVJJRBEPYudTXDbtROFRyzdn9WEdgWb5ofXuTzRUDyjFfGoGj7K+na8nxhN4WcQrCzul2HuGAsTELpIAc+Js/JTFSPtwp7wMk61nsLCR1OGGCXc4afsaEijHVgeViojXqM8s7ajcvUUf5FkUOIpj+Ds8Xt1o90TvHm6b6k9oGdBtJ/vcSFBHgwvh4MU8W8lzLLzJxTh9VXRtc4cJ3GZlDGhlytk+yrpeN984qivcwCkdylfR8JrUNN+vhnWSOxbWp8SuY3bvS7+WBIIfO+C69g7QARsqEGJvN4n8IQn6XvgkLRZ4A/tr8oCZatFsC4G1tXyKU52BK0lBa85kTRBQinMNQOITrNSm03U2bV8pBvQC46SWIuQ+njmLN1yHYPrehuDrdbd5GiEyQUjj9Q6SJDrlUjrVaY91Lre8/aZWqhk0d5FU6Q89oKVMy1W3XG9IbSCVR0/PPz4371rUWVj9oiJrpCfZyfCXpikk7fE2mB2IH9mRMr9D2T8Kens66wN6dVjxTsS/Of50UVX7WXChrcVE9DQqepNcZUewZikofJzDBbLW2CfPkYutaBTVY38tShLfyLI7yAgqJk8E173YkuML9b16GebrMORm5K 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. Change-Id: Ib9dfc9004473baa6ef26ca7277d220b6199517de 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 8b35795b664b..61a2a347fc91 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..ddcc0c33a8df --- /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_WORKINGSET_REPORT_AGING=y`` + +Sysfs interfaces +================ +``/sys/devices/system/node/nodeX/workingset_report/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/workingset_report/page_age_intervals`` +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