Re: [LKP] Re: [mm/memcg] bd0b230fe1: will-it-scale.per_process_ops -22.7% regression

From: Feng Tang
Date: Thu Nov 12 2020 - 07:28:51 EST


Hi Michal,

On Wed, Nov 04, 2020 at 09:15:46AM +0100, Michal Hocko wrote:
> > > > Hi Michal,
> > > >
> > > > We used the default configure of cgroups, not sure what configuration you
> > > > want,
> > > > could you give me more details? and here is the cgroup info of will-it-scale
> > > > process:
> > > >
> > > > $ cat /proc/3042/cgroup
> > > > 12:hugetlb:/
> > > > 11:memory:/system.slice/lkp-bootstrap.service
> > >
> > > OK, this means that memory controler is enabled and in use. Btw. do you
> > > get the original performance if you add one phony page_counter after the
> > > union?
> > >
> > I add one phony page_counter after the union and re-test, the regression
> > reduced to -1.2%. It looks like the regression caused by the data structure
> > layout change.
>
> Thanks for double checking. Could you try to cache align the
> page_counter struct? If that helps then we should figure which counters
> acks against each other by adding the alignement between the respective
> counters.

We tried below patch to make the 'page_counter' aligned.

diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h
index bab7e57..9efa6f7 100644
--- a/include/linux/page_counter.h
+++ b/include/linux/page_counter.h
@@ -26,7 +26,7 @@ struct page_counter {
/* legacy */
unsigned long watermark;
unsigned long failcnt;
-};
+} ____cacheline_internodealigned_in_smp;

and with it, the -22.7% peformance change turns to a small -1.7%, which
confirms the performance bump is caused by the change to data alignment.

After the patch, size of 'page_counter' increases from 104 bytes to 128
bytes, and the size of 'mem_cgroup' increases from 2880 bytes to 3008
bytes(with our kernel config). Another major data structure which
contains 'page_counter' is 'hugetlb_cgroup', whose size will change
from 912B to 1024B.

Should we make these page_counters aligned to reduce cacheline conflict?

Thanks,
Feng