Skip to content

Commit e633a8a

Browse files
author
Fox Snowpatch
committed
1 parent 1ecdccb commit e633a8a

File tree

5 files changed

+135
-25
lines changed

5 files changed

+135
-25
lines changed

arch/s390/include/asm/topology.h

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ static inline int numa_node_id(void)
9999

100100
#endif /* CONFIG_NUMA */
101101

102+
#define arch_cpu_parked cpu_parked
103+
int cpu_parked(int cpu);
104+
102105
#include <asm-generic/topology.h>
103106

104107
#endif /* _ASM_S390_TOPOLOGY_H */

arch/s390/kernel/topology.c

+5
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ void store_topology(struct sysinfo_15_1_x *info)
299299
stsi(info, 15, 1, topology_mnest_limit());
300300
}
301301

302+
int cpu_parked(int cpu)
303+
{
304+
return smp_cpu_get_polarization(cpu) == POLARIZATION_VL;
305+
}
306+
302307
static void __arch_update_dedicated_flag(void *arg)
303308
{
304309
if (topology_cpu_dedicated(smp_processor_id()))

include/linux/sched/topology.h

+20
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,26 @@ unsigned long arch_scale_cpu_capacity(int cpu)
270270
}
271271
#endif
272272

273+
#ifndef arch_cpu_parked
274+
/**
275+
* arch_cpu_parked - Check if a given CPU is currently parked.
276+
*
277+
* A parked CPU cannot run any kind of workload since underlying
278+
* physical CPU should not be used at the moment .
279+
*
280+
* @cpu: the CPU in question.
281+
*
282+
* By default assume CPU is not parked
283+
*
284+
* Return: Parked state of CPU
285+
*/
286+
static __always_inline
287+
unsigned long arch_cpu_parked(int cpu)
288+
{
289+
return false;
290+
}
291+
#endif
292+
273293
#ifndef arch_scale_hw_pressure
274294
static __always_inline
275295
unsigned long arch_scale_hw_pressure(int cpu)

kernel/sched/core.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu)
24352435

24362436
/* Non kernel threads are not allowed during either online or offline. */
24372437
if (!(p->flags & PF_KTHREAD))
2438-
return cpu_active(cpu);
2438+
return !arch_cpu_parked(cpu) && cpu_active(cpu);
24392439

24402440
/* KTHREAD_IS_PER_CPU is always allowed. */
24412441
if (kthread_is_per_cpu(p))
@@ -2445,6 +2445,10 @@ static inline bool is_cpu_allowed(struct task_struct *p, int cpu)
24452445
if (cpu_dying(cpu))
24462446
return false;
24472447

2448+
/* CPU should be avoided at the moment */
2449+
if (arch_cpu_parked(cpu))
2450+
return false;
2451+
24482452
/* But are allowed during online. */
24492453
return cpu_online(cpu);
24502454
}
@@ -3922,6 +3926,10 @@ static inline bool ttwu_queue_cond(struct task_struct *p, int cpu)
39223926
if (task_on_scx(p))
39233927
return false;
39243928

3929+
/* The task should not be queued onto a parked CPU. */
3930+
if (arch_cpu_parked(cpu))
3931+
return false;
3932+
39253933
/*
39263934
* Do not complicate things with the async wake_list while the CPU is
39273935
* in hotplug state.

0 commit comments

Comments
 (0)