From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C03DC433EF for ; Fri, 24 Jun 2022 05:13:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E82736B029A; Fri, 24 Jun 2022 01:13:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E33066B029C; Fri, 24 Jun 2022 01:13:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE2286B029D; Fri, 24 Jun 2022 01:13:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BE7B06B029A for ; Fri, 24 Jun 2022 01:13:58 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 9F29C812CF for ; Fri, 24 Jun 2022 05:13:58 +0000 (UTC) X-FDA: 79611962556.11.3EFE808 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf29.hostedemail.com (Postfix) with ESMTP id CC89A12001A for ; Fri, 24 Jun 2022 05:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656047637; x=1687583637; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=QYBf8oflbgBC/XBfAzL41uZYcigxxwAfRsDKymMRo5s=; b=BzTt9PHhOQVrJoFZn0tiCOkKyg70mxhMFPmOitNcq72cl+5pNjX4fQv6 seTuTaB6eRsDkRNGn24E1LjCdyAXB50HNSr23YJ8jwcaIz1YgMduaRqXG Dmibn5KFTiB6TKTmlxV64ZuIoWDbK1hbYyjKxIJsoX3RXsHXtpaI4ql51 lSwwoW+kOzgi6kuhNGVLoZISIZJ90ROIElReO7d/MooE5NYtMBqH+sLuh 0S3Bo0u1v5xUlOtWCakoKlwy/qRhsifClKzo7PKX/fAC5t/cQCAzr+7/E O/7eKF3QkuBL2eT02Ff6GsfOM6HxiDP5wYKZOLX/h3QLaylnJFMoeym3c Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="269653257" X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="269653257" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 22:13:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="678398213" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.146.138]) by FMSMGA003.fm.intel.com with ESMTP; 23 Jun 2022 22:13:52 -0700 Date: Fri, 24 Jun 2022 13:13:51 +0800 From: Feng Tang To: Eric Dumazet Cc: Jakub Kicinski , Xin Long , Marcelo Ricardo Leitner , kernel test robot , Shakeel Butt , Soheil Hassas Yeganeh , LKML , Linux Memory Management List , network dev , linux-s390@vger.kernel.org, MPTCP Upstream , "linux-sctp @ vger . kernel . org" , lkp@lists.01.org, kbuild test robot , Huang Ying , zhengjun.xing@linux.intel.com, fengwei.yin@intel.com, Ying Xu Subject: Re: [net] 4890b686f4: netperf.Throughput_Mbps -69.4% regression Message-ID: <20220624051351.GA72171@shbuild999.sh.intel.com> References: <20220619150456.GB34471@xsang-OptiPlex-9020> <20220622172857.37db0d29@kernel.org> <20220623185730.25b88096@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=BzTt9PHh; spf=none (imf29.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 134.134.136.20) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656047638; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9za2e6t9oeEMf6Tcg1WpJcXkpsw9Di41DPfBvMm1yAw=; b=Wmpb6bPwItX1r/jdAbv+cLa1CUv3sAppYke+WwpXvSHlDaahfBjnPgtYvqq2EDqS643UU/ OWCARaj6PKXwHasWQSgZrd2rC9QDemKQROp099j/NYYF0LyNefk1hW16hd7RyrWfsoiRPb IjYdmfrE0Za3G5KLoMErjmyVFOittUc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656047638; a=rsa-sha256; cv=none; b=T8yC1jpo2FGqb24+lxt2VFnoobk9k/U2vHyX+x6o9S4Kz2rg9L4X6djMXdOwydqVd46Npc pjcO4eYckb8nD+Q5U3hhjTf245I3yaoID8TBTWnAYw1U5Rw99lL+JZCPnkC9zbY8hsL165 GGJmt8vVjIBkgDLFcp2x1OTVi0yfhws= X-Stat-Signature: yw6xdzxcycu1i6q8k36n88wtjyc8o4sd X-Rspamd-Queue-Id: CC89A12001A X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=BzTt9PHh; spf=none (imf29.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 134.134.136.20) smtp.mailfrom=feng.tang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam02 X-HE-Tag: 1656047637-976582 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Eric, On Fri, Jun 24, 2022 at 06:13:51AM +0200, Eric Dumazet wrote: > On Fri, Jun 24, 2022 at 3:57 AM Jakub Kicinski wrote: > > > > On Thu, 23 Jun 2022 18:50:07 -0400 Xin Long wrote: > > > From the perf data, we can see __sk_mem_reduce_allocated() is the one > > > using CPU the most more than before, and mem_cgroup APIs are also > > > called in this function. It means the mem cgroup must be enabled in > > > the test env, which may explain why I couldn't reproduce it. > > > > > > The Commit 4890b686f4 ("net: keep sk->sk_forward_alloc as small as > > > possible") uses sk_mem_reclaim(checking reclaimable >= PAGE_SIZE) to > > > reclaim the memory, which is *more frequent* to call > > > __sk_mem_reduce_allocated() than before (checking reclaimable >= > > > SK_RECLAIM_THRESHOLD). It might be cheap when > > > mem_cgroup_sockets_enabled is false, but I'm not sure if it's still > > > cheap when mem_cgroup_sockets_enabled is true. > > > > > > I think SCTP netperf could trigger this, as the CPU is the bottleneck > > > for SCTP netperf testing, which is more sensitive to the extra > > > function calls than TCP. > > > > > > Can we re-run this testing without mem cgroup enabled? > > > > FWIW I defer to Eric, thanks a lot for double checking the report > > and digging in! > > I did tests with TCP + memcg and noticed a very small additional cost > in memcg functions, > because of suboptimal layout: > > Extract of an internal Google bug, update from June 9th: > > -------------------------------- > I have noticed a minor false sharing to fetch (struct > mem_cgroup)->css.parent, at offset 0xc0, > because it shares the cache line containing struct mem_cgroup.memory, > at offset 0xd0 > > Ideally, memcg->socket_pressure and memcg->parent should sit in a read > mostly cache line. > ----------------------- > > But nothing that could explain a "-69.4% regression" We can double check that. > memcg has a very similar strategy of per-cpu reserves, with > MEMCG_CHARGE_BATCH being 32 pages per cpu. We have proposed patch to increase the batch numer for stats update, which was not accepted as it hurts the accuracy and the data is used by many tools. > It is not clear why SCTP with 10K writes would overflow this reserve constantly. > > Presumably memcg experts will have to rework structure alignments to > make sure they can cope better > with more charge/uncharge operations, because we are not going back to > gigantic per-socket reserves, > this simply does not scale. Yes, the memcg statitics and charge/unchage update is very sensitive with the data alignemnt layout, and can easily trigger peformance changes, as we've seen quite some similar cases in the past several years. One pattern we've seen is, even if a memcg stats updating or charge function only takes about 2%~3% of the CPU cycles in perf-profile data, once it got affected, the peformance change could be amplified to up to 60% or more. Thanks, Feng