Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp956833pxb; Thu, 12 Nov 2020 23:41:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVc2ACJnM/GhDKmvt2F5lv/SktQjTp+zM/Ax8NumW6HTMN4xqqDAoXrR9+WXEC5KPHsp1t X-Received: by 2002:a05:6402:3064:: with SMTP id bs4mr1255170edb.258.1605253273584; Thu, 12 Nov 2020 23:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605253273; cv=none; d=google.com; s=arc-20160816; b=tabgLsfsdhF/zgX+62wZsYtK2yt0kuwJ/LTPYehyc+MwGpP8No8v3lwY6lz6Xrs0yr DBp9xHsPb7xcB2OUI8Y1mxD/2RIlxBG5/B7X1X1FGDPXpRI0I9OXOoiTcpElkJhfj7Oy TP4y5yrjzkfogjYwUpY37tUNrJ5nP6B4Ph7dp45qXprcUiil3Xzz7uyl1Yh6y1+QHO+Z RfdMdMhCnaSD972k9z2POXgdwNE8MGGUFe8pRfszF50++F5oLkQl/e0Rt4x/WQqA1KY9 3uwmMknfMfpn7BIt9TtzhIlcGVPQxBiNnzGQ+MIHsQh+8r6qTRR+mkGHFfQ4JcnkKDxT 7fww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=1NTEJJ21JrCnUA5xncmj9u+AkiDGLJ35lE8CHNJRA2M=; b=FOmQSyPF8d9C1kIrHNl8EGB6WNqFq6a3xPbGOITyZWxt9/++I/XMrfkeWEvefll+wA f5isOCRlWngVRYn8F8TY2zyWUjmTepT60O3TQSq8R59txU4NnKaCwDvfwA/eg4QE84J/ w+LsX2Qb4U+x0XyNRbrcpQlc/N1aHzeKcKwS955QncOxGVSc1V7OKKCsyS7pwgUFv73B 6VP5b87MiTYAop9RkkD2mVgN2ORTrq8v94k4JpXsT7E+IUkhzpQpJut8vhG+j4Bs2oi5 AC31515D4oaW8qOYsKYyj9myIfFGW1sT8TpUWNhCPjAPMwcf/0D3rTUkGfP26m5T+l10 Ee5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si5577507edq.164.2020.11.12.23.40.50; Thu, 12 Nov 2020 23:41:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726295AbgKMHjd (ORCPT + 99 others); Fri, 13 Nov 2020 02:39:33 -0500 Received: from mga07.intel.com ([134.134.136.100]:29494 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726133AbgKMHjc (ORCPT ); Fri, 13 Nov 2020 02:39:32 -0500 IronPort-SDR: g/EOUGQOh4F/EpLJZ8KwCCMhsvMc0tJ5q+eVaH3WJk/Fy/zPB2D65w5alMgnAeCTDI8jgzVKWP BkJpYDN/BE2w== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="234598819" X-IronPort-AV: E=Sophos;i="5.77,474,1596524400"; d="scan'208";a="234598819" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2020 23:39:31 -0800 IronPort-SDR: OeJS4RuRDltwgNKFLl6vi9iaaXpE8N6cFHBQjoquGyp9i7Z2lxgaM2P6oApP3IUHEL/G92pq0D GfBoZNoiNdyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,474,1596524400"; d="scan'208";a="328791314" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.147.98]) by orsmga006.jf.intel.com with ESMTP; 12 Nov 2020 23:39:27 -0800 Date: Fri, 13 Nov 2020 15:39:26 +0800 From: Feng Tang To: Waiman Long Cc: Michal Hocko , Xing Zhengjun , Linus Torvalds , Andrew Morton , Shakeel Butt , Chris Down , Johannes Weiner , Roman Gushchin , Tejun Heo , Vladimir Davydov , Yafang Shao , LKML , lkp@lists.01.org, lkp@intel.com, zhengjun.xing@intel.com, ying.huang@intel.com Subject: Re: [LKP] Re: [mm/memcg] bd0b230fe1: will-it-scale.per_process_ops -22.7% regression Message-ID: <20201113073926.GB113119@shbuild999.sh.intel.com> References: <20201102091543.GM31092@shao2-debian> <20201102092754.GD22613@dhcp22.suse.cz> <82d73ebb-a31e-4766-35b8-82afa85aa047@intel.com> <20201102100247.GF22613@dhcp22.suse.cz> <20201104081546.GB10052@dhcp22.suse.cz> <20201112122844.GA11000@shbuild999.sh.intel.com> <20201112141654.GC12240@dhcp22.suse.cz> <7e40849b-f9e0-34d4-4254-c2c99dd71f78@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7e40849b-f9e0-34d4-4254-c2c99dd71f78@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 12, 2020 at 11:43:45AM -0500, Waiman Long wrote: > >>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? > >I would rather focus on a more effective mem_cgroup layout. It is very > >likely that we are just stumbling over two counters here. > > > >Could you try to add cache alignment of counters after memory and see > >which one makes the difference? I do not expect memsw to be the one > >because that one is used together with the main counter. But who knows > >maybe the way it crosses the cache line has the exact effect. Hard to > >tell without other numbers. > > > >Btw. it would be great to see what the effect is on cgroup v2 as well. > > > >Thanks for pursuing this! > > The contention may be in the page counters themselves or it can be in other > fields below the page counters. The cacheline alignment will cause > "high_work" just after the page counters to start at a cacheline boundary. I > will try removing the cacheline alignment in the page counter and add it to > high_work to see there is any change in performance. If there is no change, > the performance problem will not be in the page counters. Yes, that's a good spot to check. I even doubt it could be other members of 'struct mem_cgroup', which affects the benchmark, as we've seen some other performance bump which is possibly related to it too. Thanks, Feng