diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index ce5a7aeaeecacf47432477a6322c5b9ca2a35db5..304c8e33355529c1ee362beb9355586fc2427788 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -7833,6 +7833,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 b40100e166838208b2a77a09d011f190c52ceb53..60b6e994b4f1cbe23c9a1c41164577b2010cbe02 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -9012,6 +9012,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 b9ae54c243a92d7025a0dd347d1ab994dcd036a8..2f31586d4188fad15fbf18901a14da04339e30fd 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 6d35728b94b2b3b12bfb47c6fcea047dbf145be6..c8cd6af80337ebfbda1a55a7e5694f5b2fd78b5a 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1984,3 +1984,14 @@ config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE # . 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.