Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp310548rwe; Wed, 24 Aug 2022 01:05:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4hDdpEWCxsDS4WVRIOuyffB1QohxbFWUJEhVTUDW1sAdjt42B4OVo6FniBZE3BKTJoUz2k X-Received: by 2002:a63:68c2:0:b0:421:9e8f:35c4 with SMTP id d185-20020a6368c2000000b004219e8f35c4mr23415108pgc.363.1661328353814; Wed, 24 Aug 2022 01:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661328353; cv=none; d=google.com; s=arc-20160816; b=aOs3PHd2S3tL/T9V+qLIZYumji+xZfDPEr8rBWUFkpvwLZqv7kmHbuartKky7VZrdP 8qqm7N1Y35GTkIb6hfgTDeNOVDEPudH2uWXUkeBvdqiqYOPvIqYzx7Ky+N8SNPdb1Y7+ p92WH/kKRPb5s5ycyk6bytKeA+GKJxFrFTAIAT3sPeJtB8PsP3iSujNWze/QcEC8ePwC kZOROkMwzKYK7N0UbabAd/Z25DBO1PRIB8L6OInlGzKlQOfyI1MAQHHjD0m3dVj03D7Z aGNv5Ey3RdGAewPSzY9ShW+FfjtsdmWC4X+jh0Iskv/a9VjDM25Y/ElQZJ1ZBwc01qDY aQxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=V++k96zrKA+x4VrYQcjFRU0h85hnHFbQNXixpGjkrsQ=; b=q7gVO+51tgobAoL4gTB+E1upeBVB3SLE/kXVhbDtbMWf/JGkxrAujMzgNcyCUn3Wio OTRNtyquJBu5QatHzedv4rd0kfHSaFeotDLbTQYMzQFC92OSijLyTJbFnGvCMbC/W7F/ PsBOg4RiHjX+eIpF1/HuwLvCcPX1wUOgbWWRUwXMYzMjI0eJrfOVcjVlYOBi4cGfyC9X HEDT2xOAZb+ByIrNi7YUBlcIRG4Rg/cSikf/A6Wm/LNOqdqMXL8ybEhob5RjF5/7ioVx yjGrspg89dRkwH6uFXO97MrdAfNVq8CVGR9aYpE05oFxXmPkflZNOw6OFp42dOVAPc+z n/FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=IqZinnwQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j16-20020a170902da9000b00172d9f6e248si12602316plx.29.2022.08.24.01.05.41; Wed, 24 Aug 2022 01:05:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=IqZinnwQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234355AbiHXH72 (ORCPT + 99 others); Wed, 24 Aug 2022 03:59:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbiHXH71 (ORCPT ); Wed, 24 Aug 2022 03:59:27 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B0D857ED; Wed, 24 Aug 2022 00:59:26 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E1FC033C7A; Wed, 24 Aug 2022 07:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1661327964; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=V++k96zrKA+x4VrYQcjFRU0h85hnHFbQNXixpGjkrsQ=; b=IqZinnwQdu40DfoRGPFhFDObyG6y9HuBHOxzDQz57qkA5Ptk+105F7+HjvDaP6nShBO1X8 78rRkHWteb/XdLdQX3NVO23OP1069frkqE96ClKy5FpdehLuOfo3Bh6L/ioROo3k8bQ/iz 9IWCjnsbujxefljz69XX4KKm/cME1x0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C43DC13AC0; Wed, 24 Aug 2022 07:59:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yI+aLVzaBWO2WQAAMHmgww (envelope-from ); Wed, 24 Aug 2022 07:59:24 +0000 Date: Wed, 24 Aug 2022 09:59:24 +0200 From: Michal Hocko To: Suren Baghdasaryan Cc: Zhaoyang Huang , Tejun Heo , Shakeel Butt , "zhaoyang.huang" , Johannes Weiner , Linux MM , LKML , Cgroups , Ke Wang , Zefan Li , Roman Gushchin , Muchun Song Subject: Re: [RFC PATCH] memcg: use root_mem_cgroup when css is inherited Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 23-08-22 09:21:16, Suren Baghdasaryan wrote: > On Tue, Aug 23, 2022 at 4:51 AM Michal Hocko wrote: > > > > On Tue 23-08-22 17:20:59, Zhaoyang Huang wrote: > > > On Tue, Aug 23, 2022 at 4:33 PM Michal Hocko wrote: > > > > > > > > On Tue 23-08-22 14:03:04, Zhaoyang Huang wrote: > > > > > On Tue, Aug 23, 2022 at 1:21 PM Michal Hocko wrote: > > > > > > > > > > > > On Tue 23-08-22 10:31:57, Zhaoyang Huang wrote: > > > > [...] > > > > > > > I would like to quote the comments from google side for more details > > > > > > > which can also be observed from different vendors. > > > > > > > "Also be advised that when you enable memcg v2 you will be using > > > > > > > per-app memcg configuration which implies noticeable overhead because > > > > > > > every app will have its own group. For example pagefault path will > > > > > > > regress by about 15%. And obviously there will be some memory overhead > > > > > > > as well. That's the reason we don't enable them in Android by > > > > > > > default." > > > > > > > > > > > > This should be reported and investigated. Because per-application memcg > > > > > > vs. memcg in general shouldn't make much of a difference from the > > > > > > performance side. I can see a potential performance impact for no-memcg > > > > > > vs. memcg case but even then 15% is quite a lot. > > > > > Less efficiency on memory reclaim caused by multi-LRU should be one of > > > > > the reason, which has been proved by comparing per-app memcg on/off. > > > > > Besides, theoretically workingset could also broken as LRU is too > > > > > short to compose workingset. > > > > > > > > Do you have any data to back these claims? Is this something that could > > > > be handled on the configuration level? E.g. by applying low limit > > > > protection to keep the workingset in the memory? > > > I don't think so. IMO, workingset works when there are pages evicted > > > from LRU and then refault which provide refault distance for pages. > > > Applying memcg's protection will have all LRU out of evicted which > > > make the mechanism fail. > > > > It is really hard to help you out without any actual data. The idea was > > though to use the low limit protection to adaptively configure > > respective memcgs to reduce refaults. You already have data about > > refaults ready so increasing the limit for often refaulting memcgs would > > reduce the trashing. > > Sorry for joining late. > A couple years ago I tested root-memcg vs per-app memcg configurations > on an Android phone. Here is a snapshot from my findings: > > Problem > ======= > We see tangible increase in major faults and workingset refaults when > transitioning from root-only memory cgroup to per-application cgroups > on Android. > > Test results > ============ > Results while running memory-demanding workload: > root memcg per-app memcg delta > workingset_refault 1771228 3874281 +118.73% > workingset_nodereclaim 4543 13928 +206.58% > pgpgin 13319208 20618944 +54.81% > pgpgout 1739552 3080664 +77.1% > pgpgoutclean 2616571 4805755 +83.67% > pswpin 359211 3918716 +990.92% > pswpout 1082238 5697463 +426.45% > pgfree 28978393 32531010 +12.26% > pgactivate 2586562 8731113 +237.56% > pgdeactivate 3811074 11670051 +206.21% > pgfault 38692510 46096963 +19.14% > pgmajfault 441288 4100020 +829.1% > pgrefill 4590451 12768165 +178.15% > > Results while running application cycle test (20 apps, 20 cycles): > root memcg per-app memcg delta > workingset_refault 10634691 11429223 +7.47% > workingset_nodereclaim 37477 59033 +57.52% > pgpgin 70662840 69569516 -1.55% > pgpgout 2605968 2695596 +3.44% > pgpgoutclean 13514955 14980610 +10.84% > pswpin 1489851 3780868 +153.77% > pswpout 4125547 8050819 +95.15% > pgfree 99823083 105104637 +5.29% > pgactivate 7685275 11647913 +51.56% > pgdeactivate 14193660 21459784 +51.19% > pgfault 89173166 100598528 +12.81% > pgmajfault 1856172 4227190 +127.74% > pgrefill 16643554 23203927 +39.42% Thanks! It would be interesting to see per memcg stats as well. Are there any outliers? Are there any signs of over-reclaim (more pages scanned & reclaimed by both kswapd and direct reclaim? > Tests were conducted on an Android phone with 4GB RAM. > Similar regression was reported a couple years ago here: > https://www.spinics.net/lists/linux-mm/msg121665.html > > I plan on checking the difference again on newer kernels (likely 5.15) > after LPC this September. Thanks, that would be useful! -- Michal Hocko SUSE Labs