Subject: kern/37245: sched_m2 is too unfair
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <yamt@mwd.biglobe.ne.jp>
List: netbsd-bugs
Date: 10/29/2007 03:15:01
>Number: 37245
>Category: kern
>Synopsis: sched_m2 is too unfair
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 29 03:15:01 +0000 2007
>Originator: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
>Release: NetBSD 4.99.34
>Organization:
>Environment:
>Description:
sched_m2 is too unfair for general uses.
see the following test program and an output of top.
there seems to be two problems, at least:
- cpu-hogging threads never moves between cpus unless
there are idle cpus.
- there are threads which get completely starved.
i guess they have never got run after fork and their sl_lrtime
are still 0.
--------------------------------------------
#include <unistd.h>
int
main()
{
int i;
for (i = 0; i < 40; i++) {
if (fork() == 0)
break;
}
for (;;)
;
}
--------------------------------------------
64 processes: 40 runnable, 22 sleeping, 2 on processor
CPU0 states: 100% user, 0.0% nice, 0.0% system, 0.0% interrupt, 0.0% idle
CPU1 states: 100% user, 0.0% nice, 0.0% system, 0.0% interrupt, 0.0% idle
Memory: 33M Inact, 7692K Wired, 5996K Exec, 11M File, 895M Free
Swap: 2000M Total, 2000M Free
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
6665 takashi 105 0 20K 624K RUN/0 0:24 48.62% 44.43% a.out
5059 takashi 105 0 20K 380K RUN/0 0:24 48.30% 44.14% a.out
5435 takashi 30 0 20K 380K RUN/1 0:02 4.01% 3.66% a.out
5439 takashi 30 0 20K 380K RUN/1 0:02 4.01% 3.66% a.out
6361 takashi 30 0 20K 380K RUN/1 0:02 4.01% 3.66% a.out
6786 takashi 30 0 20K 380K RUN/1 0:02 3.90% 3.56% a.out
5202 takashi 30 0 20K 380K RUN/1 0:02 3.90% 3.56% a.out
5248 takashi 30 0 20K 380K RUN/1 0:02 3.90% 3.56% a.out
6453 takashi 29 0 20K 380K RUN/1 0:02 3.79% 3.47% a.out
6455 takashi 29 0 20K 380K RUN/1 0:02 3.79% 3.47% a.out
5764 takashi 30 0 20K 380K RUN/1 0:02 3.69% 3.37% a.out
6739 takashi 29 0 20K 380K RUN/1 0:02 3.69% 3.37% a.out
6360 takashi 29 0 20K 380K RUN/1 0:02 3.69% 3.37% a.out
6451 takashi 29 0 20K 380K RUN/1 0:02 3.69% 3.37% a.out
6847 takashi 29 0 20K 380K RUN/1 0:02 3.69% 3.37% a.out
5309 takashi 29 0 20K 380K RUN/1 0:02 3.42% 3.12% a.out
4801 takashi 30 0 20K 380K RUN/1 0:02 2.56% 2.34% a.out
4932 takashi 30 0 20K 380K RUN/1 0:02 2.56% 2.34% a.out
6792 takashi 30 0 20K 380K CPU/1 0:02 2.51% 2.29% a.out
6794 takashi 29 0 20K 380K RUN/1 0:02 2.51% 2.29% a.out
5254 takashi 30 0 20K 380K RUN/1 0:01 2.51% 2.29% a.out
5301 takashi 31 0 20K 380K RUN/1 0:01 2.40% 2.20% a.out
6070 takashi 30 0 20K 380K RUN/1 0:02 2.35% 2.15% a.out
5130 takashi 29 0 20K 380K RUN/1 0:02 2.19% 2.00% a.out
10177 takashi 28 0 756K 1344K CPU/0 0:00 0.00% 0.00% top
6362 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6366 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
9002 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
8346 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6365 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
4902 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
4974 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
5939 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
4850 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
7127 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6364 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6613 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6611 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6363 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6609 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
6467 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
7977 takashi 48 0 20K 4K RUN/1 0:00 0.00% 0.00% a.out
>How-To-Repeat:
see above.
>Fix:
- make sched_enqueue initialize l_lrtime properly for new lwps.
- balance cpus periodically.
>Unformatted: