* [PATCH] sched: Move sched_entity::avg into separate cache line
@ 2015-12-08 20:23 Jiri Olsa
2015-12-08 20:33 ` Arnaldo Carvalho de Melo
2016-01-06 18:49 ` [tip:sched/core] sched/core: Move sched_entity:: avg " tip-bot for Jiri Olsa
0 siblings, 2 replies; 3+ messages in thread
From: Jiri Olsa @ 2015-12-08 20:23 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: lkml, Arnaldo Carvalho de Melo, Don Zickus, Joe Mario
From: root <root@hp-dl380gen9-01.khw.lab.eng.bos.redhat.com>
hi,
I tried Joe's and Don's c2c tool and it identified
a place with cache line contention. There're more
that poped up, this one was just too obvious ;-)
thanks
jirka
---
The sched_entity::avg collides with read-mostly sched_entity data.
The perf c2c tool showed many read HITM accesses across
many CPUs for sched_entity's cfs_rq and my_q, while having
at the same time tons of stores for avg.
After placing sched_entity::avg into separate cache line,
the perf bench sched pipe showed around 20 seconds speedup.
NOTE I cut out all perf events except for cycles and
instructions from following output.
Before:
$ perf stat -r 5 perf bench sched pipe -l 10000000
# Running 'sched/pipe' benchmark:
# Executed 10000000 pipe operations between two processes
Total time: 270.348 [sec]
27.034805 usecs/op
36989 ops/sec
...
245,537,074,035 cycles # 1.433 GHz
187,264,548,519 instructions # 0.77 insns per cycle
272.653840535 seconds time elapsed ( +- 1.31% )
After:
$ perf stat -r 5 perf bench sched pipe -l 10000000
# Running 'sched/pipe' benchmark:
# Executed 10000000 pipe operations between two processes
Total time: 251.076 [sec]
25.107678 usecs/op
39828 ops/sec
...
244,573,513,928 cycles # 1.572 GHz
187,409,641,157 instructions # 0.76 insns per cycle
251.679315188 seconds time elapsed ( +- 0.31% )
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
include/linux/sched.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3b0de68bce41..80cc1432e6e3 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1268,8 +1268,13 @@ struct sched_entity {
#endif
#ifdef CONFIG_SMP
- /* Per entity load average tracking */
- struct sched_avg avg;
+ /*
+ * Per entity load average tracking.
+ *
+ * Put into separate cache line so it does not
+ * collide with read-mostly values above.
+ */
+ struct sched_avg avg ____cacheline_aligned_in_smp;
#endif
};
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched: Move sched_entity::avg into separate cache line
2015-12-08 20:23 [PATCH] sched: Move sched_entity::avg into separate cache line Jiri Olsa
@ 2015-12-08 20:33 ` Arnaldo Carvalho de Melo
2016-01-06 18:49 ` [tip:sched/core] sched/core: Move sched_entity:: avg " tip-bot for Jiri Olsa
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-12-08 20:33 UTC (permalink / raw)
To: Jiri Olsa; +Cc: Ingo Molnar, Peter Zijlstra, lkml, Don Zickus, Joe Mario
Em Tue, Dec 08, 2015 at 09:23:59PM +0100, Jiri Olsa escreveu:
> From: root <root@hp-dl380gen9-01.khw.lab.eng.bos.redhat.com>
>
> hi,
> I tried Joe's and Don's c2c tool and it identified
> a place with cache line contention. There're more
> that poped up, this one was just too obvious ;-)
Would be interesting to see output from that tool and how you have
interpreted it to be for that specific data structure.
- Arnaldo
> thanks
> jirka
>
>
> ---
> The sched_entity::avg collides with read-mostly sched_entity data.
>
> The perf c2c tool showed many read HITM accesses across
> many CPUs for sched_entity's cfs_rq and my_q, while having
> at the same time tons of stores for avg.
>
> After placing sched_entity::avg into separate cache line,
> the perf bench sched pipe showed around 20 seconds speedup.
>
> NOTE I cut out all perf events except for cycles and
> instructions from following output.
>
> Before:
> $ perf stat -r 5 perf bench sched pipe -l 10000000
> # Running 'sched/pipe' benchmark:
> # Executed 10000000 pipe operations between two processes
>
> Total time: 270.348 [sec]
>
> 27.034805 usecs/op
> 36989 ops/sec
> ...
>
> 245,537,074,035 cycles # 1.433 GHz
> 187,264,548,519 instructions # 0.77 insns per cycle
>
> 272.653840535 seconds time elapsed ( +- 1.31% )
>
> After:
> $ perf stat -r 5 perf bench sched pipe -l 10000000
> # Running 'sched/pipe' benchmark:
> # Executed 10000000 pipe operations between two processes
>
> Total time: 251.076 [sec]
>
> 25.107678 usecs/op
> 39828 ops/sec
> ...
>
> 244,573,513,928 cycles # 1.572 GHz
> 187,409,641,157 instructions # 0.76 insns per cycle
>
> 251.679315188 seconds time elapsed ( +- 0.31% )
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> include/linux/sched.h | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 3b0de68bce41..80cc1432e6e3 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1268,8 +1268,13 @@ struct sched_entity {
> #endif
>
> #ifdef CONFIG_SMP
> - /* Per entity load average tracking */
> - struct sched_avg avg;
> + /*
> + * Per entity load average tracking.
> + *
> + * Put into separate cache line so it does not
> + * collide with read-mostly values above.
> + */
> + struct sched_avg avg ____cacheline_aligned_in_smp;
> #endif
> };
>
> --
> 2.4.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:sched/core] sched/core: Move sched_entity:: avg into separate cache line
2015-12-08 20:23 [PATCH] sched: Move sched_entity::avg into separate cache line Jiri Olsa
2015-12-08 20:33 ` Arnaldo Carvalho de Melo
@ 2016-01-06 18:49 ` tip-bot for Jiri Olsa
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-01-06 18:49 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, efault, dzickus, peterz, torvalds, acme, tglx,
jolsa, jmario, hpa, mingo
Commit-ID: 5a1078043f844074cbd53981432778a8d5dd56e9
Gitweb: http://git.kernel.org/tip/5a1078043f844074cbd53981432778a8d5dd56e9
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Tue, 8 Dec 2015 21:23:59 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 6 Jan 2016 11:06:14 +0100
sched/core: Move sched_entity::avg into separate cache line
The sched_entity::avg collides with read-mostly sched_entity data.
The perf c2c tool showed many read HITM accesses across
many CPUs for sched_entity's cfs_rq and my_q, while having
at the same time tons of stores for avg.
After placing sched_entity::avg into separate cache line,
the perf bench sched pipe showed around 20 seconds speedup.
NOTE I cut out all perf events except for cycles and
instructions from following output.
Before:
$ perf stat -r 5 perf bench sched pipe -l 10000000
# Running 'sched/pipe' benchmark:
# Executed 10000000 pipe operations between two processes
Total time: 270.348 [sec]
27.034805 usecs/op
36989 ops/sec
...
245,537,074,035 cycles # 1.433 GHz
187,264,548,519 instructions # 0.77 insns per cycle
272.653840535 seconds time elapsed ( +- 1.31% )
After:
$ perf stat -r 5 perf bench sched pipe -l 10000000
# Running 'sched/pipe' benchmark:
# Executed 10000000 pipe operations between two processes
Total time: 251.076 [sec]
25.107678 usecs/op
39828 ops/sec
...
244,573,513,928 cycles # 1.572 GHz
187,409,641,157 instructions # 0.76 insns per cycle
251.679315188 seconds time elapsed ( +- 0.31% )
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1449606239-28602-1-git-send-email-jolsa@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/sched.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 791b47e..0c0e781 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1268,8 +1268,13 @@ struct sched_entity {
#endif
#ifdef CONFIG_SMP
- /* Per entity load average tracking */
- struct sched_avg avg;
+ /*
+ * Per entity load average tracking.
+ *
+ * Put into separate cache line so it does not
+ * collide with read-mostly values above.
+ */
+ struct sched_avg avg ____cacheline_aligned_in_smp;
#endif
};
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-06 18:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-08 20:23 [PATCH] sched: Move sched_entity::avg into separate cache line Jiri Olsa
2015-12-08 20:33 ` Arnaldo Carvalho de Melo
2016-01-06 18:49 ` [tip:sched/core] sched/core: Move sched_entity:: avg " tip-bot for Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.