Re: [PATCH] chrt: Make priority optional for policies that don't use it

Karel Zak <[email protected]>
Newsgroups org.kernel.vger.util-linux
Message-ID <4kuoetpvezrzurjsgbu37jngbu5qteqowcdvukhoh6jlz3rcso@jr2ofz4ddfwm>
On Mon, Jun 16, 2025 at 12:52:18AM +0530, Madadi Vineeth Reddy wrote:
> Currently, chrt requires a priority argument even for scheduling
> policies like SCHED_OTHER and SCHED_BATCH, which ignore it.
> 
> This change relaxes that requirement. Now, priority is only expected
> for SCHED_FIFO and SCHED_RR. For other policies, a default value of 0
> is set internally and no argument is required on the command line.
> 
> This simplifies usage when modifying runtime parameters like
> --sched-runtime for non-realtime tasks.
> 
> For example, to change the EEVDF tunable base_slice, one currently
> needs to run:
> chrt -v -o -T 1000000 -p 0 $PID
> 
> Passing '0' after -p is not intutive and not required as priority is
> not applicable to SCHED_OTHER tasks. Now with this patch, one can do:
> chrt -v -o -T 1000000 -p $PID
> 
> Passing '0' still works ensuring ABI doesn't break.

Looks good. It would be nice to update the man page and add a note  
that -p is not required since util-linux v2.42.

> +	bool policy_needs_priority = (ctl->policy == SCHED_FIFO || ctl->policy == SCHED_RR);

Nitpicking... can't we use a shorter name, for example "need_prio"? ;-)

    Karel

-- 
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.