From patchwork Tue Feb 14 03:54:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "T.J. Alumbaugh" X-Patchwork-Id: 13139347 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 84437C61DA4 for ; Tue, 14 Feb 2023 03:54:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B55CA6B0075; Mon, 13 Feb 2023 22:54:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B0669280004; Mon, 13 Feb 2023 22:54:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F460280001; Mon, 13 Feb 2023 22:54:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8C2DA6B0075 for ; Mon, 13 Feb 2023 22:54:58 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3A85A1A09DE for ; Tue, 14 Feb 2023 03:54:58 +0000 (UTC) X-FDA: 80464531476.01.42A98B6 Received: from mail-il1-f201.google.com (mail-il1-f201.google.com [209.85.166.201]) by imf14.hostedemail.com (Postfix) with ESMTP id 89094100002 for ; Tue, 14 Feb 2023 03:54:56 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=AV+uwc4W; spf=pass (imf14.hostedemail.com: domain of 3DwbrYwgKCOwhOZiaPOiUccUZS.QcaZWbil-aaYjOQY.cfU@flex--talumbau.bounces.google.com designates 209.85.166.201 as permitted sender) smtp.mailfrom=3DwbrYwgKCOwhOZiaPOiUccUZS.QcaZWbil-aaYjOQY.cfU@flex--talumbau.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=1676346896; 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: references:dkim-signature; bh=S6nMros/llLdOXJegqR0CJWd8CtbBj3YwsU1eZ6n/QU=; b=Bjyhd+kwHci0VWY1L0mo311E8Ep+1C7zAcC3XgfUL47sVsvI59n5RSYpPTBG1zdep9NcNa Te1l3AYsKtoJeGHynH4SK375Ht9hTMA+ccsqsyVwF65Nsgbb2uxWt/Js1EhdSO+mhonJGg xD5GwsSkYFFXyS0iK4eSMBg5v2bTdnU= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=AV+uwc4W; spf=pass (imf14.hostedemail.com: domain of 3DwbrYwgKCOwhOZiaPOiUccUZS.QcaZWbil-aaYjOQY.cfU@flex--talumbau.bounces.google.com designates 209.85.166.201 as permitted sender) smtp.mailfrom=3DwbrYwgKCOwhOZiaPOiUccUZS.QcaZWbil-aaYjOQY.cfU@flex--talumbau.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676346896; a=rsa-sha256; cv=none; b=RI5zCFYTqYSwU9HrECDgYYduRolhOgqMiWmF3sf1Pd6AdTyYUrEoRHMxrmh/IbXe7t3GSx AFSLdaN82gM4+PuC2PiN1VDvgmCC8qnh7ZAdNOvg5Fr5iTXfvLiTxEUJrPLY9L7yChSry5 nX/r2BsQjUXGaoiWxsGNBc34GPDfJOM= Received: by mail-il1-f201.google.com with SMTP id s12-20020a056e021a0c00b0030efd0ed890so10524736ild.7 for ; Mon, 13 Feb 2023 19:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=S6nMros/llLdOXJegqR0CJWd8CtbBj3YwsU1eZ6n/QU=; b=AV+uwc4Wu/3TUe2Tq8ebGYJUlDknVB65+1thDMNYyz/jfFRCPg6gfjllMqFPj/zxT5 nbfAz9aJQR5Wc3mFz5GXtCyjPLViDEfRvLsyQiS02Jo3rBIwBI8fERbQ1qOMXZ0IrLjp dvKSXgowJ/d4QSYscbDL93iLrBWrk7EPrTSBgIu7UNg/gJahW/ynVmQ8a6v1YAOgmtbn xELIGeKHFcgMWHxg5XKsrr1jJ3+TIGpIWLU4+KTojX3rVS726g5f1h9+iiNkU6qTCr3U Kq46XPk1j7oQlexXnXL5ZlMOOa6fKaB8eE8hUb7S1ZcK3h9pnicZDBa2v5V+AvU8InEO JqJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=S6nMros/llLdOXJegqR0CJWd8CtbBj3YwsU1eZ6n/QU=; b=KELMXlB5A+11Rgph4FfYguJmwV8mjSTIqauGQvO4tApwpMQrz0/Ea0vsnqWN4XFYC2 NLA5kTkVOkOJ2kkurmFrp9z1uNRhsj/YpTl3I0gsgTUiIjKIUH5G25r2FOhb6FykB3VR i/fTXbf/KlRiczOjnQb4KxxTMSoKLP5R/P04DEw6ctdqfGoqFe05tEr6leE3K4ATLkHV rnzKlRFbolnh6ASahuSLrW1Pqrq9lqVzGtGw4sJWDdcnVkdht1KNloUqNL5Es9YNtNwU 6MpFpkniH9rer9rwZOQJxbQLSvyEntPpsTAjjVJSTfS6O1gZ/c2T+3GQ31oIKSC2CtRy vm9w== X-Gm-Message-State: AO0yUKUGNLhTlp9Vl8NWd1lqecSk9SvM7ytiWbs2UHgZNOicA+U+VySy D1LLOQXVydcdr3jIX3FY6j/aQwe8IHwvsQ== X-Google-Smtp-Source: AK7set+jb8ZXOF5zqKGlgzK/J/rvicIo4ppN/vI0cHmrisQ/locMHHlmXxARwZnhsiFVKT/KaNUNLrUVi3JKQQ== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a02:3318:0:b0:3c4:88de:524 with SMTP id c24-20020a023318000000b003c488de0524mr105734jae.3.1676346895649; Mon, 13 Feb 2023 19:54:55 -0800 (PST) Date: Tue, 14 Feb 2023 03:54:44 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230214035445.1250139-1-talumbau@google.com> Subject: [PATCH mm-unstable v1 1/2] mm: multi-gen LRU: clean up sysfs code From: "T.J. Alumbaugh" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mm@google.com, "T.J. Alumbaugh" X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 4bwpfhynw3oyu8zhrcz1s9y6zc8j99os X-Rspamd-Queue-Id: 89094100002 X-HE-Tag: 1676346896-312006 X-HE-Meta: U2FsdGVkX1/oP7FvPU+tEdTYYtwmeQmXNAjB9sdZiRrHPDfNZBVw8lfBS442GkGNAzGZZtasyuy3sHm755yhLEPiJgfH9iXeoIkRWgEUakEilbZ9IdsbUMJq8g9OiLez3VRO2V2sBQipLeG3SSAeOUg/Eg/o10GRckIfwY5w+chWiqSzpJrcKj18xj1XFWiCJfBuYxSaykgId4NKK/sw2rcufVe93REW68bS8Q+tdRi9UakpT0kphaeqAjHSrQ49cODTO+yS0ZhsjuX49l3qq+S7AzHOAkkPkHP/rylihQpmqPgWQyMRIGNBy8MoxI/OZxeFWaOOCUHdSgr7NB+JSCyv/rcLWPcdJb2ZXeJ5IWpwaeb/BxUnddUP1nfi09jtK5K/WMPyfbeWjp3vR2DedIR7SRatQ/vJ/ynB80G2GGN3e6bjDeD2q0Idu7f8j/0SPFRt4jG7K7XHmQySsckUMPQIDwGwPZKkuaH33ivzgGhNO9RNZ3bOhtcHZSTgiIZcNUNCaz55vdmYF9pAJpM2TL3bJnJ/lioHrNFGyw6fe2TQ0Iq39bCfhA70bkmcamOKmx9+OlOTlY7X1cMD3b/lqeLWNFcI1OqxQa7OYIXL70jcfNljmN/4Ti/f1Qw09BE8/lpuS2eY/Q3TGslCy0KAyO+hhmpKbUUgc4zYNuFTcRlLDcSxAKvV/DkDTW8MPP9h2P8Y2vykR/hUyigXJX1Bhgu/r2lSeVpfhxMymfuvXZIQCpi3qKg2GrCZ+a1CLIvrawGbIFFki5vLW4LRqBqMAw392npJ9G0ZSNX17pyGGHo6NlkG2eb9EJCgOV6Lz9UPImdqgfBPt3ct+Wdnh+GJvAHK5OhS4esnUiIZfzeO/peCO+gLl9/pHoGUT/lc3otQnBYpkQg/kTCWr6dBQ2lRQve04KNIzCMOcH0o6DI+Vw9bw1GnnZkxNiQeoYb83U25TV9tCa1wcCZIIxDa6wC 0ZQN3wkt +G4uFZx4NySoqqID/nKupytr8xkNcU6LX4C8N4w4CJ6oY4VTyJQuC1vhceWQG6HDMUf3Zf9cABOjUPFXRACXfuxq3VRWD32sMizBVkH7KSbdKPquilR+EwIRS3BuWSokmA2du3jW/Xco9JHP5uaLh49No/HsZCHTIPWBUR0lwAK7U/btO/7vG84jZ0XAGluFqcfI4mMBYN/bSMPltEyEJ5y9t3h15whsV+tcptDzbRzGudSQi7m7zqDbkBIFJDYFvhocY3fCdvKs35j3YgLK2PMCmLPnoMC041KVHGk2faR2l1IV5pDYy4ui0JDLw3NNrOdCPPcVaB/MfP9QuKcRLo96c/xuR0eyR7/PSPz3Vm2CCkuy1yfDwGg4qqeo2x+AbexYp6VZXfBglfo3SsEnmq8eCY9FjduPom4jXHty1XhYmwaYLJH4BwL63NSmYFo7ftPNDrIzTkATIvkf7ul/56G68qYyi/f+9qvWNqdip0A7wow4/qFCcczOwcPJDUQ+p0oxyRGLoggbBHygd1/kUIsMGEDOPQvAzCunOoZw9twT6TMm6MhWfFaRcHnL/cL7OYkvSfZIy8UjbLdMpwRAaF17Y/zmMrHOv8s4txuLKyrL4wEflZynnvt/EQQA2t/8attQ+ 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: This patch cleans up the sysfs code. Specifically, 1. use sysfs_emit(), 2. use __ATTR_RW(), and 3. constify multi-gen LRU struct attribute_group. Signed-off-by: T.J. Alumbaugh Reviewed-by: Wei Xu --- include/linux/mmzone.h | 2 +- mm/vmscan.c | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 9fb1b03b83b2..bf8786d45b31 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1369,7 +1369,7 @@ typedef struct pglist_data { #ifdef CONFIG_LRU_GEN /* kswap mm walk data */ - struct lru_gen_mm_walk mm_walk; + struct lru_gen_mm_walk mm_walk; /* lru_gen_folio list */ struct lru_gen_memcg memcg_lru; #endif diff --git a/mm/vmscan.c b/mm/vmscan.c index d4b9fd1ae0ed..09c064accdb1 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -5658,14 +5658,14 @@ static void lru_gen_change_state(bool enabled) * sysfs interface ******************************************************************************/ -static ssize_t show_min_ttl(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +static ssize_t min_ttl_ms_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - return sprintf(buf, "%u\n", jiffies_to_msecs(READ_ONCE(lru_gen_min_ttl))); + return sysfs_emit(buf, "%u\n", jiffies_to_msecs(READ_ONCE(lru_gen_min_ttl))); } /* see Documentation/admin-guide/mm/multigen_lru.rst for details */ -static ssize_t store_min_ttl(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t len) +static ssize_t min_ttl_ms_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t len) { unsigned int msecs; @@ -5677,11 +5677,9 @@ static ssize_t store_min_ttl(struct kobject *kobj, struct kobj_attribute *attr, return len; } -static struct kobj_attribute lru_gen_min_ttl_attr = __ATTR( - min_ttl_ms, 0644, show_min_ttl, store_min_ttl -); +static struct kobj_attribute lru_gen_min_ttl_attr = __ATTR_RW(min_ttl_ms); -static ssize_t show_enabled(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +static ssize_t enabled_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { unsigned int caps = 0; @@ -5698,7 +5696,7 @@ static ssize_t show_enabled(struct kobject *kobj, struct kobj_attribute *attr, c } /* see Documentation/admin-guide/mm/multigen_lru.rst for details */ -static ssize_t store_enabled(struct kobject *kobj, struct kobj_attribute *attr, +static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t len) { int i; @@ -5725,9 +5723,7 @@ static ssize_t store_enabled(struct kobject *kobj, struct kobj_attribute *attr, return len; } -static struct kobj_attribute lru_gen_enabled_attr = __ATTR( - enabled, 0644, show_enabled, store_enabled -); +static struct kobj_attribute lru_gen_enabled_attr = __ATTR_RW(enabled); static struct attribute *lru_gen_attrs[] = { &lru_gen_min_ttl_attr.attr, @@ -5735,7 +5731,7 @@ static struct attribute *lru_gen_attrs[] = { NULL }; -static struct attribute_group lru_gen_attr_group = { +static const struct attribute_group lru_gen_attr_group = { .name = "lru_gen", .attrs = lru_gen_attrs, }; From patchwork Tue Feb 14 03:54:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "T.J. Alumbaugh" X-Patchwork-Id: 13139348 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 2B05BC05027 for ; Tue, 14 Feb 2023 03:55:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F5EB6B0078; Mon, 13 Feb 2023 22:54:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A733280004; Mon, 13 Feb 2023 22:54:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70E65280001; Mon, 13 Feb 2023 22:54:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6177C6B0078 for ; Mon, 13 Feb 2023 22:54:59 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3514C1C6441 for ; Tue, 14 Feb 2023 03:54:59 +0000 (UTC) X-FDA: 80464531518.28.6D7664E Received: from mail-il1-f201.google.com (mail-il1-f201.google.com [209.85.166.201]) by imf06.hostedemail.com (Postfix) with ESMTP id 6948C18000F for ; Tue, 14 Feb 2023 03:54:57 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=DNQ50Sta; spf=pass (imf06.hostedemail.com: domain of 3EAbrYwgKCO0iPajbQPjVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--talumbau.bounces.google.com designates 209.85.166.201 as permitted sender) smtp.mailfrom=3EAbrYwgKCO0iPajbQPjVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--talumbau.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=1676346897; 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=M7z7DhJJ7GQp6CX5gwTveavGyOgqeiEEFMgrBGxLBZ8=; b=QGSn/IzYWm0G5Bd141/f59DT1kNjnuC9RtPAu5z9LWsW72ylDbRgKDrNQLIpXfM2TQ04Iy OCZYeJOP5d9FUhjq/l8nEgAJDXhYCZaPEIeUmPfTq2FOflHDoSVvlyes32hSJp1VsjAEtU mlLRO0FV9zLjzVnOqdmYo+DXK1v21jM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=DNQ50Sta; spf=pass (imf06.hostedemail.com: domain of 3EAbrYwgKCO0iPajbQPjVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--talumbau.bounces.google.com designates 209.85.166.201 as permitted sender) smtp.mailfrom=3EAbrYwgKCO0iPajbQPjVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--talumbau.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676346897; a=rsa-sha256; cv=none; b=ESN13VX/w9psCXW+E5QH5YJ1LWj+uu3WfH8drsLlUgqOTgrPVaL5B/ezapyAl4mjLAfUV5 cfBFdcEcNDUibkAnilMrRXpggtmLS/z6wt+ABJvTcyWY8keH2eOHK9j//qJvWnohzfO6it eqlUlrLh9/zohQ4tiAsERNEOH4NBkQc= Received: by mail-il1-f201.google.com with SMTP id b8-20020a920b08000000b00315565cf4b2so1382649ilf.1 for ; Mon, 13 Feb 2023 19:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=M7z7DhJJ7GQp6CX5gwTveavGyOgqeiEEFMgrBGxLBZ8=; b=DNQ50StaD0fjmUsChg+gdyZp+khgLhAxfrWnJb2OjAvyrOWHpTYym5niXksLMEJ48x BFErgHn8aGfTbHqafwyUa+VSRZMfJwNGCIxqG8OfEHYlw+yRb1MLm/hOBe4f395C77aS 8o8OrnaN+u5BXtjEcUB5UxWiVYbSKJJXRBfRQJwjc245KCkYJcXUBmS0XQlJf0QNXJgt 26nrLQVjHocIy1JIQXEKFZZeyDCQ+PJ1u48kYdY0zT7qb6xgcy3KPPoD2wZ337KrikqS C7DCmeU96uqcKBYo2fglHR6luPpVgGamDa7H/Gr2E071d0jxmUgB8Sl5pmiGqHgDLx78 VpHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=M7z7DhJJ7GQp6CX5gwTveavGyOgqeiEEFMgrBGxLBZ8=; b=qEIR1ISw11oJLmvUvnouvsaQOa+FOLyLFJ1Wv0rQm7hbDxotVQpLCbJcnC7xxEgWDZ Lz4gjN4ZoPIWhZaIKzv3FZCfleu3Pd0JFvT3rB896R3gdFC6r1v0JriDzPmB6Tnvuh0c jSNgvpiiMixloy3P/JvHBDQmNIVaIYdfEsE+adpRWOFidXZra53LDhT+grE4SpHX38Kr cXYm7G53yxN8VBIIy8Onlci2Ob11JJMKUu8rMhGy0REDj6ymWJ95dtyufrBlgQSw1oCY S0hBcgIUDx8Kyp59FKqQnjNbphYgV4NHVfSd4yobJE+2g5itOf1iAew1IjMkuFzGG4xy ykhQ== X-Gm-Message-State: AO0yUKWLvQRVmxm5DNN8F3PSSPHJsHDd4XCbk/pHu9tDTNvWiwbLqOPX GGkuHCnSOV+BolCmoiUVGspCC5U9bPEhqQ== X-Google-Smtp-Source: AK7set8/q1DBAyzD2gxm/b23P4hXajELnAW83AEicocg/SCqMKehiAlBF9FRSqCCo2kQBEB9XFjy0MU/dkxFHQ== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a6b:4a13:0:b0:740:694b:54b2 with SMTP id w19-20020a6b4a13000000b00740694b54b2mr112310iob.21.1676346896619; Mon, 13 Feb 2023 19:54:56 -0800 (PST) Date: Tue, 14 Feb 2023 03:54:45 +0000 In-Reply-To: <20230214035445.1250139-1-talumbau@google.com> Mime-Version: 1.0 References: <20230214035445.1250139-1-talumbau@google.com> X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230214035445.1250139-2-talumbau@google.com> Subject: [PATCH mm-unstable v1 2/2] mm: multi-gen LRU: improve design doc From: "T.J. Alumbaugh" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mm@google.com, "T.J. Alumbaugh" X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6948C18000F X-Stat-Signature: fiy3s7wmnntytctt4q6ubqok8pqdfsge X-HE-Tag: 1676346897-950504 X-HE-Meta: U2FsdGVkX1/uqf9UbHKbHnKnx2oFzADF9UamxjoSPxlEsfPdCpwXYQoaL4ApCHD7NhS89HMKv6Mk7gUF7ZRHwKt3LYV5W0DyU8uCZV3aNiP85a++wLzQZwW/0JI7Cib59ToDjXB/8+BehGt5otdsezG/tshAmBN2W0mcMGNtoSh0sBzDoy0hi4uY5LjR+edzPexw30ad6Eea4HKK2fNeZ2IPWvSyayDyR78I0/81Gt5yfpVtSd8ktrY8kB1PW6QrPa0qwPo4iwhaXMiNRDsTxdeZDlE2v4lXqoyAHRJDPU8Rdm+A+s2sBIDtK+ChQBNYN3cSTaU36xvKcKHHYGPlSBWVoyZhIPBU4xGiZ2zc6LkY2zxJMJb+js2mpmUcCQQ0jNmNu0a3xbVbMIT0cBFB1xKUYC2FSvkKwb+41WWMjoyijUTgwhGgRaidzQLB0nViwFoxVmC/j0c6aReWGHnQ+L5OoDWTJqbv4j91LhEm4fX3G96SizR7AMsn/4VHadFot0ANotv1oIiyoxuwJP2f0b+5tJPMb46q3P1SyLCBQrRJmKCS4ku/l8fEQFR0h1JNpV53TffQa8WTG0TPIt23GAHy4oqiO9D1SAXQeohwYy8XaLbLgH13untI/zCnRePCPw51i9pLgFIYrikepRYPCqNad1cRhk72PvIoZJaPTPE1zKW2z9fU6LXgjYonvMgHWVEhXVC5tnwi11NIIVu7Ht0WF+81hwObvYrShjaEkKQ6pk4vcZRIdExApbW6BvBWTYhTY669p3IAm/hFD7xhKh19pwnPWKWWWATJc6DwV9oNRcfo+kP7jSZrtIWTgskaI/2JFzn8NyPSVCL/1ViW2pu5CSma0G+NtdU/KfWWOh3zaoy5p+FWQkM9cMntfzZy5Nz6E10xhonpR5sdvzcM+Wr6zeSGeY/CGpzMsAgpavGg42jaGfhUZF5mNNb7eNDPDIB271ltfOVn3Ouemx2 BXQ5uOUH RInKmLBeMj0iuANpWQrT1nFGR6CN8/CjrmpijmyFaQSHCVIk+n6TSrZtJaD6LAezogH/Jfcdt5AHqZcK3FXKuHZSCdykgJ3XHaZVQLwnzaYBed5t4GBowCHmwjbXUWk1WegUY2qW+NJ/KAhRX2p6ECGae3dFRunwAVSlO4eD1JmdbpAbh17XFwL7ZRSmwAymPwGGARP0u6Yd92WwW1FDkmlBKAFyrUGqX6UuLZjhVY6Zk/PHcW5Z8RrcfR8aCmB0GulscM7LY+4I/BUvcrfzPslCIlHHC/2/7fsNjeeB4nYqZvhlBaJeMGRT7DRZfhUXAWUJvWKojXa64Ve73BPzWQNDWGl2DsWpWB1Xh/XFJjaorEdu/1Je/qKFDNfHTlBeUZU8iPYt6RRO8dO9VBweJmzMCtufLMei8gu2TqRS+KCe+19kCzqxgYdpEp8IB61UAe4nVV2YM9xjNDOF+8ZwhUBmcAytX4FX/R5fzC5bhhfsQRNN6V2wJE4xoTIySqcctLSQiuNZvViF2pPEl9WaEozs40XP1Qhk7Yqt9lQ2xm+EDsgUc3WJGZxWKNEd54wjoQJvl+Ajh/t/cG9MJ6d3sUOUVwtNIVbLNn8+AkcDEN1LypSVins+ERK2AMNLpelDRzgJjvNU3RwaTfCI= 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: This patch improves the design doc. Specifically, 1. add a section for the per-memcg mm_struct list, and 2. add a section for the PID controller. Signed-off-by: T.J. Alumbaugh --- Documentation/mm/multigen_lru.rst | 44 +++++++++++++++++++++++++++---- mm/vmscan.c | 2 +- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Documentation/mm/multigen_lru.rst b/Documentation/mm/multigen_lru.rst index 5f1f6ecbb79b..52ed5092022f 100644 --- a/Documentation/mm/multigen_lru.rst +++ b/Documentation/mm/multigen_lru.rst @@ -103,7 +103,8 @@ moving across tiers only involves atomic operations on ``folio->flags`` and therefore has a negligible cost. A feedback loop modeled after the PID controller monitors refaults over all the tiers from anon and file types and decides which tiers from which types to -evict or protect. +evict or protect. The desired effect is to balance refault percentages +between anon and file types proportional to the swappiness level. There are two conceptually independent procedures: the aging and the eviction. They form a closed-loop system, i.e., the page reclaim. @@ -156,6 +157,27 @@ This time-based approach has the following advantages: and memory sizes. 2. It is more reliable because it is directly wired to the OOM killer. +``mm_struct`` list +------------------ +An ``mm_struct`` list is maintained for each memcg, and an +``mm_struct`` follows its owner task to the new memcg when this task +is migrated. + +A page table walker iterates ``lruvec_memcg()->mm_list`` and calls +``walk_page_range()`` with each ``mm_struct`` on this list to scan +PTEs. When multiple page table walkers iterate the same list, each of +them gets a unique ``mm_struct``, and therefore they can run in +parallel. + +Page table walkers ignore any misplaced pages, e.g., if an +``mm_struct`` was migrated, pages left in the previous memcg will be +ignored when the current memcg is under reclaim. Similarly, page table +walkers will ignore pages from nodes other than the one under reclaim. + +This infrastructure also tracks the usage of ``mm_struct`` between +context switches so that page table walkers can skip processes that +have been sleeping since the last iteration. + Rmap/PT walk feedback --------------------- Searching the rmap for PTEs mapping each page on an LRU list (to test @@ -170,7 +192,7 @@ promotes hot pages. If the scan was done cacheline efficiently, it adds the PMD entry pointing to the PTE table to the Bloom filter. This forms a feedback loop between the eviction and the aging. -Bloom Filters +Bloom filters ------------- Bloom filters are a space and memory efficient data structure for set membership test, i.e., test if an element is not in the set or may be @@ -186,6 +208,18 @@ is false positive, the cost is an additional scan of a range of PTEs, which may yield hot pages anyway. Parameters of the filter itself can control the false positive rate in the limit. +PID controller +-------------- +A feedback loop modeled after the Proportional-Integral-Derivative +(PID) controller monitors refaults over anon and file types and +decides which type to evict when both types are available from the +same generation. + +The PID controller uses generations rather than the wall clock as the +time domain because a CPU can scan pages at different rates under +varying memory pressure. It calculates a moving average for each new +generation to avoid being permanently locked in a suboptimal state. + Memcg LRU --------- An memcg LRU is a per-node LRU of memcgs. It is also an LRU of LRUs, @@ -223,9 +257,9 @@ parts: * Generations * Rmap walks -* Page table walks -* Bloom filters -* PID controller +* Page table walks via ``mm_struct`` list +* Bloom filters for rmap/PT walk feedback +* PID controller for refault feedback The aging and the eviction form a producer-consumer model; specifically, the latter drives the former by the sliding window over diff --git a/mm/vmscan.c b/mm/vmscan.c index 09c064accdb1..43e69dc8b4bd 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3604,7 +3604,7 @@ static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long max_seq) } /****************************************************************************** - * refault feedback loop + * PID controller ******************************************************************************/ /*