Core scheduling v6
Subsystems (3)
Re: [RFC PATCH 11/16] sched: migration changes for core scheduling(Internet mail)
In reply to benbjiang(蒋彪)Quoted 164 lines · benbjiang(蒋彪)
Hi,
Quoted 152 lines · Aubrey
Quoted 149 lines · benbjiang(蒋彪)
Hi,
Quoted 124 lines · Aubrey
Quoted 121 lines · benbjiang(蒋彪)
Hi,
Quoted 120 lines · Aubrey
Quoted 102 lines · benbjiang(蒋彪)
Hi,
Quoted 100 lines · Aubrey
Quoted 97 lines · benbjiang(蒋彪)
Hi,
Quoted 94 lines · Aubrey
Quoted 80 lines · benbjiang(蒋彪)
Hi, Aubrey,
Quoted 78 lines · Vineeth Remanan Pillai
From: Aubrey Li <[email protected]>
- Don't migrate if there is a cookie mismatch Load balance tries to move task from busiest CPU to the destination CPU. When core scheduling is enabled, if the task's cookie does not match with the destination CPU's core cookie, this task will be skipped by this CPU. This mitigates the forced idle time on the destination CPU.
- Select cookie matched idle CPU
In the fast path of task wakeup, select the first cookie matched idle CPU instead of the first idle CPU.- Find cookie matched idlest CPU
In the slow path of task wakeup, find the idlest CPU whose core cookie matches with task's cookie- Don't migrate task if cookie not match
For the NUMA load balance, don't migrate task to the CPU whose core cookie does not match with task's cookieSigned-off-by Aubrey Li <[email protected]>Signed-off-by Tim Chen <[email protected]>Signed-off-by Vineeth Remanan Pillai <[email protected]>---
kernel/sched/fair.c| 64 ++++++++++++++++++++++++++++++++++++++++----kernel/sched/sched.h| 29 ++++++++++++++++++++2 files changed, 88 insertions(+), 5 deletions(-)kernel/sched/fair.c +18
-3@@ -2051,6 +2051,15 @@ static void task_numa_find_cpu(struct task_numa_env *env,if (!cpumask_test_cpu (cpu, env->p->cpus_ptr))continue ; +#ifdef CONFIG_SCHED_CORE +/* +* Skip this cpu if source task's cookie does not match +* with CPU's core cookie. +*/ +if (!sched_core_cookie_match (cpu_rq (cpu), env->p)) +continue ; +#endif + env->dst_cpu = cpu;if (task_numa_compare (env, taskimp, groupimp, maymove))break ;@@ -5963,11 +5972,17 @@ find_idlest_group_cpu(struct sched_group *group, struct task_struct *p, int this/* Traverse only the allowed CPUs */ for_each_cpu_and (i,sched_group_span (group), p->cpus_ptr) { +struct rq *rq =cpu_rq (i); + +#ifdef CONFIG_SCHED_CORE +if (!sched_core_cookie_match (rq, p)) +continue ; +#endif +if (sched_idle_cpu (i))return i;if (available_idle_cpu (i)) { -struct rq *rq =cpu_rq (i);struct cpuidle_state *idle =idle_get_state (rq);if (idle && idle->exit_latency < min_exit_latency) {/* @@ -6224,8 +6239,18 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int tfor_each_cpu_wrap (cpu, cpus, target) {if (!--nr)return -1 ; -if (available_idle_cpu (cpu) ||sched_idle_cpu (cpu)) -break ; + +if (available_idle_cpu (cpu) ||sched_idle_cpu (cpu)) {Quoted 8 lines
kernel/sched/fair.c static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t · line 6250
Quoted 7 lines
kernel/sched/fair.c +7
-0+#ifdef CONFIG_SCHED_CORE +/* +* If Core Scheduling is enabled, select this cpu +* only if the process cookie matches core cookie. +*/ +if (sched_core_enabled (cpu_rq (cpu)) && + p->core_cookie ==cpu_rq (cpu)->core->core_cookie)Why not also add similar logic in
select_idle_smtto reduce forced-idle? :)We hit
select_idle_smtafter we scaned the entire LLC domain for idle cores and idle cpus and failed,so IMHO, an idle smt is probably a good choice under this scenario.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
AFAIC, selecting idle sibling with unmatched cookie will cause unnecessary fored-idle, unfairness and latency, compared to choosing *target* cpu.
Choosing target cpu could increase the runnable task number on the target runqueue, this could trigger
busiest->nr_running> 1 logic and makes the idle sibling trying to pull but not success(due to cookie not match). Putting task to the idle sibling is relatively stable IMHO.I’m afraid that *unsuccessful* pullings between smts would not result in unstableness, because the load-balance always do periodicly , and unsuccess means nothing happen.
unsuccess pulling means more unnecessary overhead in load balance.
Quoted 2 lines
On the contrary, unmatched sibling tasks running concurrently could bring forced-idle to each other repeatedly, Which is more unstable, and more costly when
pick_next_taskfor all siblings.Not worse than two tasks ping-pong on the same target run queue I guess, and better if
- task1(cookie A) is running on the target, and task2(cookie B) in the runqueue,
- task3(cookie B) comingQuoted 6 lines
Quoted 5 lines
Quoted 2 lines
If task3 chooses target's sibling, it could have a chance to run concurrently with task2. But if task3 chooses target, it will wait for next pulling luck of load balancer
That’s more interesting. :)
Distributing different cookie tasks onto different cpus(or cpusets) could be the *ideal stable status* we want, as I understood. Different cookie tasks running on sibling smts could hurt performance, and that should be avoided with best effort.We already tried to avoid when we scan idle cores and idle cpus in llc domain.
I’m afraid that’s not enough either, :)
1. Scanning Idle cpus is not a full scan, there is limit according to scan cost.
2. That's only trying at the *core/cpu* level, *SMT* level should be considered too.Quoted 5 lines
Quoted 4 lines
For above case, selecting idle sibling cpu can improve the concurrency indeed, but it decrease the imbalance for load-balancer. In that case, load-balancer could not notice the imbalance, and would do nothing to improve the unmatched situation. On the contrary, choosing the *target* cpu could enhance the imbalance, and load-balancer could try to pull unmatched task away,
Pulling away to where needs another bunch of elaboration.
Still with the SMT2+3tasks case,
if *idle sibling* chosen,
Smt1’s load = task1+task2, smt2’s load = task3. Task3 will run intermittently because of forced-idle, so smt2’s real load could low enough, that it could not be pulled away forever. That’s indeed a stable state, but with performance at a discount.Quoted 7 lines
Quoted 5 lines
If *target sibling* chose,
Smt1’s load = task1+task2+task3, smt2’s load=0. It’s a obvious imbalance, and load-balancer will pick a task to pull,
1. If task1(cookie A) picked, that’s done for good.
2. If task2(cookie B) or task3(cookie B) picked, that’s ok too, the rest task(cookie B) could be pulled away at next balance(maybe need to improve the pulling to tend to pull matched task more aggressively). And then, we may reach a more stable state *globally* without performance discount.I'm not sure what you mean pulled away,
I mean pulled away by other cpus, may be triggered by idle balance or periodic balance on other cpus.
Quoted 9 lines
Quoted 2 lines
- if you mean pulled away from this core, cookieA in idle sibling case can be pulled away too.
Yep, cookieA(task1) in idle sibling case could be pulled away, but cookieB(task3) on the smt2 could never get the chance being pulled away(unless being waken up).
If cookieA(task1) failed beingpulled(cookieB(task2) on smt1 may be pulled, 50% chance), cookieA(task1) and cookieB(task3) would reach the stable state with performance discount.
If you meant pulled away from this core, I didn't see how two cases are different either. For example, when task2(cookieB) runs on SMT1, task3 cookieb can be pulled to SMT2. and when task1(cookieA) switch onto SMT1, task2(cookieB) can be pulled away by other cpus, too.
Thanks,
-Aubrey
Re: [RFC PATCH 11/16] sched: migration changes for core scheduling(Internet mail)
Hi,
Quoted 176 lines · Aubrey Li
Quoted 164 lines · benbjiang(蒋彪)
Hi,
Quoted 152 lines · Aubrey
Quoted 149 lines · benbjiang(蒋彪)
Hi,
Quoted 124 lines · Aubrey
Quoted 121 lines · benbjiang(蒋彪)
Hi,
Quoted 120 lines · Aubrey
Quoted 102 lines · benbjiang(蒋彪)
Hi,
Quoted 100 lines · Aubrey
Quoted 97 lines · benbjiang(蒋彪)
Hi,
Quoted 94 lines · Aubrey
Quoted 80 lines · benbjiang(蒋彪)
Hi, Aubrey,
Quoted 78 lines · Vineeth Remanan Pillai
From: Aubrey Li <[email protected]>
- Don't migrate if there is a cookie mismatch
Load balance tries to move task from busiest CPU to the
destination CPU. When core scheduling is enabled, if the
task's cookie does not match with the destination CPU's
core cookie, this task will be skipped by this CPU. This
mitigates the forced idle time on the destination CPU.- Select cookie matched idle CPU
In the fast path of task wakeup, select the first cookie matched
idle CPU instead of the first idle CPU.- Find cookie matched idlest CPU
In the slow path of task wakeup, find the idlest CPU whose core
cookie matches with task's cookie- Don't migrate task if cookie not match
For the NUMA load balance, don't migrate task to the CPU whose
core cookie does not match with task's cookieSigned-off-by: Aubrey Li <[email protected]>
Signed-off-by: Tim Chen <[email protected]>
Signed-off-by: Vineeth Remanan Pillai <[email protected]>
---
kernel/sched/fair.c | 64 ++++++++++++++++++++++++++++++++++++++++----
kernel/sched/sched.h | 29 ++++++++++++++++++++
2 files changed, 88 insertions(+), 5 deletions(-)diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d16939766361..33dc4bf01817 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2051,6 +2051,15 @@ static void task_numa_find_cpu(struct task_numa_env *env,
if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
continue;+#ifdef CONFIG_SCHED_CORE
+ /*
+ * Skip this cpu if source task's cookie does not match
+ * with CPU's core cookie.
+ */
+ if (!sched_core_cookie_match(cpu_rq(cpu), env->p))
+ continue;
+#endif
+
env->dst_cpu = cpu;
if (task_numa_compare(env, taskimp, groupimp, maymove))
break;
@@ -5963,11 +5972,17 @@ find_idlest_group_cpu(struct sched_group *group, struct task_struct *p, int this/* Traverse only the allowed CPUs */
for_each_cpu_and(i, sched_group_span(group), p->cpus_ptr) {
+ struct rq *rq = cpu_rq(i);
+
+#ifdef CONFIG_SCHED_CORE
+ if (!sched_core_cookie_match(rq, p))
+ continue;
+#endif
+
if (sched_idle_cpu(i))
return i;if (available_idle_cpu(i)) {
- struct rq *rq = cpu_rq(i);
struct cpuidle_state *idle = idle_get_state(rq);
if (idle && idle->exit_latency < min_exit_latency) {
/*
@@ -6224,8 +6239,18 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
for_each_cpu_wrap(cpu, cpus, target) {
if (!--nr)
return -1;
- if (available_idle_cpu(cpu) || sched_idle_cpu(cpu))
- break;
+
+ if (available_idle_cpu(cpu) || sched_idle_cpu(cpu)) {Quoted 8 lines
Quoted 7 lines
+#ifdef CONFIG_SCHED_CORE
+ /*
+ * If Core Scheduling is enabled, select this cpu
+ * only if the process cookie matches core cookie.
+ */
+ if (sched_core_enabled(cpu_rq(cpu)) &&
+ p->core_cookie == cpu_rq(cpu)->core->core_cookie)Why not also add similar logic in
select_idle_smtto reduce forced-idle? :)We hit
select_idle_smtafter we scaned the entire LLC domain for idle cores and idle cpus and failed,so IMHO, an idle smt is probably a good choice under this scenario.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
AFAIC, selecting idle sibling with unmatched cookie will cause unnecessary fored-idle, unfairness and latency, compared to choosing *target* cpu.
Choosing target cpu could increase the runnable task number on the target runqueue, this could trigger
busiest->nr_running> 1 logic and makes the idle sibling trying to pull but not success(due to cookie not match). Putting task to the idle sibling is relatively stable IMHO.I’m afraid that *unsuccessful* pullings between smts would not result in unstableness, because the load-balance always do periodicly , and unsuccess means nothing happen.
unsuccess pulling means more unnecessary overhead in load balance.
Quoted 2 lines
On the contrary, unmatched sibling tasks running concurrently could bring forced-idle to each other repeatedly, Which is more unstable, and more costly when
pick_next_taskfor all siblings.Not worse than two tasks ping-pong on the same target run queue I guess, and better if
- task1(cookie A) is running on the target, and task2(cookie B) in the runqueue,
- task3(cookie B) comingQuoted 6 lines
Quoted 5 lines
Quoted 2 lines
If task3 chooses target's sibling, it could have a chance to run concurrently with task2. But if task3 chooses target, it will wait for next pulling luck of load balancer
That’s more interesting. :)
Distributing different cookie tasks onto different cpus(or cpusets) could be the *ideal stable status* we want, as I understood. Different cookie tasks running on sibling smts could hurt performance, and that should be avoided with best effort.We already tried to avoid when we scan idle cores and idle cpus in llc domain.
I’m afraid that’s not enough either, :)
1. Scanning Idle cpus is not a full scan, there is limit according to scan cost.
2. That's only trying at the *core/cpu* level, *SMT* level should be considered too.Quoted 5 lines
Quoted 4 lines
For above case, selecting idle sibling cpu can improve the concurrency indeed, but it decrease the imbalance for load-balancer. In that case, load-balancer could not notice the imbalance, and would do nothing to improve the unmatched situation. On the contrary, choosing the *target* cpu could enhance the imbalance, and load-balancer could try to pull unmatched task away,
Pulling away to where needs another bunch of elaboration.
Still with the SMT2+3tasks case,
if *idle sibling* chosen,
Smt1’s load = task1+task2, smt2’s load = task3. Task3 will run intermittently because of forced-idle, so smt2’s real load could low enough, that it could not be pulled away forever. That’s indeed a stable state, but with performance at a discount.Quoted 7 lines
Quoted 5 lines
If *target sibling* chose,
Smt1’s load = task1+task2+task3, smt2’s load=0. It’s a obvious imbalance, and load-balancer will pick a task to pull,
1. If task1(cookie A) picked, that’s done for good.
2. If task2(cookie B) or task3(cookie B) picked, that’s ok too, the rest task(cookie B) could be pulled away at next balance(maybe need to improve the pulling to tend to pull matched task more aggressively). And then, we may reach a more stable state *globally* without performance discount.I'm not sure what you mean pulled away,
I mean pulled away by other cpus, may be triggered by idle balance or periodic balance on other cpus.
Quoted 9 lines
Quoted 2 lines
- if you mean pulled away from this core, cookieA in idle sibling case can be pulled away too.
Yep, cookieA(task1) in idle sibling case could be pulled away, but cookieB(task3) on the smt2 could never get the chance being pulled away(unless being waken up).
If cookieA(task1) failed beingpulled(cookieB(task2) on smt1 may be pulled, 50% chance), cookieA(task1) and cookieB(task3) would reach the stable state with performance discount.
Quoted 4 lines
If you meant pulled away from this core, I didn't see how two cases are different either. For example, when task2(cookieB) runs on SMT1, task3 cookieb can be pulled to SMT2. and when task1(cookieA) switch onto SMT1, task2(cookieB) can be pulled away by other cpus, too.
That’s the case only if SMT2’s pulling happens when task2(cookieB) is running on SMT1, which depends on,
1. Smt2 not entering tickless or nohz_balancer_kick picks smt2 before other cpu’s pulling, may be unlikely. :)
2. Task1(cookieA) is not running on SMT1.
otherwise it would be the case I described above.
Besides, for other cases, like smt2+2task(CookieA+CookieB), picking *target* cpu instead of *idle sibling* could be more helpful to reach the global stable status(distribute different cookies onto different cores).
Thx.
Regard,
Jiang
Quoted 3 lines
Thanks,
-Aubrey
Re: [RFC PATCH 11/16] sched: migration changes for core scheduling(Internet mail)
Quoted 189 lines · benbjiang(蒋彪)
Hi,
Quoted 176 lines · Aubrey Li
Quoted 164 lines · benbjiang(蒋彪)
Hi,
Quoted 152 lines · Aubrey
Quoted 149 lines · benbjiang(蒋彪)
Hi,
Quoted 124 lines · Aubrey
Quoted 121 lines · benbjiang(蒋彪)
Hi,
Quoted 120 lines · Aubrey
Quoted 102 lines · benbjiang(蒋彪)
Hi,
Quoted 100 lines · Aubrey
Quoted 97 lines · benbjiang(蒋彪)
Hi,
Quoted 94 lines · Aubrey
Quoted 88 lines · benbjiang(蒋彪)
Hi, Aubrey,
On Jul 1, 2020, at 5:32 AM, Vineeth Remanan Pillai <[email protected]> wrote:
From: Aubrey Li <[email protected]>
- Don't migrate if there is a cookie mismatch
Load balance tries to move task from busiest CPU to the
destination CPU. When core scheduling is enabled, if the
task's cookie does not match with the destination CPU's
core cookie, this task will be skipped by this CPU. This
mitigates the forced idle time on the destination CPU.- Select cookie matched idle CPU
In the fast path of task wakeup, select the first cookie matched
idle CPU instead of the first idle CPU.- Find cookie matched idlest CPU
In the slow path of task wakeup, find the idlest CPU whose core
cookie matches with task's cookie- Don't migrate task if cookie not match
For the NUMA load balance, don't migrate task to the CPU whose
core cookie does not match with task's cookieSigned-off-by: Aubrey Li <[email protected]>
Signed-off-by: Tim Chen <[email protected]>
Signed-off-by: Vineeth Remanan Pillai <[email protected]>
---
kernel/sched/fair.c | 64 ++++++++++++++++++++++++++++++++++++++++----
kernel/sched/sched.h | 29 ++++++++++++++++++++
2 files changed, 88 insertions(+), 5 deletions(-)diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d16939766361..33dc4bf01817 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2051,6 +2051,15 @@ static void task_numa_find_cpu(struct task_numa_env *env,
if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
continue;+#ifdef CONFIG_SCHED_CORE
+ /*
+ * Skip this cpu if source task's cookie does not match
+ * with CPU's core cookie.
+ */
+ if (!sched_core_cookie_match(cpu_rq(cpu), env->p))
+ continue;
+#endif
+
env->dst_cpu = cpu;
if (task_numa_compare(env, taskimp, groupimp, maymove))
break;
@@ -5963,11 +5972,17 @@ find_idlest_group_cpu(struct sched_group *group, struct task_struct *p, int this/* Traverse only the allowed CPUs */
for_each_cpu_and(i, sched_group_span(group), p->cpus_ptr) {
+ struct rq *rq = cpu_rq(i);
+
+#ifdef CONFIG_SCHED_CORE
+ if (!sched_core_cookie_match(rq, p))
+ continue;
+#endif
+
if (sched_idle_cpu(i))
return i;if (available_idle_cpu(i)) {
- struct rq *rq = cpu_rq(i);
struct cpuidle_state *idle = idle_get_state(rq);
if (idle && idle->exit_latency < min_exit_latency) {
/*
@@ -6224,8 +6239,18 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
for_each_cpu_wrap(cpu, cpus, target) {
if (!--nr)
return -1;
- if (available_idle_cpu(cpu) || sched_idle_cpu(cpu))
- break;
+
+ if (available_idle_cpu(cpu) || sched_idle_cpu(cpu)) {
+#ifdef CONFIG_SCHED_CORE
+ /*
+ * If Core Scheduling is enabled, select this cpu
+ * only if the process cookie matches core cookie.
+ */
+ if (sched_core_enabled(cpu_rq(cpu)) &&
+ p->core_cookie == cpu_rq(cpu)->core->core_cookie)
Why not also add similar logic in select_idle_smt to reduce forced-idle? :)We hit
select_idle_smtafter we scaned the entire LLC domain for idle cores and idle cpus and failed,so IMHO, an idle smt is probably a good choice under this scenario.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
AFAIC, selecting idle sibling with unmatched cookie will cause unnecessary fored-idle, unfairness and latency, compared to choosing *target* cpu.
Choosing target cpu could increase the runnable task number on the target runqueue, this could trigger
busiest->nr_running> 1 logic and makes the idle sibling trying to pull but not success(due to cookie not match). Putting task to the idle sibling is relatively stable IMHO.I’m afraid that *unsuccessful* pullings between smts would not result in unstableness, because the load-balance always do periodicly , and unsuccess means nothing happen.
unsuccess pulling means more unnecessary overhead in load balance.
Quoted 2 lines
On the contrary, unmatched sibling tasks running concurrently could bring forced-idle to each other repeatedly, Which is more unstable, and more costly when
pick_next_taskfor all siblings.Not worse than two tasks ping-pong on the same target run queue I guess, and better if
- task1(cookie A) is running on the target, and task2(cookie B) in the runqueue,
- task3(cookie B) comingQuoted 6 lines
Quoted 5 lines
Quoted 2 lines
If task3 chooses target's sibling, it could have a chance to run concurrently with task2. But if task3 chooses target, it will wait for next pulling luck of load balancer
That’s more interesting. :)
Distributing different cookie tasks onto different cpus(or cpusets) could be the *ideal stable status* we want, as I understood. Different cookie tasks running on sibling smts could hurt performance, and that should be avoided with best effort.We already tried to avoid when we scan idle cores and idle cpus in llc domain.
I’m afraid that’s not enough either, :)
1. Scanning Idle cpus is not a full scan, there is limit according to scan cost.
2. That's only trying at the *core/cpu* level, *SMT* level should be considered too.Quoted 5 lines
Quoted 4 lines
For above case, selecting idle sibling cpu can improve the concurrency indeed, but it decrease the imbalance for load-balancer. In that case, load-balancer could not notice the imbalance, and would do nothing to improve the unmatched situation. On the contrary, choosing the *target* cpu could enhance the imbalance, and load-balancer could try to pull unmatched task away,
Pulling away to where needs another bunch of elaboration.
Still with the SMT2+3tasks case,
if *idle sibling* chosen,
Smt1’s load = task1+task2, smt2’s load = task3. Task3 will run intermittently because of forced-idle, so smt2’s real load could low enough, that it could not be pulled away forever. That’s indeed a stable state, but with performance at a discount.Quoted 7 lines
Quoted 5 lines
If *target sibling* chose,
Smt1’s load = task1+task2+task3, smt2’s load=0. It’s a obvious imbalance, and load-balancer will pick a task to pull,
1. If task1(cookie A) picked, that’s done for good.
2. If task2(cookie B) or task3(cookie B) picked, that’s ok too, the rest task(cookie B) could be pulled away at next balance(maybe need to improve the pulling to tend to pull matched task more aggressively). And then, we may reach a more stable state *globally* without performance discount.I'm not sure what you mean pulled away,
I mean pulled away by other cpus, may be triggered by idle balance or periodic balance on other cpus.
Quoted 9 lines
Quoted 2 lines
- if you mean pulled away from this core, cookieA in idle sibling case can be pulled away too.
Yep, cookieA(task1) in idle sibling case could be pulled away, but cookieB(task3) on the smt2 could never get the chance being pulled away(unless being waken up).
If cookieA(task1) failed beingpulled(cookieB(task2) on smt1 may be pulled, 50% chance), cookieA(task1) and cookieB(task3) would reach the stable state with performance discount.Quoted 4 lines
If you meant pulled away from this core, I didn't see how two cases are different either. For example, when task2(cookieB) runs on SMT1, task3 cookieb can be pulled to SMT2. and when task1(cookieA) switch onto SMT1, task2(cookieB) can be pulled away by other cpus, too.
That’s the case only if SMT2’s pulling happens when task2(cookieB) is running on SMT1, which depends on,
1. Smt2 not entering tickless ornohz_balancer_kickpicks smt2 before other cpu’s pulling, may be unlikely. :)
2. Task1(cookieA) is not running on SMT1.
otherwise it would be the case I described above.
Quoted 4 lines
Besides, for other cases, like smt2+2task(CookieA+CookieB), picking *target* cpu instead of *idle sibling* could be more helpful to reach the global stable status(distribute different cookies onto different cores).
If the task number of two cookies has a big difference, then distributing
different cookies onto different cores leads to a big imbalance, that state may be stable but not an optimal state, I guess that's why core run queue does not refuse different cookies onto its rb tree.
I think I understand your concern but IMHO I'm not convinced adding cookie match in idle SMT selection is a best choice, if you have some performance data of your workload, that will be very helpful to understand the case.
If distributing different cookies onto different cores is a hard requirement from your side, you are welcome to submit a patch to see others opinion.
Thanks,
-Aubrey
Re: [RFC PATCH 11/16] sched: migration changes for core scheduling(Internet mail)
Hi,
Quoted 192 lines · Aubrey
Quoted 189 lines · benbjiang(蒋彪)
Hi,
Quoted 176 lines · Aubrey Li
Quoted 164 lines · benbjiang(蒋彪)
Hi,
Quoted 152 lines · Aubrey
Quoted 149 lines · benbjiang(蒋彪)
Hi,
Quoted 124 lines · Aubrey
Quoted 121 lines · benbjiang(蒋彪)
Hi,
Quoted 120 lines · Aubrey
Quoted 102 lines · benbjiang(蒋彪)
Hi,
Quoted 100 lines · Aubrey
Quoted 97 lines · benbjiang(蒋彪)
Hi,
Quoted 94 lines · Aubrey
On 2020/7/22 16:54, benbjiang(蒋彪) wrote:
Hi, Aubrey,On Jul 1, 2020, at 5:32 AM, Vineeth Remanan Pillai <[email protected]> wrote:
From: Aubrey Li <[email protected]>
- Don't migrate if there is a cookie mismatch
Load balance tries to move task from busiest CPU to the
destination CPU. When core scheduling is enabled, if the
task's cookie does not match with the destination CPU's
core cookie, this task will be skipped by this CPU. This
mitigates the forced idle time on the destination CPU.- Select cookie matched idle CPU
In the fast path of task wakeup, select the first cookie matched
idle CPU instead of the first idle CPU.- Find cookie matched idlest CPU
In the slow path of task wakeup, find the idlest CPU whose core
cookie matches with task's cookie- Don't migrate task if cookie not match
For the NUMA load balance, don't migrate task to the CPU whose
core cookie does not match with task's cookieSigned-off-by: Aubrey Li <[email protected]>
Signed-off-by: Tim Chen <[email protected]>
Signed-off-by: Vineeth Remanan Pillai <[email protected]>
---
kernel/sched/fair.c | 64 ++++++++++++++++++++++++++++++++++++++++----
kernel/sched/sched.h | 29 ++++++++++++++++++++
2 files changed, 88 insertions(+), 5 deletions(-)diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d16939766361..33dc4bf01817 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2051,6 +2051,15 @@ static void task_numa_find_cpu(struct task_numa_env *env,
if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
continue;+#ifdef CONFIG_SCHED_CORE
+ /*
+ * Skip this cpu if source task's cookie does not match
+ * with CPU's core cookie.
+ */
+ if (!sched_core_cookie_match(cpu_rq(cpu), env->p))
+ continue;
+#endif
+
env->dst_cpu = cpu;
if (task_numa_compare(env, taskimp, groupimp, maymove))
break;
@@ -5963,11 +5972,17 @@ find_idlest_group_cpu(struct sched_group *group, struct task_struct *p, int this/* Traverse only the allowed CPUs */
for_each_cpu_and(i, sched_group_span(group), p->cpus_ptr) {
+ struct rq *rq = cpu_rq(i);
+
+#ifdef CONFIG_SCHED_CORE
+ if (!sched_core_cookie_match(rq, p))
+ continue;
+#endif
+
if (sched_idle_cpu(i))
return i;if (available_idle_cpu(i)) {
- struct rq *rq = cpu_rq(i);
struct cpuidle_state *idle = idle_get_state(rq);
if (idle && idle->exit_latency < min_exit_latency) {
/*
@@ -6224,8 +6239,18 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
for_each_cpu_wrap(cpu, cpus, target) {
if (!--nr)
return -1;
- if (available_idle_cpu(cpu) || sched_idle_cpu(cpu))
- break;
+
+ if (available_idle_cpu(cpu) || sched_idle_cpu(cpu)) {
+#ifdef CONFIG_SCHED_CORE
+ /*
+ * If Core Scheduling is enabled, select this cpu
+ * only if the process cookie matches core cookie.
+ */
+ if (sched_core_enabled(cpu_rq(cpu)) &&
+ p->core_cookie == cpu_rq(cpu)->core->core_cookie)
Why not also add similar logic in select_idle_smt to reduce forced-idle? :)
We hit select_idle_smt after we scaned the entire LLC domain for idle cores
and idle cpus and failed,so IMHO, an idle smt is probably a good choice under
this scenario.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
AFAIC, selecting idle sibling with unmatched cookie will cause unnecessary fored-idle, unfairness and latency, compared to choosing *target* cpu.
Choosing target cpu could increase the runnable task number on the target runqueue, this could trigger
busiest->nr_running> 1 logic and makes the idle sibling trying to pull but not success(due to cookie not match). Putting task to the idle sibling is relatively stable IMHO.I’m afraid that *unsuccessful* pullings between smts would not result in unstableness, because the load-balance always do periodicly , and unsuccess means nothing happen.
unsuccess pulling means more unnecessary overhead in load balance.
Quoted 2 lines
On the contrary, unmatched sibling tasks running concurrently could bring forced-idle to each other repeatedly, Which is more unstable, and more costly when
pick_next_taskfor all siblings.Not worse than two tasks ping-pong on the same target run queue I guess, and better if
- task1(cookie A) is running on the target, and task2(cookie B) in the runqueue,
- task3(cookie B) comingQuoted 6 lines
Quoted 5 lines
Quoted 2 lines
If task3 chooses target's sibling, it could have a chance to run concurrently with task2. But if task3 chooses target, it will wait for next pulling luck of load balancer
That’s more interesting. :)
Distributing different cookie tasks onto different cpus(or cpusets) could be the *ideal stable status* we want, as I understood. Different cookie tasks running on sibling smts could hurt performance, and that should be avoided with best effort.We already tried to avoid when we scan idle cores and idle cpus in llc domain.
I’m afraid that’s not enough either, :)
1. Scanning Idle cpus is not a full scan, there is limit according to scan cost.
2. That's only trying at the *core/cpu* level, *SMT* level should be considered too.Quoted 5 lines
Quoted 4 lines
For above case, selecting idle sibling cpu can improve the concurrency indeed, but it decrease the imbalance for load-balancer. In that case, load-balancer could not notice the imbalance, and would do nothing to improve the unmatched situation. On the contrary, choosing the *target* cpu could enhance the imbalance, and load-balancer could try to pull unmatched task away,
Pulling away to where needs another bunch of elaboration.
Still with the SMT2+3tasks case,
if *idle sibling* chosen,
Smt1’s load = task1+task2, smt2’s load = task3. Task3 will run intermittently because of forced-idle, so smt2’s real load could low enough, that it could not be pulled away forever. That’s indeed a stable state, but with performance at a discount.Quoted 7 lines
Quoted 5 lines
If *target sibling* chose,
Smt1’s load = task1+task2+task3, smt2’s load=0. It’s a obvious imbalance, and load-balancer will pick a task to pull,
1. If task1(cookie A) picked, that’s done for good.
2. If task2(cookie B) or task3(cookie B) picked, that’s ok too, the rest task(cookie B) could be pulled away at next balance(maybe need to improve the pulling to tend to pull matched task more aggressively). And then, we may reach a more stable state *globally* without performance discount.I'm not sure what you mean pulled away,
I mean pulled away by other cpus, may be triggered by idle balance or periodic balance on other cpus.
Quoted 9 lines
Quoted 2 lines
- if you mean pulled away from this core, cookieA in idle sibling case can be pulled away too.
Yep, cookieA(task1) in idle sibling case could be pulled away, but cookieB(task3) on the smt2 could never get the chance being pulled away(unless being waken up).
If cookieA(task1) failed beingpulled(cookieB(task2) on smt1 may be pulled, 50% chance), cookieA(task1) and cookieB(task3) would reach the stable state with performance discount.Quoted 4 lines
If you meant pulled away from this core, I didn't see how two cases are different either. For example, when task2(cookieB) runs on SMT1, task3 cookieb can be pulled to SMT2. and when task1(cookieA) switch onto SMT1, task2(cookieB) can be pulled away by other cpus, too.
That’s the case only if SMT2’s pulling happens when task2(cookieB) is running on SMT1, which depends on,
1. Smt2 not entering tickless ornohz_balancer_kickpicks smt2 before other cpu’s pulling, may be unlikely. :)
2. Task1(cookieA) is not running on SMT1.
otherwise it would be the case I described above.
Quoted 7 lines
Quoted 4 lines
Besides, for other cases, like smt2+2task(CookieA+CookieB), picking *target* cpu instead of *idle sibling* could be more helpful to reach the global stable status(distribute different cookies onto different cores).
If the task number of two cookies has a big difference, then distributingdifferent cookies onto different cores leads to a big imbalance, that state may be stable but not an optimal state, I guess that's why core run queue does not refuse different cookies onto its rb tree.
That’s the overcommit case, in which case distributing is not possible, and would fallback to the *local stable status*(as what current implementation does) too.
If the total task number is not overcommit, distributing could work. :)
Quoted 4 lines
I think I understand your concern but IMHO I'm not convinced adding cookie match in idle SMT selection is a best choice, if you have some performance data of your workload, that will be very helpful to understand the case.
Got it, I’ll try later.
Quoted 3 lines
If distributing different cookies onto different cores is a hard requirement from your side, you are welcome to submit a patch to see others opinion.
Thanks for your patience. If possible, could you please loop me in for future discussions about core-scheduling.
Thx.
Regard,
Jiang
Quoted 3 lines
Thanks,
-Aubrey
Re: [RFC PATCH 09/16] sched/fair: core wide cfs task priority comparison(Internet mail)
In reply to benbjiang(蒋彪)Quoted 10 lines · benbjiang(蒋彪)
Quoted 6 lines
+/*
+ * This function takes care of adjusting themin_vruntimeof siblings of
+ * a core during coresched enable/disable.
+ * This is called in stop machine context so no need to take the rq lock.Hi,
IMHO, it seems that stop machine context cannot guarantee race free. The param *cpu* maybe not *this_cpu*, rq lock should be taken even in stop machine context, and irq should be disabled too, to avoid potential races with other contexts.
In stop machine context, all CPUs except the active ones are spinning with irq disabled and in this invocation of stop_machine(), only one CPU is active so I don't think race is possible.
Re: [RFC PATCH 09/16] sched/fair: core wide cfs task priority comparison(Internet mail)
Quoted 8 lines · Aaron Lu
Quoted 6 lines · benbjiang(蒋彪)
Quoted 6 lines
+/*
+ * This function takes care of adjusting themin_vruntimeof siblings of
+ * a core during coresched enable/disable.
+ * This is called in stop machine context so no need to take the rq lock.
Quoted 8 lines
Quoted 4 lines
Hi,
IMHO, it seems that stop machine context cannot guarantee race free. The param *cpu* maybe not *this_cpu*, rq lock should be taken even in stop machine context, and irq should be disabled too, to avoid potential races with other contexts.
In stop machine context, all CPUs except the active ones are spinning with irq disabled and in this invocation of
stop_machine(), only one CPU is active so I don't think race is possible.
You're right, stop_machine provides much more protection than stop_*_cpu. Thanks for the explanation.
Regards,
Jiang
Quoted 4 lines · Vineeth Pillai
Sixth iteration of the Core-Scheduling feature.
I am no longer with DigitalOcean. Kindly use this email address for all future responses.
Thanks,
Vineeth
Quoted 32 lines · Vineeth Remanan Pillai
Sixth iteration of the Core-Scheduling feature.
Core scheduling is a feature that allows only trusted tasks to run concurrently on cpus sharing compute resources (eg: hyperthreads on a core). The goal is to mitigate the core-level side-channel attacks without requiring to disable SMT (which has a significant impact on performance in some situations). Core scheduling (as of v6) mitigates user-space to user-space attacks and user to kernel attack when one of the siblings enters the kernel via interrupts. It is still possible to have a task attack the sibling thread when it enters the kernel via syscalls.
By default, the feature doesn't change any of the current scheduler behavior. The user decides which tasks can run simultaneously on the same core (for now by having them in the same tagged cgroup). When a tag is enabled in a cgroup and a task from that cgroup is running on a hardware thread, the scheduler ensures that only idle or trusted tasks run on the other sibling(s). Besides security concerns, this feature can also be beneficial for RT and performance applications where we want to control how tasks make use of SMT dynamically.
This iteration is mostly a cleanup of v5 except for a major feature of pausing sibling when a cpu enters kernel via nmi/irq/softirq. Also introducing documentation and includes minor crash fixes.
One major cleanup was removing the hotplug support and related code. The hotplug related crashes were not documented and the fixes piled up over time leading to complex code. We were not able to reproduce the crashes in the limited testing done. But if they are reroducable, we don't want to hide them. We should document them and design better fixes if any.
Quoted 15 lines
In terms of performance, the results in this release are similar to v5. On a x86 system with N hardware threads:
- if only N/2 hardware threads are busy, the performance is similar between baseline, corescheduling and nosmt
- if N hardware threads are busy with N different corescheduling groups, the impact of corescheduling is similar to nosmt
- if N hardware threads are busy and multiple active threads share the same corescheduling cookie, they gain a performance improvement over nosmt.
The specific performance impact depends on the workload, but for a really busy database 12-vcpu VM (1 coresched tag) running on a 36 hardware threads NUMA node with 96 mostly idle neighbor VMs (each in their own coresched tag), the performance drops by 54% with corescheduling and drops by 90% with nosmt.
We found uperf(in cgroup) throughput drops by ~50% with corescheduling.
The problem is, uperf triggered a lot of softirq and offloaded softirq service to *ksoftirqd* thread.
- default, ksoftirqd thread can run with uperf on the same core, we saw 100% CPU utilization.
- coresched enabled, ksoftirqd's core cookie is different from uperf, so they can't run concurrently on the same core, we saw ~15% forced idle.
I guess this kind of performance drop can be replicated by other similar (a lot of softirq activities) workloads.
Currently core scheduler picks cookie-match tasks for all SMT siblings, does it make sense we add a policy to allow cookie-compatible task running together? For example, if a task is trusted(set by admin), it can work with kernel thread. The difference from corescheduling disabled is that we still have user to user isolation.
Thanks,
-Aubrey
Hi Aubrey,
Quoted 60 lines · Aubrey
Quoted 32 lines · Vineeth Remanan Pillai
Sixth iteration of the Core-Scheduling feature.
Core scheduling is a feature that allows only trusted tasks to run concurrently on cpus sharing compute resources (eg: hyperthreads on a core). The goal is to mitigate the core-level side-channel attacks without requiring to disable SMT (which has a significant impact on performance in some situations). Core scheduling (as of v6) mitigates user-space to user-space attacks and user to kernel attack when one of the siblings enters the kernel via interrupts. It is still possible to have a task attack the sibling thread when it enters the kernel via syscalls.
By default, the feature doesn't change any of the current scheduler behavior. The user decides which tasks can run simultaneously on the same core (for now by having them in the same tagged cgroup). When a tag is enabled in a cgroup and a task from that cgroup is running on a hardware thread, the scheduler ensures that only idle or trusted tasks run on the other sibling(s). Besides security concerns, this feature can also be beneficial for RT and performance applications where we want to control how tasks make use of SMT dynamically.
This iteration is mostly a cleanup of v5 except for a major feature of pausing sibling when a cpu enters kernel via nmi/irq/softirq. Also introducing documentation and includes minor crash fixes.
One major cleanup was removing the hotplug support and related code. The hotplug related crashes were not documented and the fixes piled up over time leading to complex code. We were not able to reproduce the crashes in the limited testing done. But if they are reroducable, we don't want to hide them. We should document them and design better fixes if any.
Quoted 15 lines
In terms of performance, the results in this release are similar to v5. On a x86 system with N hardware threads:
- if only N/2 hardware threads are busy, the performance is similar between baseline, corescheduling and nosmt
- if N hardware threads are busy with N different corescheduling groups, the impact of corescheduling is similar to nosmt
- if N hardware threads are busy and multiple active threads share the same corescheduling cookie, they gain a performance improvement over nosmt.
The specific performance impact depends on the workload, but for a really busy database 12-vcpu VM (1 coresched tag) running on a 36 hardware threads NUMA node with 96 mostly idle neighbor VMs (each in their own coresched tag), the performance drops by 54% with corescheduling and drops by 90% with nosmt.We found uperf(in cgroup) throughput drops by ~50% with corescheduling.
The problem is, uperf triggered a lot of softirq and offloaded softirq service to *ksoftirqd* thread.
- default, ksoftirqd thread can run with uperf on the same core, we saw 100% CPU utilization.
- coresched enabled, ksoftirqd's core cookie is different from uperf, so they can't run concurrently on the same core, we saw ~15% forced idle.
Quoted 8 lines
I guess this kind of performance drop can be replicated by other similar (a lot of softirq activities) workloads.
Currently core scheduler picks cookie-match tasks for all SMT siblings, does it make sense we add a policy to allow cookie-compatible task running together? For example, if a task is trusted(set by admin), it can work with kernel thread. The difference from corescheduling disabled is that we still have user to user isolation.
In ChromeOS we are considering all cookie-0 tasks as trusted. Basically if you don't trust a task, then that is when you assign the task a tag. We do this for the sandboxed processes.
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Quoted 72 lines · Joel Fernandes
Hi Aubrey,
Quoted 60 lines · Aubrey
Quoted 32 lines · Vineeth Remanan Pillai
Sixth iteration of the Core-Scheduling feature.
Core scheduling is a feature that allows only trusted tasks to run concurrently on cpus sharing compute resources (eg: hyperthreads on a core). The goal is to mitigate the core-level side-channel attacks without requiring to disable SMT (which has a significant impact on performance in some situations). Core scheduling (as of v6) mitigates user-space to user-space attacks and user to kernel attack when one of the siblings enters the kernel via interrupts. It is still possible to have a task attack the sibling thread when it enters the kernel via syscalls.
By default, the feature doesn't change any of the current scheduler behavior. The user decides which tasks can run simultaneously on the same core (for now by having them in the same tagged cgroup). When a tag is enabled in a cgroup and a task from that cgroup is running on a hardware thread, the scheduler ensures that only idle or trusted tasks run on the other sibling(s). Besides security concerns, this feature can also be beneficial for RT and performance applications where we want to control how tasks make use of SMT dynamically.
This iteration is mostly a cleanup of v5 except for a major feature of pausing sibling when a cpu enters kernel via nmi/irq/softirq. Also introducing documentation and includes minor crash fixes.
One major cleanup was removing the hotplug support and related code. The hotplug related crashes were not documented and the fixes piled up over time leading to complex code. We were not able to reproduce the crashes in the limited testing done. But if they are reroducable, we don't want to hide them. We should document them and design better fixes if any.
Quoted 15 lines
In terms of performance, the results in this release are similar to v5. On a x86 system with N hardware threads:
- if only N/2 hardware threads are busy, the performance is similar between baseline, corescheduling and nosmt
- if N hardware threads are busy with N different corescheduling groups, the impact of corescheduling is similar to nosmt
- if N hardware threads are busy and multiple active threads share the same corescheduling cookie, they gain a performance improvement over nosmt.
The specific performance impact depends on the workload, but for a really busy database 12-vcpu VM (1 coresched tag) running on a 36 hardware threads NUMA node with 96 mostly idle neighbor VMs (each in their own coresched tag), the performance drops by 54% with corescheduling and drops by 90% with nosmt.We found uperf(in cgroup) throughput drops by ~50% with corescheduling.
The problem is, uperf triggered a lot of softirq and offloaded softirq service to *ksoftirqd* thread.
- default, ksoftirqd thread can run with uperf on the same core, we saw 100% CPU utilization.
- coresched enabled, ksoftirqd's core cookie is different from uperf, so they can't run concurrently on the same core, we saw ~15% forced idle.Quoted 8 lines
I guess this kind of performance drop can be replicated by other similar (a lot of softirq activities) workloads.
Currently core scheduler picks cookie-match tasks for all SMT siblings, does it make sense we add a policy to allow cookie-compatible task running together? For example, if a task is trusted(set by admin), it can work with kernel thread. The difference from corescheduling disabled is that we still have user to user isolation.
Quoted 3 lines
In ChromeOS we are considering all cookie-0 tasks as trusted. Basically if you don't trust a task, then that is when you assign the task a tag. We do this for the sandboxed processes.
I have a proposal of this, by changing cpu.tag to cpu.coresched_policy, something like the following:
+/*
+ * Core scheduling policy:
+ * - CORE_SCHED_DISABLED: core scheduling is disabled.
+ * - CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * - CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * - CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */
+enum coresched_policy {
+ CORE_SCHED_DISABLED,
+ CORE_SCHED_COOKIE_MATCH,
+ CORE_SCHED_COOKIE_TRUST,
+ CORE_SCHED_COOKIE_LONELY,
+};
We can set policy to CORE_COOKIE_TRUST of uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?
Quoted 2 lines
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
Thanks,
-Aubrey
Quoted 9 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Re: [RFC PATCH 00/16] Core scheduling v6(Internet mail)
Hi,
Quoted 82 lines · Aubrey
Quoted 72 lines · Joel Fernandes
Hi Aubrey,
Quoted 60 lines · Aubrey
Quoted 32 lines · Vineeth Remanan Pillai
Sixth iteration of the Core-Scheduling feature.
Core scheduling is a feature that allows only trusted tasks to run concurrently on cpus sharing compute resources (eg: hyperthreads on a core). The goal is to mitigate the core-level side-channel attacks without requiring to disable SMT (which has a significant impact on performance in some situations). Core scheduling (as of v6) mitigates user-space to user-space attacks and user to kernel attack when one of the siblings enters the kernel via interrupts. It is still possible to have a task attack the sibling thread when it enters the kernel via syscalls.
By default, the feature doesn't change any of the current scheduler behavior. The user decides which tasks can run simultaneously on the same core (for now by having them in the same tagged cgroup). When a tag is enabled in a cgroup and a task from that cgroup is running on a hardware thread, the scheduler ensures that only idle or trusted tasks run on the other sibling(s). Besides security concerns, this feature can also be beneficial for RT and performance applications where we want to control how tasks make use of SMT dynamically.
This iteration is mostly a cleanup of v5 except for a major feature of pausing sibling when a cpu enters kernel via nmi/irq/softirq. Also introducing documentation and includes minor crash fixes.
One major cleanup was removing the hotplug support and related code. The hotplug related crashes were not documented and the fixes piled up over time leading to complex code. We were not able to reproduce the crashes in the limited testing done. But if they are reroducable, we don't want to hide them. We should document them and design better fixes if any.
Quoted 15 lines
In terms of performance, the results in this release are similar to v5. On a x86 system with N hardware threads:
- if only N/2 hardware threads are busy, the performance is similar between baseline, corescheduling and nosmt
- if N hardware threads are busy with N different corescheduling groups, the impact of corescheduling is similar to nosmt
- if N hardware threads are busy and multiple active threads share the same corescheduling cookie, they gain a performance improvement over nosmt.
The specific performance impact depends on the workload, but for a really busy database 12-vcpu VM (1 coresched tag) running on a 36 hardware threads NUMA node with 96 mostly idle neighbor VMs (each in their own coresched tag), the performance drops by 54% with corescheduling and drops by 90% with nosmt.We found uperf(in cgroup) throughput drops by ~50% with corescheduling.
The problem is, uperf triggered a lot of softirq and offloaded softirq service to *ksoftirqd* thread.
- default, ksoftirqd thread can run with uperf on the same core, we saw 100% CPU utilization.
- coresched enabled, ksoftirqd's core cookie is different from uperf, so they can't run concurrently on the same core, we saw ~15% forced idle.Quoted 8 lines
I guess this kind of performance drop can be replicated by other similar (a lot of softirq activities) workloads.
Currently core scheduler picks cookie-match tasks for all SMT siblings, does it make sense we add a policy to allow cookie-compatible task running together? For example, if a task is trusted(set by admin), it can work with kernel thread. The difference from corescheduling disabled is that we still have user to user isolation.
Quoted 3 lines
In ChromeOS we are considering all cookie-0 tasks as trusted. Basically if you don't trust a task, then that is when you assign the task a tag. We do this for the sandboxed processes.
I have a proposal of this, by changing cpu.tag to cpu.coresched_policy, something like the following:
Quoted 7 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
How about other OS tasks(like systemd) except kernel thread? :)
Thx.
Regards,
Jiang
Quoted 30 lines
+ * -
CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Quoted 2 lines
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
Thanks,
-AubreyQuoted 8 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]
Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};
Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?
Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
5. Document everything clearly so the semantics are clear both to the developers of core scheduling and to system administrators.
Note that, with the concept of "system trusted cookie", we can also do optimizations like:
1. Disable STIBP when switching into trusted tasks.
2. Disable L1D flushing / verw stuff for L1TF/MDS issues, when switching into trusted tasks.
At least #1 seems to be biting enabling HT on ChromeOS right now, and one other engineer requested I do something like #2 already.
Once we get full-syscall isolation working, threads belonging to a process can also share a core so those can just share a core with the task-group leader.
Quoted 4 lines
Quoted 1 line
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
This is worrying for sure. :-(. We ought to debug/profile it more to see what is causing the overhead. Me/Vineeth added it as a topic for LPC as well.
Any other thoughts from others on this?
thanks,
- Joel
Quoted 9 lines
Quoted 8 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Thanks,
-Aubrey
Quoted 41 lines
5. Document everything clearly so the semantics are clear both to the developers of core scheduling and to system administrators.
Note that, with the concept of "system trusted cookie", we can also do optimizations like:
1. Disable STIBP when switching into trusted tasks.
2. Disable L1D flushing / verw stuff for L1TF/MDS issues, when switching into trusted tasks.At least #1 seems to be biting enabling HT on ChromeOS right now, and one other engineer requested I do something like #2 already.
Once we get full-syscall isolation working, threads belonging to a process can also share a core so those can just share a core with the task-group leader.
Quoted 4 lines
Quoted 1 line
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
This is worrying for sure. :-(. We ought to debug/profile it more to see what is causing the overhead. Me/Vineeth added it as a topic for LPC as well.
Any other thoughts from others on this?
thanks,
- Joel
Quoted 9 lines
Quoted 8 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).
Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup? Then it will have cookie 0 and be able to share core with kernel threads. About user-user isolation that you need, if you tag any "untrusted" threads by adding it to CGroup, then there will automatically isolated from uperf while allowing uperf to share CPU with kernel threads.
Please let me know your thoughts and thanks,
- Joel
Quoted 45 lines
Thanks,
-AubreyQuoted 41 lines
5. Document everything clearly so the semantics are clear both to the developers of core scheduling and to system administrators.
Note that, with the concept of "system trusted cookie", we can also do optimizations like:
1. Disable STIBP when switching into trusted tasks.
2. Disable L1D flushing / verw stuff for L1TF/MDS issues, when switching into trusted tasks.At least #1 seems to be biting enabling HT on ChromeOS right now, and one other engineer requested I do something like #2 already.
Once we get full-syscall isolation working, threads belonging to a process can also share a core so those can just share a core with the task-group leader.
Quoted 4 lines
Quoted 1 line
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
This is worrying for sure. :-(. We ought to debug/profile it more to see what is causing the overhead. Me/Vineeth added it as a topic for LPC as well.
Any other thoughts from others on this?
thanks,
- Joel
Quoted 9 lines
Quoted 8 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Quoted 60 lines · Joel Fernandes
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
Quoted 3 lines
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup?
I guess this is unacceptable for who runs their apps in container and vm.
Thanks,
-Aubrey
Quoted 55 lines
Then it will have cookie 0 and be able to
share core with kernel threads. About user-user isolation that you need, if you tag any "untrusted" threads by adding it to CGroup, then there will automatically isolated from uperf while allowing uperf to share CPU with kernel threads.Please let me know your thoughts and thanks,
- Joel
Quoted 45 lines
Thanks,
-AubreyQuoted 41 lines
5. Document everything clearly so the semantics are clear both to the developers of core scheduling and to system administrators.
Note that, with the concept of "system trusted cookie", we can also do optimizations like:
1. Disable STIBP when switching into trusted tasks.
2. Disable L1D flushing / verw stuff for L1TF/MDS issues, when switching into trusted tasks.At least #1 seems to be biting enabling HT on ChromeOS right now, and one other engineer requested I do something like #2 already.
Once we get full-syscall isolation working, threads belonging to a process can also share a core so those can just share a core with the task-group leader.
Quoted 4 lines
Quoted 1 line
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
This is worrying for sure. :-(. We ought to debug/profile it more to see what is causing the overhead. Me/Vineeth added it as a topic for LPC as well.
Any other thoughts from others on this?
thanks,
- Joel
Quoted 9 lines
Quoted 8 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Re: [RFC PATCH 00/16] Core scheduling v6(Internet mail)
Quoted 65 lines · Aubrey
Quoted 60 lines · Joel Fernandes
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
Quoted 5 lines
Quoted 3 lines
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup?
I guess this is unacceptable for who runs their apps in container and vm.
IMHO, just as Joel proposed,
1. Consider all cookie-0 task as trusted.
2. All kernel threads and idle task would have a cookie 0
In that way, all tasks with cookies(including uperf in a cgroup) could run concurrently with kernel threads.
That could be a good solution for the issue. :)
If with CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED enabled, maybe we should set ksoftirqd’s cookie to be cookie-0 to solve the issue.
Thx.
Regards,
Jiang
Quoted 61 lines
Thanks,
-AubreyQuoted 55 lines
Then it will have cookie 0 and be able to
share core with kernel threads. About user-user isolation that you need, if you tag any "untrusted" threads by adding it to CGroup, then there will automatically isolated from uperf while allowing uperf to share CPU with kernel threads.Please let me know your thoughts and thanks,
- Joel
Quoted 45 lines
Thanks,
-AubreyQuoted 41 lines
5. Document everything clearly so the semantics are clear both to the developers of core scheduling and to system administrators.
Note that, with the concept of "system trusted cookie", we can also do optimizations like:
1. Disable STIBP when switching into trusted tasks.
2. Disable L1D flushing / verw stuff for L1TF/MDS issues, when switching into trusted tasks.At least #1 seems to be biting enabling HT on ChromeOS right now, and one other engineer requested I do something like #2 already.
Once we get full-syscall isolation working, threads belonging to a process can also share a core so those can just share a core with the task-group leader.
Quoted 4 lines
Quoted 1 line
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
This is worrying for sure. :-(. We ought to debug/profile it more to see what is causing the overhead. Me/Vineeth added it as a topic for LPC as well.
Any other thoughts from others on this?
thanks,
- Joel
Quoted 9 lines
Quoted 8 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Re: [RFC PATCH 00/16] Core scheduling v6(Internet mail)
Quoted 69 lines · benbjiang(蒋彪)
Quoted 69 lines · Aubrey
Quoted 63 lines · Joel Fernandes
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup?
Quoted 7 lines
Quoted 1 line
I guess this is unacceptable for who runs their apps in container and vm.
IMHO, just as Joel proposed,
1. Consider all cookie-0 task as trusted.
2. All kernel threads and idle task would have a cookie 0
In that way, all tasks with cookies(including uperf in a cgroup) could run concurrently with kernel threads.
That could be a good solution for the issue. :)
From uperf point of review, it can trust cookie-0(I assume we still need some modifications to change cookie-match to cookie-compatible to allow ZERO and NONZERO run together).
But from kernel thread point of review, it can NOT trust uperf, unless we set uperf's cookie to 0.
Thanks,
-Aubrey
Re: [RFC PATCH 00/16] Core scheduling v6(Internet mail)
Quoted 82 lines · Aubrey
Quoted 69 lines · benbjiang(蒋彪)
Quoted 69 lines · Aubrey
Quoted 63 lines · Joel Fernandes
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup?
Quoted 7 lines
Quoted 1 line
I guess this is unacceptable for who runs their apps in container and vm.
IMHO, just as Joel proposed,
1. Consider all cookie-0 task as trusted.
2. All kernel threads and idle task would have a cookie 0
In that way, all tasks with cookies(including uperf in a cgroup) could run concurrently with kernel threads.
That could be a good solution for the issue. :)
Quoted 6 lines
From uperf point of review, it can trust cookie-0(I assume we still need some modifications to change cookie-match to cookie-compatible to allow ZERO and NONZERO run together).
But from kernel thread point of review, it can NOT trust uperf, unless we set uperf's cookie to 0.
That’s right. :)
Could we set the cookie of cgroup where uperf lies to 0?
Thx.
Regards,
Jiang
Quoted 4 lines
Thanks,
-Aubrey
Re: [RFC PATCH 00/16] Core scheduling v6(Internet mail)
Quoted 82 lines · benbjiang(蒋彪)
Quoted 82 lines · Aubrey
Quoted 76 lines · benbjiang(蒋彪)
Quoted 65 lines · Aubrey
Quoted 60 lines · Joel Fernandes
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
Quoted 5 lines
Quoted 3 lines
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup?
I guess this is unacceptable for who runs their apps in container and vm.
IMHO, just as Joel proposed,
1. Consider all cookie-0 task as trusted.
2. All kernel threads and idle task would have a cookie 0
In that way, all tasks with cookies(including uperf in a cgroup) could run concurrently with kernel threads.
That could be a good solution for the issue. :)
Quoted 9 lines
Quoted 6 lines
From uperf point of review, it can trust cookie-0(I assume we still need some modifications to change cookie-match to cookie-compatible to allow ZERO and NONZERO run together).
But from kernel thread point of review, it can NOT trust uperf, unless we set uperf's cookie to 0.
That’s right. :)
Could we set the cookie of cgroup where uperf lies to 0?
IMHO the disadvantage is that if there are two or more cgroups set cookie-0, then the user applications in these cgroups could run concurrently on a core, though all of them are set as trusted, we made a hole of user->user isolation.
Thanks,
-Aubrey
Re: [RFC PATCH 00/16] Core scheduling v6(Internet mail)
Hi,
Quoted 89 lines · Aubrey
Quoted 86 lines · benbjiang(蒋彪)
Quoted 86 lines · Aubrey
Quoted 69 lines · benbjiang(蒋彪)
Quoted 69 lines · Aubrey
Quoted 63 lines · Joel Fernandes
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup?
Quoted 7 lines
Quoted 1 line
I guess this is unacceptable for who runs their apps in container and vm.
IMHO, just as Joel proposed,
1. Consider all cookie-0 task as trusted.
2. All kernel threads and idle task would have a cookie 0
In that way, all tasks with cookies(including uperf in a cgroup) could run concurrently with kernel threads.
That could be a good solution for the issue. :)From uperf point of review, it can trust cookie-0(I assume we still need some modifications to change cookie-match to cookie-compatible to allow ZERO and NONZERO run together).
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
But from kernel thread point of review, it can NOT trust uperf, unless we set uperf's cookie to 0.
That’s right. :)
Could we set the cookie of cgroup where uperf lies to 0?IMHO the disadvantage is that if there are two or more cgroups set cookie-0, then the user applications in these cgroups could run concurrently on a core, though all of them are set as trusted, we made a hole of
user->userisolation.
For that case, how about,
- use a special cookie(cookie-trust) instead of cookie-0 for kernel thread
- implement cookie_partial_match() to match part of the cookie
- Cookie-normal(normal tasks use) could trust cookie-trust,
- tasks tend to be trusted by cookie-trust could use cookies including cookie-trust partially, while cookie-normal does not include cookie-trust.
- cookie-trust tasks use cookie_partial_match() to match cookie
- normal tasks use the standard cookie match(full match) interface to match cookie.
Just a sudden thought. :)
Thx.
Regards,
Jiang
Quoted 61 lines · Aubrey
Quoted 60 lines · Joel Fernandes
Quoted 45 lines · Aubrey
Hi Joel,
Quoted 42 lines · Joel Fernandes
Hi Aubrey,
Apologies for replying late as I was still looking into the details.
On Wed, Aug 05, 2020 at 11:57:20AM +0800, Li, Aubrey wrote:
[...]Quoted 17 lines
+/*
+ * Core scheduling policy:
+ * -CORE_SCHED_DISABLED: core scheduling is disabled.
+ * -CORE_COOKIE_MATCH: tasks with same cookie can run
+ * on the same core concurrently.
+ * -CORE_COOKIE_TRUST: trusted task can run with kernel thread on the same core concurrently.
+ * -CORE_COOKIE_LONELY: tasks with cookie can run only
+ * with idle thread on the same core.
+ */(quoted diff) +6
-0+enum coresched_policy { + CORE_SCHED_DISABLED, + CORE_SCHED_COOKIE_MATCH, + CORE_SCHED_COOKIE_TRUST, + CORE_SCHED_COOKIE_LONELY, +};Quoted 2 lines
We can set policy to
CORE_COOKIE_TRUSTof uperf cgroup and fix this kind of performance regression. Not sure if this sounds attractive?Instead of this, I think it can be something simpler IMHO:
1. Consider all cookie-0 task as trusted. (Even right now, if you apply the core-scheduling patchset, such tasks will share a core and sniff on each other. So let us not pretend that such tasks are not trusted).
2. All kernel threads and idle task would have a cookie 0 (so that will cover ksoftirqd reported in your original issue).
3. Add a config option (
CONFIG_SCHED_CORE_DEFAULT_TASKS_UNTRUSTED). Default enable it. Setting this option would tag all tasks that are forked from a cookie-0 task with their own cookie. Later on, such tasks can be added to a group. This cover's PeterZ's ask about having 'default untrusted'). (Users like ChromeOS that don't want to userspace system processes to be tagged can disable this option so such tasks will be cookie-0).Quoted 5 lines
Quoted 2 lines
4. Allow prctl/cgroup interfaces to create groups of tasks and override the above behaviors.
How does uperf in a cgroup work with ksoftirqd? Are you suggesting I set uperf's cookie to be cookie-0 via prctl?
Yes, but let me try to understand better. There are 2 problems here I think:
1. ksoftirqd getting idled when HT is turned on, because uperf is sharing a core with it: This should not be any worse than SMT OFF, because even SMT OFF would also reduce ksoftirqd's CPU time just core sched is doing. Sure core-scheduling adds some overhead with IPIs but such a huge drop of perf is strange. Peter any thoughts on that?
Quoted 5 lines
Quoted 3 lines
2. Interface: To solve the performance problem, you are saying you want uperf to share a core with ksoftirqd so that it is not forced into idle. Why not just keep uperf out of the cgroup?
I guess this is unacceptable for who runs their apps in container and vm.
I think let us forget about #2, that's just a workaround. #1 is probably what we should look into for your problem. Was talking to Vineeth earlier, is it possible that the fairness issues that Aaron and Peter are looking into is causing the performance problem here?
So like, if ksoftirqd being higher prio is making the vruntime delta between 2 CFS tasks sharing a core to be quite high, then it causes the core-wide min_vruntime to be high. Then if uperf gets enqueued, it will get starved by ksoftirqd and not able to run till ksoftirqd's vruntime catches up.
Other than that, the only other thing (AFAIK) is the IPI/scheduler overhead is giving uperf worse performance than SMT-off and we ought to reduce the overhead some how. Does a kernel perf profile show you any smoking guns?
thanks,
- Joel
Quoted 60 lines
Thanks,
-AubreyQuoted 55 lines
Then it will have cookie 0 and be able to
share core with kernel threads. About user-user isolation that you need, if you tag any "untrusted" threads by adding it to CGroup, then there will automatically isolated from uperf while allowing uperf to share CPU with kernel threads.Please let me know your thoughts and thanks,
- Joel
Quoted 45 lines
Thanks,
-AubreyQuoted 41 lines
5. Document everything clearly so the semantics are clear both to the developers of core scheduling and to system administrators.
Note that, with the concept of "system trusted cookie", we can also do optimizations like:
1. Disable STIBP when switching into trusted tasks.
2. Disable L1D flushing / verw stuff for L1TF/MDS issues, when switching into trusted tasks.At least #1 seems to be biting enabling HT on ChromeOS right now, and one other engineer requested I do something like #2 already.
Once we get full-syscall isolation working, threads belonging to a process can also share a core so those can just share a core with the task-group leader.
Quoted 4 lines
Quoted 1 line
Is the uperf throughput worse with SMT+core-scheduling versus no-SMT ?
This is a good question, from the data we measured by uperf, SMT+core-scheduling is 28.2% worse than no-SMT, :(
This is worrying for sure. :-(. We ought to debug/profile it more to see what is causing the overhead. Me/Vineeth added it as a topic for LPC as well.
Any other thoughts from others on this?
thanks,
- Joel
Quoted 9 lines
Quoted 8 lines
thanks,
- Joel
PS: I am planning to write a patch behind a CONFIG option that tags all processes (default untrusted) so everything gets a cookie which some folks said was how they wanted (have a whitelist instead of blacklist).
Hi Vineeth,
Quoted 47 lines · Vineeth Remanan Pillai
Sixth iteration of the Core-Scheduling feature.
Core scheduling is a feature that allows only trusted tasks to run concurrently on cpus sharing compute resources (eg: hyperthreads on a core). The goal is to mitigate the core-level side-channel attacks without requiring to disable SMT (which has a significant impact on performance in some situations). Core scheduling (as of v6) mitigates user-space to user-space attacks and user to kernel attack when one of the siblings enters the kernel via interrupts. It is still possible to have a task attack the sibling thread when it enters the kernel via syscalls.
By default, the feature doesn't change any of the current scheduler behavior. The user decides which tasks can run simultaneously on the same core (for now by having them in the same tagged cgroup). When a tag is enabled in a cgroup and a task from that cgroup is running on a hardware thread, the scheduler ensures that only idle or trusted tasks run on the other sibling(s). Besides security concerns, this feature can also be beneficial for RT and performance applications where we want to control how tasks make use of SMT dynamically.
This iteration is mostly a cleanup of v5 except for a major feature of pausing sibling when a cpu enters kernel via nmi/irq/softirq. Also introducing documentation and includes minor crash fixes.
One major cleanup was removing the hotplug support and related code. The hotplug related crashes were not documented and the fixes piled up over time leading to complex code. We were not able to reproduce the crashes in the limited testing done. But if they are reroducable, we don't want to hide them. We should document them and design better fixes if any.
In terms of performance, the results in this release are similar to v5. On a x86 system with N hardware threads:
- if only N/2 hardware threads are busy, the performance is similar between baseline, corescheduling and nosmt
- if N hardware threads are busy with N different corescheduling groups, the impact of corescheduling is similar to nosmt
- if N hardware threads are busy and multiple active threads share the same corescheduling cookie, they gain a performance improvement over nosmt.
The specific performance impact depends on the workload, but for a really busy database 12-vcpu VM (1 coresched tag) running on a 36 hardware threads NUMA node with 96 mostly idle neighbor VMs (each in their own coresched tag), the performance drops by 54% with corescheduling and drops by 90% with nosmt.
Quoted 2 lines
v6 is rebased on 5.7.6(a06eb423367e)
https://github.com/digitalocean/linux-coresched/tree/coresched/v6-v5.7.y
As discussed during Linux Plumbers, here is a small repo with test scripts and applications that I've used to look at core scheduling unfairness:
https://github.com/agraf/schedgaps
Please let me know if it's unclear how to use it or if you see issues in your environment.
Please also make sure to only run this on idle server class hardware. Notebooks will most definitely have too many uncontrollable sources of timing entropy to give sensible results.
Alex
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Hi Alex,
Quoted 7 lines
As discussed during Linux Plumbers, here is a small repo with test scripts and applications that I've used to look at core scheduling unfairness:
Thanks for sharing :).
Quoted 3 lines
Please let me know if it's unclear how to use it or if you see issues in your environment.
Will give it a try soon and let you know. Went through the README quickly and documentation is very clear.
This is really helpful and would be really useful in future testing as well.
Thanks,
Vineeth