Revert "ANDROID: sched: avoid placing RT threads on cores handling softirqs"

This reverts commit 3adfd8e344.  It causes
merge issues with 5.18-rc1 and has to be reverted for now.  If it is
still needed, it can be added back after 5.18-rc1.

Bug: 31501544
Bug: 168521633
Cc: John Dias <joaodias@google.com>
Cc: J. Avila <elavila@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I03d90db2c9169975740a1f0d3193e44f27006c31
This commit is contained in:
Greg Kroah-Hartman
2022-03-31 19:33:16 +02:00
parent 66330b896c
commit 65c99af98b
5 changed files with 8 additions and 98 deletions
-1
View File
@@ -30,7 +30,6 @@ CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_BPF=y
CONFIG_NAMESPACES=y
# CONFIG_PID_NS is not set
CONFIG_RT_SOFTINT_OPTIMIZATION=y
# CONFIG_RD_BZIP2 is not set
# CONFIG_RD_LZMA is not set
# CONFIG_RD_XZ is not set
-11
View File
@@ -1274,17 +1274,6 @@ config SCHED_AUTOGROUP
desktop applications. Task group autogeneration is currently based
upon task session.
config RT_SOFTINT_OPTIMIZATION
bool "Improve RT scheduling during long softint execution"
depends on ARM64
depends on SMP
default n
help
Enable an optimization which tries to avoid placing RT tasks on CPUs
occupied by nonpreemptible tasks, such as a long softint, or CPUs
which may soon block preemptions, such as a CPU running a ksoftirq
thread which handles slow softints.
config SYSFS_DEPRECATED
bool "Enable deprecated sysfs features to support old userspace tools"
depends on SYSFS
+2 -43
View File
@@ -65,29 +65,8 @@ static int convert_prio(int prio)
return cpupri;
}
#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
/**
* drop_nopreempt_cpus - remove likely nonpreemptible cpus from the mask
* @lowest_mask: mask with selected CPUs (non-NULL)
*/
static void
drop_nopreempt_cpus(struct cpumask *lowest_mask)
{
unsigned int cpu = cpumask_first(lowest_mask);
while (cpu < nr_cpu_ids) {
/* unlocked access */
struct task_struct *task = READ_ONCE(cpu_rq(cpu)->curr);
if (task_may_not_preempt(task, cpu)) {
cpumask_clear_cpu(cpu, lowest_mask);
}
cpu = cpumask_next(cpu, lowest_mask);
}
}
#endif
static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p,
struct cpumask *lowest_mask, int idx,
bool drop_nopreempts)
struct cpumask *lowest_mask, int idx)
{
struct cpupri_vec *vec = &cp->pri_to_cpu[idx];
int skip = 0;
@@ -124,11 +103,6 @@ static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p,
if (lowest_mask) {
cpumask_and(lowest_mask, &p->cpus_mask, vec->mask);
#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
if (drop_nopreempts)
drop_nopreempt_cpus(lowest_mask);
#endif
/*
* We have to ensure that we have at least one bit
* still set in the array, since the map could have
@@ -173,16 +147,12 @@ int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p,
{
int task_pri = convert_prio(p->prio);
int idx, cpu;
bool drop_nopreempts = task_pri <= MAX_RT_PRIO;
BUG_ON(task_pri >= CPUPRI_NR_PRIORITIES);
#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
retry:
#endif
for (idx = 0; idx < task_pri; idx++) {
if (!__cpupri_find(cp, p, lowest_mask, idx, drop_nopreempts))
if (!__cpupri_find(cp, p, lowest_mask, idx))
continue;
if (!lowest_mask || !fitness_fn)
@@ -204,17 +174,6 @@ retry:
return 1;
}
/*
* If we can't find any non-preemptible cpu's, retry so we can
* find the lowest priority target and avoid priority inversion.
*/
#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
if (drop_nopreempts) {
drop_nopreempts = false;
goto retry;
}
#endif
/*
* If we failed to find a fitting lowest_mask, kick off a new search
* but without taking into account any fitness criteria this time.
+6 -32
View File
@@ -1568,22 +1568,6 @@ static void yield_task_rt(struct rq *rq)
#ifdef CONFIG_SMP
static int find_lowest_rq(struct task_struct *task);
#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
/*
* Return whether the task on the given cpu is currently non-preemptible
* while handling a softirq or is likely to block preemptions soon because
* it is a ksoftirq thread.
*/
bool
task_may_not_preempt(struct task_struct *task, int cpu)
{
struct task_struct *cpu_ksoftirqd = per_cpu(ksoftirqd, cpu);
return (task_thread_info(task)->preempt_count & SOFTIRQ_MASK) ||
task == cpu_ksoftirqd;
}
EXPORT_SYMBOL_GPL(task_may_not_preempt);
#endif /* CONFIG_RT_SOFTINT_OPTIMIZATION */
static int
select_task_rq_rt(struct task_struct *p, int cpu, int flags)
{
@@ -1591,7 +1575,6 @@ select_task_rq_rt(struct task_struct *p, int cpu, int flags)
struct rq *rq;
bool test;
int target_cpu = -1;
bool may_not_preempt;
trace_android_rvh_select_task_rq_rt(p, cpu, flags & 0xF,
flags, &target_cpu);
@@ -1608,12 +1591,7 @@ select_task_rq_rt(struct task_struct *p, int cpu, int flags)
curr = READ_ONCE(rq->curr); /* unlocked access */
/*
* If the current task on @p's runqueue is a softirq task,
* it may run without preemption for a time that is
* ill-suited for a waiting RT task. Therefore, try to
* wake this RT task on another runqueue.
*
* Also, if the current task on @p's runqueue is an RT task, then
* If the current task on @p's runqueue is an RT task, then
* try to see if we can wake this RT task up on another
* runqueue. Otherwise simply start this RT task
* on its current runqueue.
@@ -1638,10 +1616,9 @@ select_task_rq_rt(struct task_struct *p, int cpu, int flags)
* requirement of the task - which is only important on heterogeneous
* systems like big.LITTLE.
*/
may_not_preempt = task_may_not_preempt(curr, cpu);
test = (curr && (may_not_preempt ||
(unlikely(rt_task(curr)) &&
(curr->nr_cpus_allowed < 2 || curr->prio <= p->prio))));
test = curr &&
unlikely(rt_task(curr)) &&
(curr->nr_cpus_allowed < 2 || curr->prio <= p->prio);
if (test || !rt_task_fits_capacity(p, cpu)) {
int target = find_lowest_rq(p);
@@ -1654,14 +1631,11 @@ select_task_rq_rt(struct task_struct *p, int cpu, int flags)
goto out_unlock;
/*
* If cpu is non-preemptible, prefer remote cpu
* even if it's running a higher-prio task.
* Otherwise: Don't bother moving it if the destination CPU is
* Don't bother moving it if the destination CPU is
* not running a lower priority task.
*/
if (target != -1 &&
(may_not_preempt ||
p->prio < cpu_rq(target)->rt.highest_prio.curr))
p->prio < cpu_rq(target)->rt.highest_prio.curr)
cpu = target;
}
-11
View File
@@ -3161,14 +3161,3 @@ extern int sched_dynamic_mode(const char *str);
extern void sched_dynamic_update(int mode);
#endif
/*
* task_may_not_preempt - check whether a task may not be preemptible soon
*/
#ifdef CONFIG_RT_SOFTINT_OPTIMIZATION
extern bool task_may_not_preempt(struct task_struct *task, int cpu);
#else
static inline bool task_may_not_preempt(struct task_struct *task, int cpu)
{
return false;
}
#endif /* CONFIG_RT_SOFTINT_OPTIMIZATION */