Skip to content

Commit 77070ee

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup: Avoid false cacheline sharing of read mostly rstat_cpu
The rstat_cpu and also rstat_css_list of the cgroup structure are read mostly variables. However, they may share the same cacheline as the subsequent rstat_flush_next and *bstat variables which can be updated frequently. That will slow down the cgroup_rstat_cpu() call which is called pretty frequently in the rstat code. Add a CACHELINE_PADDING() line in between them to avoid false cacheline sharing. A parallel kernel build on a 2-socket x86-64 server is used as the benchmarking tool for measuring the lock hold time. Below were the lock hold time frequency distribution before and after the patch: Run time Before patch After patch -------- ------------ ----------- 0-01 us 9,928,562 9,820,428 01-05 us 110,151 50,935 05-10 us 270 93 10-15 us 273 146 15-20 us 135 76 20-25 us 0 2 25-30 us 1 0 It can be seen that the patch further pushes the lock hold time towards the lower end. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent d499fd4 commit 77070ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/linux/cgroup-defs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,13 @@ struct cgroup {
496496
struct cgroup_rstat_cpu __percpu *rstat_cpu;
497497
struct list_head rstat_css_list;
498498

499+
/*
500+
* Add padding to separate the read mostly rstat_cpu and
501+
* rstat_css_list into a different cacheline from the following
502+
* rstat_flush_next and *bstat fields which can have frequent updates.
503+
*/
504+
CACHELINE_PADDING(_pad_);
505+
499506
/*
500507
* A singly-linked list of cgroup structures to be rstat flushed.
501508
* This is a scratch field to be used exclusively by

0 commit comments

Comments
 (0)