100% CPU usage in init if /dev/console is not available
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
upstart (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
When /dev/console is not available (for example when running as an OpenVZ guest), init consumes 100% time of one CPU core.
Here is a strace excerpt captured on the OpenVZ host :
...
waitid(P_ALL, 0, {}, WNOHANG|
clock_gettime(
select(5, [0 3 4], [], [4], NULL) = 1 (in [0])
read(0, "", 1) = 0
waitid(P_ALL, 0, {}, WNOHANG|
clock_gettime(
select(5, [0 3 4], [], [4], NULL) = 1 (in [0])
read(0, "", 1) = 0
waitid(P_ALL, 0, {}, WNOHANG|
clock_gettime(
select(5, [0 3 4], [], [4], NULL) = 1 (in [0])
read(0, "", 1) = 0
...
Here is what happens :
- in init's main function, system_
- nih_main_loop_init eventually get called, initializing its interrupt_pipe on file descriptors 0 and 1
- we end up calling system_
- in nih_main_loop, select is called on 0 (/dev/null instead of the pipe) which repeatedly appears to have changed
I'm attaching a small patch which fixes this.
Status changed to 'Confirmed' because the bug affects multiple users.