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

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/sysfs-schemes: implement file for quota goal nid parameter

DAMOS_QUOTA_NODE_MEM_{USED,FREE}_BP DAMOS quota goal metrics require the
node id parameter. However, there is no DAMON user ABI for setting it.
Implement a DAMON sysfs file for that with name 'nid', under the quota
goal directory.

Link: https://lkml.kernel.org/r/20250420194030.75838-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Yunjeong Mun <yunjeong.mun@sk.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
0fbd5937 0e1c773b

+27
+27
mm/damon/sysfs-schemes.c
··· 936 936 enum damos_quota_goal_metric metric; 937 937 unsigned long target_value; 938 938 unsigned long current_value; 939 + int nid; 939 940 }; 940 941 941 942 /* This should match with enum damos_action */ ··· 1017 1016 return err ? err : count; 1018 1017 } 1019 1018 1019 + static ssize_t nid_show(struct kobject *kobj, 1020 + struct kobj_attribute *attr, char *buf) 1021 + { 1022 + struct damos_sysfs_quota_goal *goal = container_of(kobj, struct 1023 + damos_sysfs_quota_goal, kobj); 1024 + 1025 + /* todo: return error if the goal is not using nid */ 1026 + 1027 + return sysfs_emit(buf, "%d\n", goal->nid); 1028 + } 1029 + 1030 + static ssize_t nid_store(struct kobject *kobj, 1031 + struct kobj_attribute *attr, const char *buf, size_t count) 1032 + { 1033 + struct damos_sysfs_quota_goal *goal = container_of(kobj, struct 1034 + damos_sysfs_quota_goal, kobj); 1035 + int err = kstrtoint(buf, 0, &goal->nid); 1036 + 1037 + /* feed callback should check existence of this file and read value */ 1038 + return err ? err : count; 1039 + } 1040 + 1020 1041 static void damos_sysfs_quota_goal_release(struct kobject *kobj) 1021 1042 { 1022 1043 /* or, notify this release to the feed callback */ ··· 1054 1031 static struct kobj_attribute damos_sysfs_quota_goal_current_value_attr = 1055 1032 __ATTR_RW_MODE(current_value, 0600); 1056 1033 1034 + static struct kobj_attribute damos_sysfs_quota_goal_nid_attr = 1035 + __ATTR_RW_MODE(nid, 0600); 1036 + 1057 1037 static struct attribute *damos_sysfs_quota_goal_attrs[] = { 1058 1038 &damos_sysfs_quota_goal_target_metric_attr.attr, 1059 1039 &damos_sysfs_quota_goal_target_value_attr.attr, 1060 1040 &damos_sysfs_quota_goal_current_value_attr.attr, 1041 + &damos_sysfs_quota_goal_nid_attr.attr, 1061 1042 NULL, 1062 1043 }; 1063 1044 ATTRIBUTE_GROUPS(damos_sysfs_quota_goal);