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/0SPFRt4jG7K7XHmQ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OoZw9twT6TMm6MhWfFaRcHnL/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, };