Skip to content

Commit 6080fb2

Browse files
Joel FernandesPeter Zijlstra
authored andcommitted
sched/debug: Fix updating of ppos on server write ops
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
1 parent 3cb3b27 commit 6080fb2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

kernel/sched/debug.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
339339
long cpu = (long) ((struct seq_file *) filp->private_data)->private;
340340
struct rq *rq = cpu_rq(cpu);
341341
u64 runtime, period;
342+
int retval = 0;
342343
size_t err;
343-
int retval;
344344
u64 value;
345345

346346
err = kstrtoull_from_user(ubuf, cnt, 10, &value);
@@ -374,15 +374,16 @@ static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubu
374374
dl_server_stop(&rq->fair_server);
375375

376376
retval = dl_server_apply_params(&rq->fair_server, runtime, period, 0);
377-
if (retval)
378-
cnt = retval;
379377

380378
if (!runtime)
381379
printk_deferred("Fair server disabled in CPU %d, system may crash due to starvation.\n",
382380
cpu_of(rq));
383381

384382
if (rq->cfs.h_nr_queued)
385383
dl_server_start(&rq->fair_server);
384+
385+
if (retval < 0)
386+
return retval;
386387
}
387388

388389
*ppos += cnt;

0 commit comments

Comments
 (0)