Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/isolation: Fix housekeeping_mask memory leak

If "nohz_full=" or "isolcpus=nohz" are called with CONFIG_NO_HZ_FULL=n,
housekeeping_mask doesn't get freed despite it being unused if
housekeeping_setup() is called for the first time.

Check this scenario first to fix this, so that no useless allocation
is performed.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Juri Lelli <juri.lelli@redhat.com>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Phil Auld <pauld@redhat.com>
Link: https://lore.kernel.org/r/20220207155910.527133-8-frederic@kernel.org

authored by

Frederic Weisbecker and committed by
Peter Zijlstra
65e53f86 0cd3e59d

+10 -9
+10 -9
kernel/sched/isolation.c
··· 94 94 cpumask_var_t non_housekeeping_mask, housekeeping_staging; 95 95 int err = 0; 96 96 97 + if ((flags & HK_FLAG_TICK) && !(housekeeping_flags & HK_FLAG_TICK)) { 98 + if (!IS_ENABLED(CONFIG_NO_HZ_FULL)) { 99 + pr_warn("Housekeeping: nohz unsupported." 100 + " Build with CONFIG_NO_HZ_FULL\n"); 101 + return 0; 102 + } 103 + } 104 + 97 105 alloc_bootmem_cpumask_var(&non_housekeeping_mask); 98 106 if (cpulist_parse(str, non_housekeeping_mask) < 0) { 99 107 pr_warn("Housekeeping: nohz_full= or isolcpus= incorrect CPU range\n"); ··· 131 123 } 132 124 } 133 125 134 - if ((flags & HK_FLAG_TICK) && !(housekeeping_flags & HK_FLAG_TICK)) { 135 - if (IS_ENABLED(CONFIG_NO_HZ_FULL)) { 136 - tick_nohz_full_setup(non_housekeeping_mask); 137 - } else { 138 - pr_warn("Housekeeping: nohz unsupported." 139 - " Build with CONFIG_NO_HZ_FULL\n"); 140 - goto free_housekeeping_staging; 141 - } 142 - } 126 + if ((flags & HK_FLAG_TICK) && !(housekeeping_flags & HK_FLAG_TICK)) 127 + tick_nohz_full_setup(non_housekeeping_mask); 143 128 144 129 housekeeping_flags |= flags; 145 130 err = 1;