coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] nice: add -a arg to set absolute niceness


From: Kevin Mark
Subject: Re: [PATCH] nice: add -a arg to set absolute niceness
Date: Fri, 21 Aug 2020 18:43:08 -0700

On Fri, Aug 21, 2020 at 9:14 AM Pádraig Brady wrote:
> I'm not sure the new option is worth this simplification.

Thanks for taking a look. I agree that the small shell one-liner this
patch can replace is not particularly motivating, but I wanted to
include it to make it clear what feature this patch was adding. The
good news is that this patch should be strictly additive and I was not
able to find an instance where it introduced a backcompat issue.

My motivation for this patch originates from the need to set a
specific/absolute niceness value in an environment where the shell
alternative I mentioned is unavailable. I'm using SDDM to launch Xorg,
and I'd like for Xorg to be launched with a niceness of -4 regardless
of SDDM's niceness, which should be 0 but I don't want to rely on
that. SDDM, via sddm.conf, allows me to configure the path to the Xorg
binary and its arguments, but in this configuration file I do not have
any mechanism to use shell logic. I can only provide a hardcoded
string to a binary. This patch allows me to set the following in my
SDDM config:

[X11]
ServerPath=/usr/local/bin/nice
ServerArguments=-a -4 /usr/bin/Xorg -nolisten tcp

to launch Xorg at -4 niceness. The alternatives I considered were to
either submit a patch to SDDM to allow for a configurable niceness
value or have a scheduled task which looks for the Xorg running
process and runs renice. The former is reasonable but with this patch
I can solve an entire class of issues instead of just one specific to
SDDM. And the latter feels like more of a hack than a real solution.

I'm not very committed to the terminology here. "Absolute" makes sense
in the context of the other relative option, but it's not very
descriptive. If I can improve that please let me know. I could also
try and undo some of the refactors I made in this patch (duplicate
code instead of pulling out functions) but I felt this hurt
readability and maintainability for very little benefit.

> BTW I notice renice from util-linux takes an absolute value
> as an argument to -n, which is inconsistent with renice on FreeBSD
> (which supports both absolute and relative, using -n to specify
> a relative adjustment (consistent with nice)).

renice supporting both relative and absolute niceness values was
another motivating factor for this patch. It's not very obvious (to
users on a GNU/Linux system) that nice is from GNU coreutils and
renice is from util-linux, given the similarity of the names and
purpose. While it's impossible to make nice and renice behave
similarly without breaking changes, this patch at least gives us the
absolute adjustment functionality that is already available with the
renice tools from util-linux and FreeBSD.

Best,
Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]