
From: GUO Zihua <guozihua@huawei.com> 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 9d2f717c1f7c..e853e2fe5d24 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -7830,6 +7830,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 b40100e16683..60b6e994b4f1 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 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. -- 2.25.1