axboe / fio

Flexible I/O Tester

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bogus warning: nice: max value out of range: 20 (19 max)

rfjakob opened this issue · comments

Please acknowledge the following before creating a ticket

Description of the bug:

Using --nice=-20 causes this bogus warning:

nice: max value out of range: 20 (19 max)

Running under strace shows that the value -20 is actually accepted despite the warning:

[pid 40039] setpriority(PRIO_PROCESS, 0, -20) = 0

Environment: Fedora 38

fio version: fio-3.36-6-gc11e2 (compiled from git right now, but same behavoir on fio-3.36 and with Fedora and Debian fio packages)

Reproduction steps

$ sudo ./fio --name=foo --filename=/tmp/fio.tmp --size=1M --nice=-20
nice: max value out of range: 20 (19 max)
foo: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1
fio-3.36-6-gc11e2
Starting 1 process
[...]
$ sudo ./fio --debug=parse --name=foo --filename=/tmp/fio.tmp --size=1M --nice=-20
fio: set debug option parse
parse    40053 dup options
parse    40053 handle_option=name, ptr=foo
parse    40053 __handle_option=name, type=OPT_STR_STORE, ptr=foo
parse    40053 handle_option=filename, ptr=/tmp/fio.tmp
parse    40053 __handle_option=filename, type=OPT_STR_STORE, ptr=/tmp/fio.tmp
parse    40053 handle_option=size, ptr=1M
parse    40053 __handle_option=size, type=OPT_STR_VAL_ZONE, ptr=1M
parse    40053   ret=0, out=1048576
parse    40053 handle_option=nice, ptr=-20
parse    40053 __handle_option=nice, type=OPT_INT, ptr=-20
parse    40053   ret=0, out=18446744073709551596
parse    40053 __handle_option=nice, type=OPT_INT, ptr=20
parse    40053   ret=0, out=20
nice: max value out of range: 20 (19 max)
foo: (g=0): rw=read, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=psync, iodepth=1
parse    40053 free options
fio-3.36-6-gc11e2
Starting 1 process
[...]

It appears that the bug is that --nice=-20 is ultimately parsed to be nice=20. This is because in parse.c:__handle_option() we parse FIO_OPT_ULL and FIO_OPT_INT in the same switch block.