Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: multi-gen LRU: clean up sysfs code

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.

Link: https://lkml.kernel.org/r/20230214035445.1250139-1-talumbau@google.com
Signed-off-by: T.J. Alumbaugh <talumbau@google.com>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

T.J. Alumbaugh and committed by
Andrew Morton
9a52b2f3 d155df53

+10 -14
+1 -1
include/linux/mmzone.h
··· 1369 1369 1370 1370 #ifdef CONFIG_LRU_GEN 1371 1371 /* kswap mm walk data */ 1372 - struct lru_gen_mm_walk mm_walk; 1372 + struct lru_gen_mm_walk mm_walk; 1373 1373 /* lru_gen_folio list */ 1374 1374 struct lru_gen_memcg memcg_lru; 1375 1375 #endif
+9 -13
mm/vmscan.c
··· 5663 5663 * sysfs interface 5664 5664 ******************************************************************************/ 5665 5665 5666 - static ssize_t show_min_ttl(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 5666 + static ssize_t min_ttl_ms_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 5667 5667 { 5668 - return sprintf(buf, "%u\n", jiffies_to_msecs(READ_ONCE(lru_gen_min_ttl))); 5668 + return sysfs_emit(buf, "%u\n", jiffies_to_msecs(READ_ONCE(lru_gen_min_ttl))); 5669 5669 } 5670 5670 5671 5671 /* see Documentation/admin-guide/mm/multigen_lru.rst for details */ 5672 - static ssize_t store_min_ttl(struct kobject *kobj, struct kobj_attribute *attr, 5673 - const char *buf, size_t len) 5672 + static ssize_t min_ttl_ms_store(struct kobject *kobj, struct kobj_attribute *attr, 5673 + const char *buf, size_t len) 5674 5674 { 5675 5675 unsigned int msecs; 5676 5676 ··· 5682 5682 return len; 5683 5683 } 5684 5684 5685 - static struct kobj_attribute lru_gen_min_ttl_attr = __ATTR( 5686 - min_ttl_ms, 0644, show_min_ttl, store_min_ttl 5687 - ); 5685 + static struct kobj_attribute lru_gen_min_ttl_attr = __ATTR_RW(min_ttl_ms); 5688 5686 5689 - static ssize_t show_enabled(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 5687 + static ssize_t enabled_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) 5690 5688 { 5691 5689 unsigned int caps = 0; 5692 5690 ··· 5701 5703 } 5702 5704 5703 5705 /* see Documentation/admin-guide/mm/multigen_lru.rst for details */ 5704 - static ssize_t store_enabled(struct kobject *kobj, struct kobj_attribute *attr, 5706 + static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, 5705 5707 const char *buf, size_t len) 5706 5708 { 5707 5709 int i; ··· 5728 5730 return len; 5729 5731 } 5730 5732 5731 - static struct kobj_attribute lru_gen_enabled_attr = __ATTR( 5732 - enabled, 0644, show_enabled, store_enabled 5733 - ); 5733 + static struct kobj_attribute lru_gen_enabled_attr = __ATTR_RW(enabled); 5734 5734 5735 5735 static struct attribute *lru_gen_attrs[] = { 5736 5736 &lru_gen_min_ttl_attr.attr, ··· 5736 5740 NULL 5737 5741 }; 5738 5742 5739 - static struct attribute_group lru_gen_attr_group = { 5743 + static const struct attribute_group lru_gen_attr_group = { 5740 5744 .name = "lru_gen", 5741 5745 .attrs = lru_gen_attrs, 5742 5746 };