Re: [PATCH v2 20/23] sched/cache: Add user control to adjust the parameters of cache-aware scheduling

From: Chen, Yu C

Date: Tue Dec 16 2025 - 02:49:49 EST


On 12/11/2025 1:02 AM, Peter Zijlstra wrote:
On Wed, Dec 03, 2025 at 03:07:39PM -0800, Tim Chen wrote:

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 466ba8b7398c..95bf080bbbf0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2436,9 +2436,11 @@ extern void migrate_enable(void);
DEFINE_LOCK_GUARD_0(migrate, migrate_disable(), migrate_enable())
#ifdef CONFIG_SCHED_CACHE
+DECLARE_STATIC_KEY_FALSE(sched_cache_on);
+
static inline bool sched_cache_enabled(void)
{
- return false;
+ return static_branch_unlikely(&sched_cache_on);
}
#endif
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 02e16b70a790..cde324672103 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -169,6 +169,53 @@ static const struct file_operations sched_feat_fops = {
.release = single_release,
};
+#ifdef CONFIG_SCHED_CACHE
+#define SCHED_CACHE_CREATE_CONTROL(name, max) \
+static ssize_t sched_cache_write_##name(struct file *filp, \
+ const char __user *ubuf, \
+ size_t cnt, loff_t *ppos) \
+{ \
+ char buf[16]; \
+ unsigned int val; \
+ if (cnt > 15) \
+ cnt = 15; \
+ if (copy_from_user(&buf, ubuf, cnt)) \
+ return -EFAULT; \
+ buf[cnt] = '\0'; \


+ if (kstrtouint(buf, 10, &val)) \
+ return -EINVAL; \
+ if (val > (max)) \
+ return -EINVAL; \
+ llc_##name = val; \
+ if (!strcmp(#name, "enabled")) \
+ sched_cache_set(false); \

Oh gawd :-(

Please just write out all the various write methods and use
kstrtoul_from_user() and kstrtobool_from_user() where applicable.


OK, will do.

thanks,
Chenyu