Commit f3b90091 authored by Xiongfeng Wang's avatar Xiongfeng Wang
Browse files

isolation: Check whether there exists a housekeeping CPU online

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9NR7Q
CVE: NA

--------------------------------

We need to make sure that the housekeeper, one of the housekeeping
CPUs, is online, as describe in the below Link. We add this check
after secondary CPUs online is finished.

Link: https://lore.kernel.org/all/20190504002733.GB19076@lenoir/


Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
parent d38265ed
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ extern bool housekeeping_enabled(enum hk_flags flags);
extern void housekeeping_affine(struct task_struct *t, enum hk_flags flags);
extern bool housekeeping_test_cpu(int cpu, enum hk_flags flags);
extern void __init housekeeping_init(void);
extern void check_housekeeping_cpu_online(void);

#else

@@ -48,6 +49,7 @@ static inline bool housekeeping_enabled(enum hk_flags flags)
static inline void housekeeping_affine(struct task_struct *t,
				       enum hk_flags flags) { }
static inline void housekeeping_init(void) { }
static inline void check_housekeeping_cpu_online(void) { }
#endif /* CONFIG_CPU_ISOLATION */

static inline bool housekeeping_cpu(int cpu, enum hk_flags flags)
+13 −0
Original line number Diff line number Diff line
@@ -218,3 +218,16 @@ static int __init enhanced_isolcpus_setup(char *str)
	return 0;
}
__setup("enhanced_isolcpus", enhanced_isolcpus_setup);

void check_housekeeping_cpu_online(void)
{
	if (!support_cpu0_nohz_full)
		return;
	if (!housekeeping_flags)
		return;
	if (!cpumask_intersects(housekeeping_mask, cpu_online_mask)) {
		pr_err("All the housekeeping CPUs are offline, please modify the kernel parameter !\n");
		/* BUG() here, otherwise we may BUG() in sched_init_smp(). */
		BUG();
	}
}
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/cpu.h>
#include <linux/sched.h>
#include <linux/sched/idle.h>
#include <linux/sched/isolation.h>
#include <linux/hypervisor.h>
#include <linux/sched/clock.h>
#include <linux/nmi.h>
@@ -884,6 +885,9 @@ void __init smp_init(void)

	/* Any cleanup work */
	smp_cpus_done(setup_max_cpus);

	/* Check whether there exists a housekeeping CPU online */
	check_housekeeping_cpu_online();
}

/*