From patchwork Wed Nov 27 02:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanchu Xie X-Patchwork-Id: 13886513 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 39002D66BAD for ; Wed, 27 Nov 2024 02:58:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B3FC8D0007; Tue, 26 Nov 2024 21:58:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 264228D0001; Tue, 26 Nov 2024 21:58:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08FEC8D0007; Tue, 26 Nov 2024 21:57:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D63708D0001 for ; Tue, 26 Nov 2024 21:57:59 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 896101C7810 for ; Wed, 27 Nov 2024 02:57:59 +0000 (UTC) X-FDA: 82830365436.28.BC8A701 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf14.hostedemail.com (Postfix) with ESMTP id E69C2100002 for ; Wed, 27 Nov 2024 02:57:51 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=fLDcEwrA; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3tIpGZwcKCCUZVBODIVHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--yuanchu.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3tIpGZwcKCCUZVBODIVHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--yuanchu.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732676275; 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=FdWbI+s0p0wBgh+VsWAydrlLqfgeB+x4CgOEMGbe8TM=; b=vMYkhtZS2kmUorq7l6CJpldSBzwr4muvLIA917xjFZX0NInWBGQL2pXeezq50iamRMBJhf gM5G8KVQNmiUfzThkTQ+Qi1IIFrezgWH7luKaeaBCOvkOkSTcNGpxchtF3iEoHjXs69s9a lgHracjIZpgmuxjfM58lT6G3AxTP3PQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732676275; a=rsa-sha256; cv=none; b=tDj8jrQcOkODjbA7ECb+6DwlqXMGPKO+wB9QJ8upAApVPtfIBditOQhzcpJLXG/Tm/SVXz hf63nTfKbqSwg7YQQvcbYrooyqqr+8q4rYy9e5wjvTyaNbW0eKsBvsiYo//S5YPgS5BBNW 9DlwzA6qU8+GKeD9d1gcBdiHhmTzU+M= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=fLDcEwrA; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3tIpGZwcKCCUZVBODIVHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--yuanchu.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3tIpGZwcKCCUZVBODIVHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--yuanchu.bounces.google.com Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ee0c9962daso342528a91.2 for ; Tue, 26 Nov 2024 18:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1732676276; x=1733281076; 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=FdWbI+s0p0wBgh+VsWAydrlLqfgeB+x4CgOEMGbe8TM=; b=fLDcEwrAgcenfq5q/jklvHDttU78q4n0Y3zlJCDdX8hbScFAre4BpFX6OFPinL9qwe RQln4hB+ou9w+fw7tAt06LdDFc51KiYJFJvXRH/+tDTwaqctK8Y4PhRv5YtNimO7ORLV nFO84G2qLuATki8x5eHTdLagI+t/bmFrVwvGjvhL5+3oMsc8oPpmtnlMmC/em1J5jz+H Mg5BoeQKk+mkiQM9iYRp3PJn9r2tRgtpnfr/A4tdYSzG4tP7Hj/O3A4uXGazEfg8sGbu WrXN/mOzw+XoX00yO7bjmfo26xe6n9tlGdu1kpqwdNZf5zmR7r2lJnNF6kAVNb2i/dHd O6WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732676276; x=1733281076; 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=FdWbI+s0p0wBgh+VsWAydrlLqfgeB+x4CgOEMGbe8TM=; b=IaLBSsQZ38jlFHYME9YDpGySQQ6BlLJO9zOOclSVjfBUwvrbhUe4tTvPlo2FLI33Yk MHhDip0RSv4u7gQkVpXxGm3awAO8xu8iH+vyd/r6rGzh4DFKvlz5zAsH0dApFi7FWJ4d XwUHR/UtsQyXp3FEpcy/MroCHCIlTO2iFafFLN9+Dn8q3pcIESjOfwMiwBgneZWVri+n 64vJCKd9CDS961jGMfrhq7duDtNDPzbEcNv+yrYYvxAS0AsWREnFjYre2EzL3WxIJHB8 9IwsaSylmH68zwcDNYVaaON5zjbYPkQKtPqOhWBkOG9XnvObD4qF4BDiW2HQnkjLCJ6U zEaw== X-Forwarded-Encrypted: i=1; AJvYcCXG0WEssSBxDum/+66TZDnFmdPexQsqGesPLkTwU6I+aSudh5eBvKf+IOtQ20EqvRkObH4kmlYcFg==@kvack.org X-Gm-Message-State: AOJu0YxOuYaUfCv+QuC75UcLBrlGifU/ELIc/4nb+ILV9eJXnu/8EgNf t2KkDaGgRHTHG9rdO+3Ke/r/Ct1SXqsd8DKBKWGWXQUnDgOzVUkcMrDKtxUP4/dFGT93CBrQBJ5 8JqXLvw== X-Google-Smtp-Source: AGHT+IGwhfii5+MtQdbRihMKL41ITlobJS3ldyPZjP/ITZaiG2+mPbpCQb3KZbCSJSGpnWkssvQZr9R3iWRd X-Received: from pjbok13.prod.google.com ([2002:a17:90b:1d4d:b0:2da:ac73:93e5]) (user=yuanchu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1d10:b0:2ea:aa56:4b0 with SMTP id 98e67ed59e1d1-2ee08e99941mr2057809a91.3.1732676276518; Tue, 26 Nov 2024 18:57:56 -0800 (PST) Date: Tue, 26 Nov 2024 18:57:26 -0800 In-Reply-To: <20241127025728.3689245-1-yuanchu@google.com> Mime-Version: 1.0 References: <20241127025728.3689245-1-yuanchu@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241127025728.3689245-8-yuanchu@google.com> Subject: [PATCH v4 7/9] Docs/admin-guide/mm/workingset_report: document sysfs and memcg interfaces From: Yuanchu Xie To: Andrew Morton , David Hildenbrand , "Aneesh Kumar K.V" , Khalid Aziz , Henry Huang , Yu Zhao , Dan Williams , Gregory Price , Huang Ying , Lance Yang , Randy Dunlap , Muhammad Usama Anjum Cc: Tejun Heo , Johannes Weiner , " =?utf-8?q?Michal_Koutn=C3=BD?= " , Jonathan Corbet , Greg Kroah-Hartman , "Rafael J. Wysocki" , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , " =?utf-8?q?Eugenio_P=C3=A9rez?= " , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Mike Rapoport , Shuah Khan , Christian Brauner , Daniel Watson , Yuanchu Xie , cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org X-Stat-Signature: 1sr5ywf3zdswir3bq16o5jk3towbdonu X-Rspamd-Queue-Id: E69C2100002 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1732676271-112392 X-HE-Meta: U2FsdGVkX19vaZfFo7dJLXUX8gyzIH8EJEJEKJ/CxDHisutYbwkK3gRCeGpCP9wkCqoUD6PaKKte0hhcf2KhDcr65TMEHGjPZ+OxX7AVlNZUrXIvGvp+NqA1olS4rPMK4vTaglht7oo9x9UWi2paJg5L0FvApVqR478Kf437qejcCTasD81NAfwDNKxUW3ww7Az3r+TJzeYwJlUWe3QHCoy9IhLQdqkTemGcpAto1fv1lsPYgOTRNi2Fts/vglfpiHqTWCyqUAaBL8tbB2OKCg6m/blfs7f0xdY2ldKLgtYt4v8cfWjljDzHnmgVU10utD0MO8zSYWbUDHrWZYd1OTNeY6tMPV+KWXBDYC/lTKBIUj7XxXsvkL4z6G/mgSVCy7ifU5CCGbqgAzrYGQ6hM0wr3gADIrrpLQo5Iha731X4iJW3Y3nV43v9AQDGZJFDqOoSzBMwDdZfbIw1RtHYjTOvq3laUjb8WwkuFuvsNaN6fZlWu4S5n2jOm8JeVuLxavlwoeQB2QZy5f9kaScW5QDgTEHo//SXaptcaAmQ/J+oSzO6Vapt8sor5mBZzJvx02WgeRWzAh6GycpMaNGoI6HcCvJa7777VuCw+Cbz8Sm8PanJlQk1xxQZbeGdUUBC5NZY9ZdsorueDCk5gd/JWRxhZj5tgqHU4l+mpY1v+xbQM3mIKviVbiNrO6XI09e7x7EBFXxkJYJbeuGnLj23ClsTWvkCEd3KmTjPuSgwIY0F56QkUuQjcwU42zoH59vbSXeTLUOmgNfOH7PocOxJwVmI5vmuECoZNjUm2KC3yazcYFoH0Rvzrvto/5xn6m8G8+QNkQ2tvHBFnKpP+mreOMO2fPAPkCTxzGwCmF1WIye/MTt0R/MciAKka8Df1O2YTCkE5hSgS5qX02wJl7AqSG9hddmIk5vMETRcEHF7CtBKrJYZELScBOtYwc4b1hCIxZjnAgCj0VZK67xDeVZ efESxiOP f1Krd6Yp2hVuH2evlgpz/6+6HeM5rPAPLILkG4Jq7h0kZEDqCpLeYgkJAODPCpsxFN0f1PicUbaMVUTkgFEqUUhpt0xdLDsdSgcxB4X702W2TU9veYK7/RWwSMcaMyAPOWcFI5gp9G+dXY32NGqwbQifAd7VJMb73LGsSkX4oscHxrbamo7FA/uiSPXHytWRE2RkdNeYVfWmHfZegfnjfS/uJFLqyLvfkS3RGULlfZMO/1VbtTSeEvgIHhk8V+pLsx2d+RnDhiXLDBbevr6hnI+cgSs6hbOvAUvd6G+njzPO0uduaGIUexlc47ZHF2peTGJ9U/qm8ms8+/WHjeB+daMKuCIXZHzC47Z5trEfq+w15wGpCnF2ua7KU6i8oOYE1/XhvZOItISZ/CZ5njOQUjpWZ0ZDWaRo5JVimvY5IovT3To+rK2ZvTUBhMdtS6Vw+EIixhs/hlkJKBy5k+0HvNH0cbuoTUcsfWpupwvlkpwl8oQFdpGKyTNXp3GQBAAKZj8W8awOvzmMQuIzUZ2fYTSG5K9EwTy4hJjCIQDo2mH0SPh9AQpdkK45tApmCGt6Dl7R++NvCzjUMqtm0+uvC7IRFMo/MRd3eLY0f 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 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..0969513705c4 --- /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, e.g. 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