hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8K30G
--------------------------------
Add a config isolation for random bootup initialization optimization.
Signed-off-by: GUO Zihua guozihua@huawei.com --- arch/arm64/configs/openeuler_defconfig | 1 + arch/x86/configs/openeuler_defconfig | 1 + drivers/char/random.c | 4 ++++ init/Kconfig | 11 +++++++++++ 4 files changed, 17 insertions(+)
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index 8f1a4db8d49b..99dd1b89240e 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -7792,6 +7792,7 @@ CONFIG_LOCK_DEBUGGING_SUPPORT=y
# CONFIG_DEBUG_IRQFLAGS is not set CONFIG_STACKTRACE=y +CONFIG_RANDOM_BOOT_OPTIMIZATION=y # CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set # CONFIG_DEBUG_KOBJECT is not set
diff --git a/arch/x86/configs/openeuler_defconfig b/arch/x86/configs/openeuler_defconfig index 507d199ff598..c46f34c77643 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -8989,6 +8989,7 @@ CONFIG_LOCK_DEBUGGING_SUPPORT=y # CONFIG_NMI_CHECK_CPU is not set # CONFIG_DEBUG_IRQFLAGS is not set CONFIG_STACKTRACE=y +CONFIG_RANDOM_BOOT_OPTIMIZATION=y # CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set # CONFIG_DEBUG_KOBJECT is not set
diff --git a/drivers/char/random.c b/drivers/char/random.c index b9ae54c243a9..2f31586d4188 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1100,8 +1100,12 @@ void add_interrupt_randomness(int irq) if (new_count & MIX_INFLIGHT) return;
+#ifdef CONFIG_RANDOM_BOOT_OPTIMIZATION if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ) && crng_ready()) +#else + if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ)) +#endif return;
fast_pool->count |= MIX_INFLIGHT; diff --git a/init/Kconfig b/init/Kconfig index 6d35728b94b2..c8cd6af80337 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1984,3 +1984,14 @@ config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE # <asm/syscall_wrapper.h>. config ARCH_HAS_SYSCALL_WRAPPER def_bool n + +config RANDOM_BOOT_OPTIMIZATION + bool "Random initialization optimization during bootup" + default n + help + Enable optimization on random bootup initialization. It is tested + to provide an optimization of up to 60%. + + It works by disabling batching of interrupt randomness events + during boot time, allowing interrupt related entropy to flow in + at a higher rate.