[PATCH 2/2] sched/preempt: Avoid updating for duplicate preempt mode

From: Song Shuai
Date: Fri Jan 12 2024 - 04:30:39 EST


When echoing the current preempt mode to /sys/kernel/debug/sched/preempt,
we don't have to update SC or SK in the sched_dynamic_update() function.

Stop it at the sched_dynamic_write() function.

Signed-off-by: Song Shuai <songshuaishuai@xxxxxxxxxxx>
---
kernel/sched/debug.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 4580a450700e..dafcfdfae23d 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -235,7 +235,8 @@ static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
if (mode < 0)
return mode;

- sched_dynamic_update(mode);
+ if (preempt_dynamic_mode != mode)
+ sched_dynamic_update(mode);

*ppos += cnt;

--
2.39.2