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 path file under quota goal directory

Add a DAMOS sysfs file for specifying the cgroup of the interest for
DAMOS_QUOTA_NODE_MEMCG_USED_BP.

Link: https://lkml.kernel.org/r/20251017212706.183502-5-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
c41e253a b74a120b

+36 -2
+36 -2
mm/damon/sysfs-schemes.c
··· 999 999 unsigned long target_value; 1000 1000 unsigned long current_value; 1001 1001 int nid; 1002 + char *path; 1002 1003 }; 1003 1004 1004 1005 static struct damos_sysfs_quota_goal *damos_sysfs_quota_goal_alloc(void) ··· 1129 1128 return err ? err : count; 1130 1129 } 1131 1130 1131 + static ssize_t path_show(struct kobject *kobj, 1132 + struct kobj_attribute *attr, char *buf) 1133 + { 1134 + struct damos_sysfs_quota_goal *goal = container_of(kobj, 1135 + struct damos_sysfs_quota_goal, kobj); 1136 + 1137 + return sysfs_emit(buf, "%s\n", goal->path ? goal->path : ""); 1138 + } 1139 + 1140 + static ssize_t path_store(struct kobject *kobj, 1141 + struct kobj_attribute *attr, const char *buf, size_t count) 1142 + { 1143 + struct damos_sysfs_quota_goal *goal = container_of(kobj, 1144 + struct damos_sysfs_quota_goal, kobj); 1145 + char *path = kmalloc_array(size_add(count, 1), sizeof(*path), 1146 + GFP_KERNEL); 1147 + 1148 + if (!path) 1149 + return -ENOMEM; 1150 + 1151 + strscpy(path, buf, count + 1); 1152 + kfree(goal->path); 1153 + goal->path = path; 1154 + return count; 1155 + } 1156 + 1132 1157 static void damos_sysfs_quota_goal_release(struct kobject *kobj) 1133 1158 { 1134 - /* or, notify this release to the feed callback */ 1135 - kfree(container_of(kobj, struct damos_sysfs_quota_goal, kobj)); 1159 + struct damos_sysfs_quota_goal *goal = container_of(kobj, 1160 + struct damos_sysfs_quota_goal, kobj); 1161 + 1162 + kfree(goal->path); 1163 + kfree(goal); 1136 1164 } 1137 1165 1138 1166 static struct kobj_attribute damos_sysfs_quota_goal_target_metric_attr = ··· 1176 1146 static struct kobj_attribute damos_sysfs_quota_goal_nid_attr = 1177 1147 __ATTR_RW_MODE(nid, 0600); 1178 1148 1149 + static struct kobj_attribute damos_sysfs_quota_goal_path_attr = 1150 + __ATTR_RW_MODE(path, 0600); 1151 + 1179 1152 static struct attribute *damos_sysfs_quota_goal_attrs[] = { 1180 1153 &damos_sysfs_quota_goal_target_metric_attr.attr, 1181 1154 &damos_sysfs_quota_goal_target_value_attr.attr, 1182 1155 &damos_sysfs_quota_goal_current_value_attr.attr, 1183 1156 &damos_sysfs_quota_goal_nid_attr.attr, 1157 + &damos_sysfs_quota_goal_path_attr.attr, 1184 1158 NULL, 1185 1159 }; 1186 1160 ATTRIBUTE_GROUPS(damos_sysfs_quota_goal);