Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1326675lqj; Mon, 3 Jun 2024 19:08:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmMxyir1jw6RNIFko22HoOS+W5SN+iSmjVOJLpOhLWYCtW1PWzSESvcGGmjigW4brvuqUOhqJfKGXHu3CH00oHlzmOxtRPmcTzjQ32sw== X-Google-Smtp-Source: AGHT+IH9kHSDCSa4zBczvOKdA4BdxFAhC3kaofuWNmXeN2wR0SEAZQWlLLiWKlAywSc9zJzSejNr X-Received: by 2002:a05:6214:3f82:b0:6af:4787:223c with SMTP id 6a1803df08f44-6af47873fecmr78672746d6.45.1717466914951; Mon, 03 Jun 2024 19:08:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717466914; cv=pass; d=google.com; s=arc-20160816; b=a8Q3tAPp4HaKrULiDft4aqm1bdxdZNT6/LLpPy8pxBunXsWuZ4D2+CZiOQDNw9wSi/ KVxtabLAOE35qvu9SlJN6TP/vJDYhIRuerV0tedwTqXePjzyBXU3XFbCd7vlS61jbgLx 7op2q1XBcU1GTdin13XYKCnJaoYd4i47O8LTGHFH5I/iNApZZlpata6EPHyfDP5yF+Wh ba9sZBZQV73I9CBuSNTl5YAPNE8fynpViLqwjA1FU2fhE59Yt4NnorHtJoqcddlRInsn OgUoPmw7trEat0lvfnQ6f25iuOe/2imgVsPCEX46hE00sqoj+rYQchAWxgM3GFWsYB6c fYAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=TnO0wJpr9VrNuJfB7YNxreIL5h7wQch0G6mtECTuPNI=; fh=EM26YDrhjlJ6JJz/JfXLjNN+vVCLVCmYCxrKziPBxG0=; b=UHWcmuMHDkHz9X8JJc+/J3U2jo/8T1EOK31yJ9BA+1BiWporcgWHtjkTm9Trf9Sj73 MxCNDu5RQ52cw7As3V+ygs4hzeSuvBP4mPaav/Eq559V8k+ecDHWYZlH2ZKSmV4tdRxZ +IADb2nfAikrZp+VfvLgnGwfcbmDPB6eMHgKoGdquZmHGcMyPv/9BZBUmL4S2WvCeaH0 COB12GaZA+eVv/1cSp6YR6r09Mcp642r1rQ3FLDykdKQbOIqIYAxw2uQTW9XJ4VYhWw9 cxHeuaDAqyBfiAkiKV6ok4kdV3RR0hiNcNzsajw9DzpjmBb9OLGeQBB34N9K+S/R/6Xo WOEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kw3CUsG4; arc=pass (i=1 spf=pass spfdomain=flex--yuanchu.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4a742608si85663406d6.183.2024.06.03.19.08.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 19:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kw3CUsG4; arc=pass (i=1 spf=pass spfdomain=flex--yuanchu.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1D3AA1C24069 for ; Tue, 4 Jun 2024 02:08:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B4771411E0; Tue, 4 Jun 2024 02:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kw3CUsG4" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5966514039E for ; Tue, 4 Jun 2024 02:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466785; cv=none; b=Ue7yjlzV5AJnCZ84jYbKjnKU4uRwv7JYWC8l2+P9w4P1ucgWi2x2GCWYaOwmPIx+PreshWe2YPr98S2ftXuE9ECVfSQ3tUrEoHLq3Kb2cIGpMJC6XXYhLMGxGW0A4+xGi0J57bCTNCONbQChaF3YQFPkZDhqkZ+siei/4P32mIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466785; c=relaxed/simple; bh=eASpyk4WWK4m1u5bAgzdZmzHoLxlNRCkiIkqJ+AFaTw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hD4+3TfXv9L+9xTE5xmqu7fBD7Cb4KUgjZ+kTR6tZMoxRjt4iiWJZ5epDEvIWCoSTR4JhKrE1QYLPE54b/7y+WLJE4g4QEbe1BqagXZYCjF64SCVAvAt7qJzLDQvhoubHGs80hHPm+b9lxGPYhccNkBNG89G6qJCpMd1ZSWijWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yuanchu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kw3CUsG4; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yuanchu.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62a3dec382eso54944237b3.1 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=vger.kernel.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=kw3CUsG4HuXRbBfwPxIlmqbR59+zdoruCRpZfL487nlZ/KeYrxAz5IYal2lceH7KcQ M090USlbcJr0vsXC4S19u/7Wl64ULN/7p+VrkpqJB2xukoqq/ZTtsK2BND/MKg5tcRP4 g68Zq1Lyl0xQ8Qyos4iFJUsv2uRnYVQV77jpfMKFYy8gHKVKh+k99f9oDe9eijg5ov1r GiveBNjP+eolSf94p441u8j3HDuZO8hjKV63kEie0Og9IeVVt7JVw1FbSj+Luv6/vNz4 49+OPKcDmrWbAf9Nn7Mm+iKp8S/jQisMIqWGJekmOVrt92iCG9X1IkSqj0yC5GpD1vVM 1Sxg== 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=LvP0oABTM6fu3/ziucsiVwEXQzftFGHZpSNfIVa7KCgKCQb3TELG/a38uYtphAuMyi 7YlcFfVY7UN2nYQIMfcnt6++EwAVHxUkuwOtsxci3Kr63iVAL5uHfcBkx65Smb640mBX P6uwLJxzBtEmcBXq1UKe+ZfmpFPUiWTtvRnMCYzH44yNnDTVOxfhlyA1ISzzjAXL99jV cnvUJB3tdZRBywNFSKV+X1+moKOQp7B9atqWNidw7rw64jToKozS8uXovVsaVrP2fyfM tDU4/jPVwNFMBwVPdRQxiGqD/+tkxRZnkDb4+dpZRJenvkJQv/diIs5pcfUjMUdz/Tee 8d4w== X-Forwarded-Encrypted: i=1; AJvYcCW2z9MyiZFGTRK91XLHc0jxxp70P6Dj7pd1UWiaDUhIKVkltivytpBdotB99d5EWZpNlGBIwi35QtUDQg7+8gLKiXrjOsmdXCri5bCj X-Gm-Message-State: AOJu0YxgsOmCC6sv+hpXl89FvROoekrZlXUNeLm1Cn/54SUVaQmqxISx BkxKYoMhWvw3NC3bL6SA7qopMU6tNhg3Bk1NWeKzhEFL5peb7+T0v/UjCIDghL29EsdNvohN4bJ UlhrI8Q== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Type: text/plain; charset="UTF-8" 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 -- 2.45.1.467.gbab1589fc0-goog