Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100% CPU use when the computer is started #20

Closed
eleius opened this issue Mar 13, 2021 · 16 comments
Closed

100% CPU use when the computer is started #20

eleius opened this issue Mar 13, 2021 · 16 comments

Comments

@eleius
Copy link

eleius commented Mar 13, 2021

I've been using jitterentropy-rngd for a couple of years without issues.

Now, every time I start my laptop (kernel 5.11.6, gnome-shell 3.38.3) I notice the fans are always on (even before reaching the graphical/desktop stage) because the jitterentropy-rngd process is using 100% of the cpu.

If I kill the process the problem goes away, restarting it produces the same high cpu issue.

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 14, 2021 via email

@eleius
Copy link
Author

eleius commented Mar 14, 2021

Hi again, I tried with older kernels and the problem only appears in 5.11.3+ kernels.

Version:

jitterentropy rngd feeding entropy to input_pool of Linux RNG
Version jitterentropy-rngd 1.2.0
Reported numeric version number of jent library 3000100

running with -vvv produces an endless log like this:

jitterentropy-rngd - Verbose: 64 bytes written to /dev/random
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for select on /dev/random
jitterentropy-rngd - Debug: Injected 64 bytes with an entropy count of 32 bytes of entropy
jitterentropy-rngd - Verbose: 64 bytes written to /dev/random
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for select on /dev/random
jitterentropy-rngd - Debug: Injected 64 bytes with an entropy count of 32 bytes of entropy
jitterentropy-rngd - Verbose: 64 bytes written to /dev/random
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for select on /dev/random
jitterentropy-rngd - Debug: Injected 64 bytes with an entropy count of 32 bytes of entropy
...

Then:

sudo killall jitterentropy-rngd

cat /proc/sys/kernel/random/entropy_avail
34

A couple of seconds after moving mouse and using the desktop:

cat /proc/sys/kernel/random/entropy_avail
489

A couple of minutes later I restarted jitterentropy-rngd but cpu usage was normal. I used killall and checked again:

cat /proc/sys/kernel/random/entropy_avail
2472

Running with -vvv shows different a log:

jitterentropy-rngd - Debug: Injected 64 bytes with an entropy count of 32 bytes of entropy
jitterentropy-rngd - Verbose: 64 bytes written to /dev/random
jitterentropy-rngd - Debug: Install termination signal handler
jitterentropy-rngd - Debug: Install alarm signal handler
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for alarm on /proc/sys/kernel/random/entropy_avail
jitterentropy-rngd - Debug: Sufficient entropy 2791 available
jitterentropy-rngd - Debug: Install alarm signal handler
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for alarm on /proc/sys/kernel/random/entropy_avail
jitterentropy-rngd - Debug: Sufficient entropy 2836 available
jitterentropy-rngd - Debug: Install alarm signal handler
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for alarm on /proc/sys/kernel/random/entropy_avail
jitterentropy-rngd - Debug: Sufficient entropy 2888 available
jitterentropy-rngd - Debug: Install alarm signal handler
jitterentropy-rngd - Debug: Polling /dev/random
...

Tried booting from kernel 5.11.2:

normal cpu %

cat /proc/sys/kernel/random/entropy_avail
1746

sudo killall jitterentropy-rngd 

cat /proc/sys/kernel/random/entropy_avail
1916

Booting kernel 5.11.3:

process uses 100% cpu

cat /proc/sys/kernel/random/entropy_avail 
3

Booting kernel 5.11.4:

process uses 100% cpu

cat /proc/sys/kernel/random/entropy_avail 
3

Booting 5.11.2 again:

normal cpu %

cat /proc/sys/kernel/random/entropy_avail 
1349

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 14, 2021 via email

@eleius
Copy link
Author

eleius commented Mar 14, 2021

I removed the IF block (lines 272-278). It worked!

  1. boot 5.11.6: 100% cpu use
  2. /proc/sys/kernel/random/entropy_avail is 4
  3. sudo killall jitterentropy-rngd
  4. /proc/sys/kernel/random/entropy_avail is 3
  5. sudo /opt/custom-version/jitterentropy-rngd (the one without the ioctl line)
  6. cpu use is normal
  7. /proc/sys/kernel/random/entropy_avail is 378

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 14, 2021 via email

@eleius
Copy link
Author

eleius commented Mar 14, 2021

Great, thanks!

@eleius eleius closed this as completed Mar 14, 2021
@eleius
Copy link
Author

eleius commented Mar 14, 2021

Just to clarify: when you restart the rngd, you would get 100% CPU use if you use the version 1.2.0 rngd. If you remove the ioctl, you have a regular normal operation, i.e. the CPU use is back to normal.

Yes, 100% cpu use when starting with the regular rngd, normal cpu with the "patched" version.

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 15, 2021 via email

@eleius
Copy link
Author

eleius commented Mar 15, 2021

Cloned and run with latest kernel, still getting 100% cpu use.

before killing process:

cat /proc/sys/kernel/random/entropy_avail
197

after killing process:

cat /proc/sys/kernel/random/entropy_avail
225

restarting with -vvv shows:

jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for select on /dev/random
jitterentropy-rngd - Debug: Inject entropy into ChaCha20 DRNG
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 2 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 4 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Inject entropy into input_pool
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 2 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 4 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Verbose: 128 bytes written to /dev/random
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for select on /dev/random
jitterentropy-rngd - Debug: Inject entropy into ChaCha20 DRNG
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 2 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 4 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Inject entropy into input_pool
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 2 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 4 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Verbose: 128 bytes written to /dev/random
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for select on /dev/random
jitterentropy-rngd - Debug: Inject entropy into ChaCha20 DRNG
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 2 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 4 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Inject entropy into input_pool
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 2 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 4 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Verbose: 128 bytes written to /dev/random
jitterentropy-rngd - Debug: Polling /dev/random
jitterentropy-rngd - Verbose: Wakeup call for select on /dev/random
jitterentropy-rngd - Debug: Inject entropy into ChaCha20 DRNG
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 10 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 2 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 10 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Injected 4 bytes with an entropy count of 0 bytes of entropy
jitterentropy-rngd - Debug: Inject entropy into input_pool
...

@eleius eleius reopened this Mar 15, 2021
@smuellerDD
Copy link
Owner

smuellerDD commented Mar 15, 2021 via email

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 15, 2021 via email

@eleius
Copy link
Author

eleius commented Mar 15, 2021

Strange - let me get an 5.11.4. Ciao Stephan

I've been using 5.11.6 for the latest tests.

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 15, 2021 via email

@eleius
Copy link
Author

eleius commented Mar 15, 2021

I hope I have fixed the issue for good now. Can you please test? Thanks Stephan

Tested, CPU is back to normal.

entropy after boot using 1.2.0: 4
entropy after killing process and starting git version: 1039

So it is fixed :) Thanks!

@spaetz
Copy link

spaetz commented Mar 15, 2021

Just letting you know that I requested this commit to be taken into Debian testing (soon to be the next stable):
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=985302

P.S. And thanks for the extremly quick fix. Impressive!

@smuellerDD
Copy link
Owner

smuellerDD commented Mar 15, 2021 via email

@eleius eleius closed this as completed Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants