public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Theodore Dubois <tbodt@google.com>
Cc: linux-man@vger.kernel.org, mtk.manpages@gmail.com
Subject: Re: [PATCH] getpriority: Only getpriority translation the priority values
Date: Sat, 14 May 2022 16:20:17 +0200	[thread overview]
Message-ID: <1fb620af-88dc-b21b-9b2c-e45ba7035138@gmail.com> (raw)
In-Reply-To: <20220510220821.1481801-1-tbodt@google.com>

On 5/11/22 00:08, Theodore Dubois wrote:
> The translation is needed to avoid returning a negative number from a
> successful syscall, and this requirement doesn't apply to setpriority.
> See the implementation of getpriority in kernel/sys.c.

Confirmed.  See:

$ grepc -tf getpriority kernel/
./kernel/sys.c:274:
SYSCALL_DEFINE2(getpriority, int, which, int, who)
{
	...
			niceval = nice_to_rlimit(task_nice(p));
			if (niceval > retval)
				retval = niceval;
	...

	return retval;
}
$ grepc -tf setpriority kernel/
./kernel/sys.c:204:
SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
{
	...
	if (niceval < MIN_NICE)
		niceval = MIN_NICE;
	if (niceval > MAX_NICE)
		niceval = MAX_NICE;

	...
}
$ grepc -tm M.._NICE
./include/linux/sched/prio.h:5:
#define MAX_NICE	19


./include/linux/sched/prio.h:6:
#define MIN_NICE	-20
$ grepc -tf nice_to_rlimit
./include/linux/sched/prio.h:32:
static inline long nice_to_rlimit(long nice)
{
	return (MAX_NICE - nice + 1);
}


-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

  reply	other threads:[~2022-05-14 14:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 22:08 [PATCH] getpriority: Only getpriority translation the priority values Theodore Dubois
2022-05-14 14:20 ` Alejandro Colomar [this message]
2022-05-14 14:37 ` Alejandro Colomar
2022-05-14 15:00   ` Alejandro Colomar
2022-05-14 18:43   ` Martin Ågren
2022-05-14 21:18     ` Alejandro Colomar
2022-05-17 17:02     ` Theodore Dubois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1fb620af-88dc-b21b-9b2c-e45ba7035138@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=tbodt@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox