]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched/debug: Fix updating of ppos on server write ops
authorJoel Fernandes <joelagnelf@nvidia.com>
Mon, 26 Jan 2026 09:59:00 +0000 (10:59 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 3 Feb 2026 11:04:16 +0000 (12:04 +0100)
Updating "ppos" on error conditions does not make much sense. The pattern
is to return the error code directly without modifying the position, or
modify the position on success and return the number of bytes written.

Since on success, the return value of apply is 0, there is no point in
modifying ppos either. Fix it by removing all this and just returning
error code or number of bytes written on success.

Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Juri Lelli <juri.lelli@redhat.com>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Acked-by: Tejun Heo <tj@kernel.org>
Tested-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/20260126100050.3854740-3-arighi@nvidia.com
kernel/sched/debug.c

index 929fdf09e8e9deb606174df6050eaecca252940f..ed9254da511613f9c5dba2e48f2ffae0acfe5938 100644 (file)
@@ -339,8 +339,8 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
        long cpu = (long) ((struct seq_file *) filp->private_data)->private;
        struct rq *rq = cpu_rq(cpu);
        u64 runtime, period;
+       int retval = 0;
        size_t err;
-       int retval;
        u64 value;
 
        err = kstrtoull_from_user(ubuf, cnt, 10, &value);
@@ -374,8 +374,6 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
                dl_server_stop(&rq->fair_server);
 
                retval = dl_server_apply_params(&rq->fair_server, runtime, period, 0);
-               if (retval)
-                       cnt = retval;
 
                if (!runtime)
                        printk_deferred("Fair server disabled in CPU %d, system may crash due to starvation.\n",
@@ -383,6 +381,9 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
 
                if (rq->cfs.h_nr_queued)
                        dl_server_start(&rq->fair_server);
+
+               if (retval < 0)
+                       return retval;
        }
 
        *ppos += cnt;