Re: [PATCH] getpriority: Only getpriority translation the priority values

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

 



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/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux