Skip to contentSkip to conversation

rng-tools: Add Arm aarch64 CPU specific configuration to address excessive CPU usage on startup

PATCH Superseded Xiangyu Chen 2 participants 3 messages Oct 31, 2022 – Nov 1, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rng-tools: Add Arm aarch64 CPU specific configuration to address excessive CPU usage on startup

With the default jitter options aarch64 CPU-based devices typically experience continuous high CPU utilisation for several minutes after rngd starts.

Accoring to the rng-tools issue #150[1] and comments[2],in order to address this, the following configuration changes have been made, those configurations also can be found on Alpine Linux[3]:

- reduce the number of threads used to 1 in total, rather than 1 per core.
- reduce the buffer size from 16535 to 4133 which reduces the time taken to fill the buffer (and so reduces the duration of CPU load).

[1] https://github.com/nhorman/rng-tools/issues/150
[2] https://github.com/nhorman/rng-tools/issues/150#issuecomment-953079212
[3] https://git.alpinelinux.org/aports/tree/main/rng-tools/rngd.confd-arm

---
 .../rng-tools/rng-tools/default.aarch64               | 11 +++++++++++
 meta/recipes-support/rng-tools/rng-tools_6.15.bb      |  5 +++++
 2 files changed, 16 insertions(+)
 create mode 100644 meta/recipes-support/rng-tools/rng-tools/default.aarch64
meta/recipes-support/rng-tools/rng-tools/default.aarch64 new file +11 -0
new file mode 100644
index 0000000000..5a2fbcc9ef
@@ -0,0 +1,11 @@
+# With the default jitter options Arm CPU-based devices typically experience
+# continuous high CPU utilisation for several minutes after rngd starts.
+# See https://gitlab.alpinelinux.org/alpine/aports/-/issues/13035 and
+# https://github.com/nhorman/rng-tools/issues/150
+# In order to address this the following configuration changes have been made:
+#
+#   - reduce the number of threads used to 1 in total, rather than 1 per core.
+#   - reduce the buffer size from 16535 to 4133 which reduces the time taken
+#     to fill the buffer (and so reduces the duration of CPU load).
+#
+EXTRA_ARGS="-r /dev/hwrng -O jitter:buffer_size:4133 -O jitter:refill_thresh:4133 -O jitter:thread_count:1"
meta/recipes-support/rng-tools/rng-tools_6.15.bb +5 -0
index 0696351903..e1f6b2ad77 100644
@@ -12,6 +12,7 @@ SRC_URI = "git://github.com/nhorman/rng-tools.git;branch=master;protocol=https \
            file://init \
            file://default \
            file://rngd.service \
+           file://default.aarch64 \
            "
 SRCREV = "381f69828b782afda574f259c1b7549f48f9bb77"
 
@@ -59,3 +60,7 @@ do_install:append() {
             ${D}${systemd_system_unitdir}/rngd.service
     fi
 }
+
+do_install:append:aarch64() {
+    install -Dm 0644 ${WORKDIR}/default.aarch64 ${D}${sysconfdir}/default/rng-tools
+}
Signature · 1 line
2.34.1
#1 lore raw
Quoted 53 lines · Xiangyu Chen

With the default jitter options aarch64 CPU-based devices typically experience continuous high CPU utilisation for several minutes after rngd starts.

Accoring to the rng-tools issue #150[1] and comments[2],in order to address this, the following configuration changes have been made, those configurations also can be found on Alpine Linux[3]:

- reduce the number of threads used to 1 in total, rather than 1 per core.
- reduce the buffer size from 16535 to 4133 which reduces the time taken to fill the buffer (and so reduces the duration of CPU load).

[1] https://github.com/nhorman/rng-tools/issues/150
[2] https://github.com/nhorman/rng-tools/issues/150#issuecomment-953079212
[3] https://git.alpinelinux.org/aports/tree/main/rng-tools/rngd.confd-arm

---
 .../rng-tools/rng-tools/default.aarch64               | 11 +++++++++++
 meta/recipes-support/rng-tools/rng-tools_6.15.bb      |  5 +++++
 2 files changed, 16 insertions(+)
 create mode 100644 meta/recipes-support/rng-tools/rng-tools/default.aarch64
meta/recipes-support/rng-tools/rng-tools/default.aarch64 new file +11 -0
new file mode 100644
index 0000000000..5a2fbcc9ef
@@ -0,0 +1,11 @@
+# With the default jitter options Arm CPU-based devices typically experience
+# continuous high CPU utilisation for several minutes after rngd starts.
+# See https://gitlab.alpinelinux.org/alpine/aports/-/issues/13035 and
+# https://github.com/nhorman/rng-tools/issues/150
+# In order to address this the following configuration changes have been made:
+#
+#   - reduce the number of threads used to 1 in total, rather than 1 per core.
+#   - reduce the buffer size from 16535 to 4133 which reduces the time taken
+#     to fill the buffer (and so reduces the duration of CPU load).
+#
+EXTRA_ARGS="-r /dev/hwrng -O jitter:buffer_size:4133 -O jitter:refill_thresh:4133 -O jitter:thread_count:1"
meta/recipes-support/rng-tools/rng-tools_6.15.bb +1 -0
index 0696351903..e1f6b2ad77 100644
@@ -12,6 +12,7 @@ SRC_URI = "git://github.com/nhorman/rng-tools.git;branch=master;protocol=https \
            file://init \
            file://default \
            file://rngd.service \
+           file://default.aarch64 \
            "
 SRCREV = "381f69828b782afda574f259c1b7549f48f9bb77"
 

meta/recipes-support/rng-tools/rng-tools_6.15.bb do_install:append() { · line 66

Quoted 7 lines
meta/recipes-support/rng-tools/rng-tools_6.15.bb +4 -0
@@ -59,3 +60,7 @@ do_install:append() {
             ${D}${systemd_system_unitdir}/rngd.service
     fi
 }
+
+do_install:append:aarch64() {
+    install -Dm 0644 ${WORKDIR}/default.aarch64 ${D}${sysconfdir}/default/rng-tools
+}

Perhaps drop the aarch64 specific default file inside a folder called aarch64 under meta/recipes-support/rng-tools/rng-tools
and we don't need any changes in recipe.

Quoted 12 lines

--
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#172290): https://lists.openembedded.org/g/openembedded-core/message/172290
Mute This Topic: https://lists.openembedded.org/mt/94680433/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 55 lines · Khem Raj

[Please note: This e-mail is from an EXTERNAL e-mail address]

Quoted 51 lines · Xiangyu Chen

With the default jitter options aarch64 CPU-based devices typically experience continuous high CPU utilisation for several minutes after rngd starts.

Accoring to the rng-tools issue #150[1] and comments[2],in order to address this, the following configuration changes have been made, those configurations also can be found on Alpine Linux[3]:

- reduce the number of threads used to 1 in total, rather than 1 per core.
- reduce the buffer size from 16535 to 4133 which reduces the time taken to fill the buffer (and so reduces the duration of CPU load).

[1] https://github.com/nhorman/rng-tools/issues/150
[2] https://github.com/nhorman/rng-tools/issues/150#issuecomment-953079212
[3] https://git.alpinelinux.org/aports/tree/main/rng-tools/rngd.confd-arm

---
  .../rng-tools/rng-tools/default.aarch64               | 11 +++++++++++
  meta/recipes-support/rng-tools/rng-tools_6.15.bb      |  5 +++++
  2 files changed, 16 insertions(+)

create mode 100644 meta/recipes-support/rng-tools/rng-tools/default.aarch64

meta/recipes-support/rng-tools/rng-tools/default.aarch64 new file +11 -0
new file mode 100644
index 0000000000..5a2fbcc9ef
@@ -0,0 +1,11 @@
+# With the default jitter options Arm CPU-based devices typically experience
+# continuous high CPU utilisation for several minutes after rngd starts.
+# See https://gitlab.alpinelinux.org/alpine/aports/-/issues/13035 and
+# https://github.com/nhorman/rng-tools/issues/150
+# In order to address this the following configuration changes have been made:
+#
+#   - reduce the number of threads used to 1 in total, rather than 1 per core.
+#   - reduce the buffer size from 16535 to 4133 which reduces the time taken
+#     to fill the buffer (and so reduces the duration of CPU load).
+#
+EXTRA_ARGS="-r /dev/hwrng -O jitter:buffer_size:4133 -O jitter:refill_thresh:4133 -O jitter:thread_count:1"
meta/recipes-support/rng-tools/rng-tools_6.15.bb +1 -0
index 0696351903..e1f6b2ad77 100644
@@ -12,6 +12,7 @@ SRC_URI = "git://github.com/nhorman/rng-tools.git;branch=master;protocol=https \
             file://init \
             file://default \
             file://rngd.service \
+           file://default.aarch64 \
             "
  SRCREV = "381f69828b782afda574f259c1b7549f48f9bb77"
 
Quoted 11 lines

meta/recipes-support/rng-tools/rng-tools_6.15.bb do_install:append() { · line 66

Quoted 8 lines
meta/recipes-support/rng-tools/rng-tools_6.15.bb +4 -0
@@ -59,3 +60,7 @@ do_install:append() {
              ${D}${systemd_system_unitdir}/rngd.service
      fi
  }
+
+do_install:append:aarch64() {
+    install -Dm 0644 ${WORKDIR}/default.aarch64 ${D}${sysconfdir}/default/rng-tools
+}

Perhaps drop the aarch64 specific default file inside a folder called aarch64 under meta/recipes-support/rng-tools/rng-tools
and we don't need any changes in recipe.

Thanks,  already sent the v2 patch.

https://lists.openembedded.org/g/openembedded-core/message/172349

Quoted 12 lines
Quoted 12 lines

--
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#172290): https://lists.openembedded.org/g/openembedded-core/message/172290
Mute This Topic: https://lists.openembedded.org/mt/94680433/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-