Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2766311rda; Wed, 25 Oct 2023 11:37:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYuZk1zEoc+EAr6pDufhIM3qc4aFG9pymQ94o6r5CkkTlHRd/O6jzvLGwJ+rwyoaK3H4Wm X-Received: by 2002:a0d:d54a:0:b0:5a7:d412:af32 with SMTP id x71-20020a0dd54a000000b005a7d412af32mr17168446ywd.10.1698259063042; Wed, 25 Oct 2023 11:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698259063; cv=none; d=google.com; s=arc-20160816; b=Qlgk8COS1ydKwZjmOcuv6Ar674EZdMqkref8r4k45m4Kj5VPEyIryWR0vQFD3BxMOC JGSAu7dX7pbpIFGmCZ0GltacIEVueQY0IsnAj47hIaxVxn8kjRf39vYwovv6sL6JMMmu Q077zLW8YgiRMcELnt+6eQRq0HlJRMlnmBbbbhSgsWMYlyf+ds8fujZ/rGlIoJuVsOpt wzAEA6zHmKTFeA3zLnCJ9oYWNLpUn3FQhl5V94oqMNw7SKXd/AYbTV+T50G1RqmydUno LvqfkbEGGWiapnjOojBPnyw4dkIPmwTfMWHPnCnuOpuXbum/ZH07euOOKJr4DVV5ZS10 tpdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2e92O8wEWD/53OKXUltaj6IOD/TJFtp9v92hFMtfX+0=; fh=FcA4fVe48FB+JFLI79AoQi1lH68EODYofULGOXsj7Hg=; b=NSNMNZtCNqtu0SFZNKDjBk+WEF4GVj/WCVkMMLW/QA8PJs/Es8rn0HiVC635oMh3EB VCCgOJfE+fQiL6hX/UoBpJ0h5/Xj6Elb0GiczAJPe87eS/mbqBN+TXHgs+9BnBMgwl3g xofYSJKZWZhIeBWCo2dd1MQlvepu7jxstP0+kbku6Yp61KtoRHqsx4ujpOddkgKj1shF xwoO0bJp+IDX4o8XSdiimSHP8zNpEfn5VDh3qn3xrLW7O4UUbH8llbUi4WCQEPuj6W7C wVVavxPHnXs8G405nGcWsuBhHDBYKGU7GwMeX58Q51UBSkF7hFvKc4Ho4rtCny3QE9bI BSdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HZUDCNyW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t64-20020a818343000000b0059c267a488asi11848680ywf.314.2023.10.25.11.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 11:37:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HZUDCNyW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1781E80C3A34; Wed, 25 Oct 2023 11:37:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229788AbjJYSg6 (ORCPT + 99 others); Wed, 25 Oct 2023 14:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjJYSg4 (ORCPT ); Wed, 25 Oct 2023 14:36:56 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA12E115 for ; Wed, 25 Oct 2023 11:36:54 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-9c75ceea588so12280666b.3 for ; Wed, 25 Oct 2023 11:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698259013; x=1698863813; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2e92O8wEWD/53OKXUltaj6IOD/TJFtp9v92hFMtfX+0=; b=HZUDCNyWfmVGsQvYptxE2H5bp/TtofRCTOocZ+RBHWLyryaezilnDrb/MzrfogOWdp +DgOnlBW/XHxVKrIRjqb9K9+2uOyM8p0iHryEfbWWxKwv643z3Jdl5um+CxPeGQ+5pAG I2405qN/sR/CmHZ8RZbvDJSQpPIo+G5uMdQyDHqXlJ8UynGCYES3iL47Rks0xEghww7l DlxaAghKgRKsQMzC0+yq9KAzzxcLmuv+I97df0DhiC28+5i4iyKiBjid0wDExEXxf5cL 2piE8YMRLN7pvWIjoMKXU2c9uZ+dW5In6wdX7LL3GRAqgMvAURLahG1NMFaSfjlpv4wB 97/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698259013; x=1698863813; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2e92O8wEWD/53OKXUltaj6IOD/TJFtp9v92hFMtfX+0=; b=viPuT8G8KhK5RHGMMa8Qa8wnGs4EqEmcsb4H1klxRKAKIhZsrUj2fapemvDFDkla/9 G39TvWY8UEwjJWtaIH2ugV4XkA3SvrTLZcLPbyvVtyLmUdYHVTpcp+KxAtS2sNihMM9g cAMLl+dfxVAw5xMPOQICUfEKGrZTgpsyz/4iX5mfjboO0BJkV063DG5RpXLqCguZs1QL fwyQROVv/zV74jj89XXBv5ITR1UyCIxfrzpYnO+Ksz2txBz4b5jviTYfAz0xVo4Jurhz sWlxKDfo92HTluZ4IiWj/Ypm5NHQ27aqBi3PJNxLGCe+JzzwlLwKVjO0hPstGt/Bspjy hNJA== X-Gm-Message-State: AOJu0YxF91YF2cQJZKawJe0ztsYpO7WuK0gfy9zLO1asgr+CTce99rLN qogceQ2OXBFGp104fn0L9dXIBzP/ZWlixxqMiZH/WA== X-Received: by 2002:a17:907:70b:b0:9c6:724:fa16 with SMTP id xb11-20020a170907070b00b009c60724fa16mr12368133ejb.59.1698259012860; Wed, 25 Oct 2023 11:36:52 -0700 (PDT) MIME-Version: 1.0 References: <20231010032117.1577496-4-yosryahmed@google.com> <202310202303.c68e7639-oliver.sang@intel.com> In-Reply-To: From: Yosry Ahmed Date: Wed, 25 Oct 2023 11:36:13 -0700 Message-ID: Subject: Re: [PATCH v2 3/5] mm: memcg: make stats flushing threshold per-memcg To: Shakeel Butt Cc: Oliver Sang , Johannes Weiner , Feng Tang , "oe-lkp@lists.linux.dev" , lkp , "cgroups@vger.kernel.org" , "linux-mm@kvack.org" , "Huang, Ying" , "Yin, Fengwei" , Andrew Morton , Michal Hocko , Roman Gushchin , Muchun Song , Ivan Babrou , Tejun Heo , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Waiman Long , "kernel-team@cloudflare.com" , Wei Xu , Greg Thelen , "linux-kernel@vger.kernel.org" , Domenico Cerasuolo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 25 Oct 2023 11:37:16 -0700 (PDT) On Wed, Oct 25, 2023 at 10:06=E2=80=AFAM Shakeel Butt = wrote: > > On Tue, Oct 24, 2023 at 11:23=E2=80=AFPM Yosry Ahmed wrote: > > > [...] > > > > Thanks Oliver for running the numbers. If I understand correctly the > > will-it-scale.fallocate1 microbenchmark is the only one showing > > significant regression here, is this correct? > > > > In my runs, other more representative microbenchmarks benchmarks like > > netperf and will-it-scale.page_fault* show minimal regression. I would > > expect practical workloads to have high concurrency of page faults or > > networking, but maybe not fallocate/ftruncate. > > > > Oliver, in your experience, how often does such a regression in such a > > microbenchmark translate to a real regression that people care about? > > (or how often do people dismiss it?) > > > > I tried optimizing this further for the fallocate/ftruncate case but > > without luck. I even tried moving stats_updates into cgroup core > > (struct cgroup_rstat_cpu) to reuse the existing loop in > > cgroup_rstat_updated() -- but it somehow made it worse. > > > > On the other hand, we do have some machines in production running this > > series together with a previous optimization for non-hierarchical > > stats [1] on an older kernel, and we do see significant reduction in > > cpu time spent on reading the stats. Domenico did a similar experiment > > with only this series and reported similar results [2]. > > > > Shakeel, Johannes, (and other memcg folks), I personally think the > > benefits here outweigh a regression in this particular benchmark, but > > I am obviously biased. What do you think? > > > > [1]https://lore.kernel.org/lkml/20230726153223.821757-2-yosryahmed@goog= le.com/ > > [2]https://lore.kernel.org/lkml/CAFYChMv_kv_KXOMRkrmTN-7MrfgBHMcK3YXv0d= PYEL7nK77e2A@mail.gmail.com/ > > I still am not convinced of the benefits outweighing the regression > but I would not block this. So, let's do this, skip this open window, > get the patch series reviewed and hopefully we can work together on > fixing that regression and we can make an informed decision of > accepting the regression for this series for the next cycle. Skipping this open window sounds okay to me. FWIW, I think with this patch series we can keep the old behavior (roughly) and hide the changes behind a tunable (config option or sysfs file). I think the only changes that need to be done to the code to approximate the previous behavior are: - Use root when updating the pending stats in memcg_rstat_updated() instead of the passed memcg. - Use root in mem_cgroup_flush_stats() instead of the passed memcg. - Use mutex_trylock() instead of mutex_lock() in mem_cgroup_flush_stats(). So I think it should be doable to hide most changes behind a tunable, but let's not do this unless necessary.