Skip to content

Commit 3a54466

Browse files
author
Frederic Weisbecker
committed
sched,arm64: Handle CPU isolation on last resort fallback rq selection
When a kthread or any other task has an affinity mask that is fully offline or unallowed, the scheduler reaffines the task to all possible CPUs as a last resort. This default decision doesn't mix up very well with nohz_full CPUs that are part of the possible cpumask but don't want to be disturbed by unbound kthreads or even detached pinned user tasks. Make the fallback affinity setting aware of nohz_full. Suggested-by: Michal Hocko <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 4a1567b commit 3a54466

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

arch/arm64/include/asm/cpufeature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ static inline bool supports_clearbhb(int scope)
671671
}
672672

673673
const struct cpumask *system_32bit_el0_cpumask(void);
674+
const struct cpumask *fallback_32bit_el0_cpumask(void);
674675
DECLARE_STATIC_KEY_FALSE(arm64_mismatched_32bit_el0);
675676

676677
static inline bool system_supports_32bit_el0(void)

arch/arm64/include/asm/mmu_context.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,26 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
271271
}
272272

273273
static inline const struct cpumask *
274-
task_cpu_possible_mask(struct task_struct *p)
274+
__task_cpu_possible_mask(struct task_struct *p, const struct cpumask *mask)
275275
{
276276
if (!static_branch_unlikely(&arm64_mismatched_32bit_el0))
277-
return cpu_possible_mask;
277+
return mask;
278278

279279
if (!is_compat_thread(task_thread_info(p)))
280-
return cpu_possible_mask;
280+
return mask;
281281

282282
return system_32bit_el0_cpumask();
283283
}
284+
285+
static inline const struct cpumask *
286+
task_cpu_possible_mask(struct task_struct *p)
287+
{
288+
return __task_cpu_possible_mask(p, cpu_possible_mask);
289+
}
284290
#define task_cpu_possible_mask task_cpu_possible_mask
285291

292+
const struct cpumask *task_cpu_fallback_mask(struct task_struct *p);
293+
286294
void verify_cpu_asid_bits(void);
287295
void post_ttbr_update_workaround(void);
288296

arch/arm64/kernel/cpufeature.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,11 @@ const struct cpumask *system_32bit_el0_cpumask(void)
16421642
return cpu_possible_mask;
16431643
}
16441644

1645+
const struct cpumask *task_cpu_fallback_mask(struct task_struct *p)
1646+
{
1647+
return __task_cpu_possible_mask(p, housekeeping_cpumask(HK_TYPE_TICK));
1648+
}
1649+
16451650
static int __init parse_32bit_el0_param(char *str)
16461651
{
16471652
allow_mismatched_32bit_el0 = true;

include/linux/mmu_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static inline void leave_mm(void) { }
2424
#ifndef task_cpu_possible_mask
2525
# define task_cpu_possible_mask(p) cpu_possible_mask
2626
# define task_cpu_possible(cpu, p) true
27+
# define task_cpu_fallback_mask(p) housekeeping_cpumask(HK_TYPE_TICK)
2728
#else
2829
# define task_cpu_possible(cpu, p) cpumask_test_cpu((cpu), task_cpu_possible_mask(p))
2930
#endif

kernel/sched/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3534,7 +3534,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p)
35343534
*
35353535
* More yuck to audit.
35363536
*/
3537-
do_set_cpus_allowed(p, task_cpu_possible_mask(p));
3537+
do_set_cpus_allowed(p, task_cpu_fallback_mask(p));
35383538
state = fail;
35393539
break;
35403540
case fail:

0 commit comments

Comments
 (0)