I've just noticed something odd about the scheduling of processes with
varying 'nice' values (7.0-stable/amd64, GENERIC.MP): it appears that
processes with 'nice 20' are given more favorable scheduling than those
with 'nice 10', which is exactly the opposite of what I'd expect based
on the man page for setpriority(2), "lower priorities cause more favorable
scheduling" (and longstanding Unix experience).

In more detail:
Right now I have 5 CPU-bound processes running (all the same binary, but
with different command-line arguments and started from different working
directories), on hardware with 4 CPUs visible to OpenBSD (quad-core Intel
i7-8650U processor; hyperthreading is disabled both in the BIOS and by
default in OpenBSD).  Of those 5 processes, 3 are at 'nice 20', and the
other 2 are at 'nice 10'.  I expected the 2 'nice 10' processes to each
get more CPU time than the 3 'nice 20' processes, but 'top -S -i -s1'
shows exactly the opposite behavior: the 3 'nice 20' processes are each
getting MORE CPU time (about 100% of a CPU each) than the 2 'nice 1
' processes (about 50% of a CPU each):

load averages:  5.04,  4.99,  4.04               gold.bkis-orchard.net 18:02:38
176 processes: 4 running, 168 idle, 4 on processor             up 7 days, 17:40
CPU0:  0.0% user, 97.0% nice,  0.0% sys,  0.0% spin,  3.0% intr,  0.0% idle
CPU1:  1.0% user, 99.0% nice,  0.0% sys,  0.0% spin,  0.0% intr,  0.0% idle
CPU2:  0.0% user,  100% nice,  0.0% sys,  0.0% spin,  0.0% intr,  0.0% idle
CPU3:  1.0% user, 99.0% nice,  0.0% sys,  0.0% spin,  0.0% intr,  0.0% idle
Memory: Real: 5686M/13G act/tot Free: 1929M Cache: 6785M Swap: 0K/34G

  PID USERNAME PRI NICE  SIZE   RES STATE     WAIT      TIME    CPU COMMAND
95910 jonathan 104   20   39M   42M onproc/3  -        17:38 99.02% smp-O3
58006 jonathan 104   20   39M   42M run/2     -        42:45 98.97% smp-O3
63085 jonathan 104   20   39M   42M run/1     -        12:39 97.66% smp-O3
36985 jonathan  84   10   21M   24M onproc/0  -         5:57 49.66% smp-O3
95125 jonathan  84   10   21M   24M run/0     -        11:53 49.32% smp-O3
64031 _firefox  28    0  959M 1057M run/2     -        63:28  0.83% firefox-esr
77428 _firefox   2    0 1381M 1355M sleep/2   poll    179:14  0.10% firefox-esr

Am I missing something obvious?

--
-- "Jonathan Thornburg [remove color- to reply]" <jthorn4...@pink-gmail.com>
   on the west coast of Canada, eh?
   "There was of course no way of knowing whether you were being watched
    at any given moment.  How often, or on what system, the Thought Police
    plugged in on any individual wire was guesswork.  It was even conceivable
    that they watched everybody all the time."  -- George Orwell, "1984"

Reply via email to