Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp310865rdg; Thu, 12 Oct 2023 06:30:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIwTsi+fDmDMwXBHXHrZei+ZA7BF6IMQa9CyR4FoTLh9LIAL4aSjQOyPz+lc+znS+b7HF2 X-Received: by 2002:a17:903:110d:b0:1c1:fe97:bf34 with SMTP id n13-20020a170903110d00b001c1fe97bf34mr27098026plh.24.1697117404584; Thu, 12 Oct 2023 06:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697117404; cv=none; d=google.com; s=arc-20160816; b=AIUJzkUvRaYd9OHkqZIZJJK6rgqW39Ipc/XMNuXEUzjSsYPzCAaE4hm49rfwUZAZ98 nwcId11fhktQlGDXgG6Q0tm+Vi6MP7Wc5RDWeFiOq+WMSW2Ticm6KF3j8vfxQllTWYLI bvKorkhjLvmIBrvBsqNWETYP9KUeoT3ouwpwti3tXPzIudD4vDNl+sGQPmFkllJd8YjS ck7PWFH9jfhqig+NVVKVYA2626d0wcArSSFT/Ow0M41AOplr3r5Bqd1nhaaV2G/xaMIz J3G3aR3+xbce+vP66n82mUqW8GhFNVzUb57s/btQIJE9VwPdkqXpZPufnP3OrXluaI3O n/Dg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ybk+sUTEHYxJD085NMJHTHmsqfChe2BT9mQZhimnZfU=; fh=TwrmWDGKIzC/AbC9LX9EF6paIM8Xf9MOsZ70p54le1g=; b=DS5iuMStT575/x8FyYIVGwv25PpIBi2qsOg39PIngGMWcHAA1CQPgA+UjsNxs0Vi1D 1gnN5Hvnpe7vD5Av3JSX5wlZ72OHPkGgNFMoldAi9x6GVkZeoVTgJJMGNEJuNhzpBbCn 8vdY7Gd5vgL7j+y0Z5hDlpqGKe6ezMY5QoPCi+WRPeOOTt6sSa6r/j376TSelvbZa8Yq zOHgE7Nx8HElffd9LWciAIHINe4Bi9PeYs8Gcs6x262+dZIZmFwkcbraDZcaR6Cp3iD4 co0fNEojxiK3yKK5yUAznZYEYaczOVFHEj1l4iwFMEvynOPgR1Yd1vIFuYccfomCQJmR C71g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=jIuNn9Bp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id l3-20020a170902f68300b001c9abb72958si2320586plg.590.2023.10.12.06.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 06:30:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=jIuNn9Bp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8E08781B17C8; Thu, 12 Oct 2023 06:30:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378354AbjJLN3v (ORCPT + 99 others); Thu, 12 Oct 2023 09:29:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234174AbjJLN3u (ORCPT ); Thu, 12 Oct 2023 09:29:50 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0804B8 for ; Thu, 12 Oct 2023 06:29:48 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-419787a43ebso5798801cf.1 for ; Thu, 12 Oct 2023 06:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1697117388; x=1697722188; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Ybk+sUTEHYxJD085NMJHTHmsqfChe2BT9mQZhimnZfU=; b=jIuNn9BpNZ5E0CMi0rcrvn45N7C0GjqytSfQslPSzr9InqVKk9jkq8WGvuxTDJxisY 8doClCialO18/c0W4KBXdbq2b3VQrJOaXI1gR2l16L+tzuKuxVvC2KfBepJwyEWWJ7Cx RKQXv3Ff31I0mgZooTn1TPTCUEDlfwYT7rmoRPqO/0bGsqjCgEn68Z8XBhiGMHICNr6V 1trdWQc032Em+0mlqzUfmcrGffCSywJw/QadkpUk129XEGjq5MaS485arIHI6gaTPh2Y vJ7eJ0h6tH+/c1tlt4mzHhh2/GhNIyOF+oO6gTX/rk2TV8wqGlf7gfu4u9SuojgUe965 5hfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697117388; x=1697722188; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ybk+sUTEHYxJD085NMJHTHmsqfChe2BT9mQZhimnZfU=; b=Z09e74LTC2YX3Cgq22zIQTdeP4U+SYYbImOIhHMhhrbXOrWsFO2bym0zIXPYJ3n+qn 1kHtzKSP41bLTvnRAVlic+c+yJwuRPuxotmt8DdION+fKAadJEc7nVjjrSiitgT9r0cH qlvGcJAIfN5TM4DMQLRlAGTKydBgIeISMWj+eO6vM/EiqGuc9r+Fsv6TR/3xD1hwXVIl AG4LKE5x36i2d41iisVDw3bpLmb70drBuELLS8/QvMyRumaINCBOGsePEAxw7Q7NVo53 +Rim+P0qIbuGPD/5d+cAtIuMiJdF0sqDR0U9tNL/19E8tFY0VhHyiMLsocNzqoCuggbe /pkg== X-Gm-Message-State: AOJu0YxWD09elnd+R6+b7CR+XyGd+5/Rt8+/5tR8vENXPcEU78j/53Ha j3rq6Z+VYgPkfY2LhC9/6aV0IA== X-Received: by 2002:a05:622a:11d4:b0:416:5e11:f7ec with SMTP id n20-20020a05622a11d400b004165e11f7ecmr31277304qtk.52.1697117387879; Thu, 12 Oct 2023 06:29:47 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:66a6]) by smtp.gmail.com with ESMTPSA id g26-20020ac870da000000b00400a99b8b38sm6146339qtp.78.2023.10.12.06.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 06:29:47 -0700 (PDT) Date: Thu, 12 Oct 2023 09:29:46 -0400 From: Johannes Weiner To: Yosry Ahmed Cc: Shakeel Butt , Andrew Morton , Michal Hocko , Roman Gushchin , Muchun Song , Ivan Babrou , Tejun Heo , Michal =?iso-8859-1?Q?Koutn=FD?= , Waiman Long , kernel-team@cloudflare.com, Wei Xu , Greg Thelen , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/5] mm: memcg: make stats flushing threshold per-memcg Message-ID: <20231012132946.GA470544@cmpxchg.org> References: <20231010032117.1577496-1-yosryahmed@google.com> <20231010032117.1577496-4-yosryahmed@google.com> <20231011003646.dt5rlqmnq6ybrlnd@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 06:30:01 -0700 (PDT) On Thu, Oct 12, 2023 at 01:04:03AM -0700, Yosry Ahmed wrote: > On Wed, Oct 11, 2023 at 8:13 PM Yosry Ahmed wrote: > > > > On Wed, Oct 11, 2023 at 5:46 AM Shakeel Butt wrote: > > > > > > On Tue, Oct 10, 2023 at 6:48 PM Yosry Ahmed wrote: > > > > > > > > On Tue, Oct 10, 2023 at 5:36 PM Shakeel Butt wrote: > > > > > > > > > > On Tue, Oct 10, 2023 at 03:21:47PM -0700, Yosry Ahmed wrote: > > > > > [...] > > > > > > > > > > > > I tried this on a machine with 72 cpus (also ixion), running both > > > > > > netserver and netperf in /sys/fs/cgroup/a/b/c/d as follows: > > > > > > # echo "+memory" > /sys/fs/cgroup/cgroup.subtree_control > > > > > > # mkdir /sys/fs/cgroup/a > > > > > > # echo "+memory" > /sys/fs/cgroup/a/cgroup.subtree_control > > > > > > # mkdir /sys/fs/cgroup/a/b > > > > > > # echo "+memory" > /sys/fs/cgroup/a/b/cgroup.subtree_control > > > > > > # mkdir /sys/fs/cgroup/a/b/c > > > > > > # echo "+memory" > /sys/fs/cgroup/a/b/c/cgroup.subtree_control > > > > > > # mkdir /sys/fs/cgroup/a/b/c/d > > > > > > # echo 0 > /sys/fs/cgroup/a/b/c/d/cgroup.procs > > > > > > # ./netserver -6 > > > > > > > > > > > > # echo 0 > /sys/fs/cgroup/a/b/c/d/cgroup.procs > > > > > > # for i in $(seq 10); do ./netperf -6 -H ::1 -l 60 -t TCP_SENDFILE -- > > > > > > -m 10K; done > > > > > > > > > > You are missing '&' at the end. Use something like below: > > > > > > > > > > #!/bin/bash > > > > > for i in {1..22} > > > > > do > > > > > /data/tmp/netperf -6 -H ::1 -l 60 -t TCP_SENDFILE -- -m 10K & > > > > > done > > > > > wait > > > > > > > > > > > > > Oh sorry I missed the fact that you are running instances in parallel, my bad. > > > > > > > > So I ran 36 instances on a machine with 72 cpus. I did this 10 times > > > > and got an average from all instances for all runs to reduce noise: > > > > > > > > #!/bin/bash > > > > > > > > ITER=10 > > > > NR_INSTANCES=36 > > > > > > > > for i in $(seq $ITER); do > > > > echo "iteration $i" > > > > for j in $(seq $NR_INSTANCES); do > > > > echo "iteration $i" >> "out$j" > > > > ./netperf -6 -H ::1 -l 60 -t TCP_SENDFILE -- -m 10K >> "out$j" & > > > > done > > > > wait > > > > done > > > > > > > > cat out* | grep 540000 | awk '{sum += $5} END {print sum/NR}' > > > > > > > > Base: 22169 mbps > > > > Patched: 21331.9 mbps > > > > > > > > The difference is ~3.7% in my runs. I am not sure what's different. > > > > Perhaps it's the number of runs? > > > > > > My base kernel is next-20231009 and I am running experiments with > > > hyperthreading disabled. > > > > Using next-20231009 and a similar 44 core machine with hyperthreading > > disabled, I ran 22 instances of netperf in parallel and got the > > following numbers from averaging 20 runs: > > > > Base: 33076.5 mbps > > Patched: 31410.1 mbps > > > > That's about 5% diff. I guess the number of iterations helps reduce > > the noise? I am not sure. > > > > Please also keep in mind that in this case all netperf instances are > > in the same cgroup and at a 4-level depth. I imagine in a practical > > setup processes would be a little more spread out, which means less > > common ancestors, so less contended atomic operations. > > > (Resending the reply as I messed up the last one, was not in plain text) > > I was curious, so I ran the same testing in a cgroup 2 levels deep > (i.e /sys/fs/cgroup/a/b), which is a much more common setup in my > experience. Here are the numbers: > > Base: 40198.0 mbps > Patched: 38629.7 mbps > > The regression is reduced to ~3.9%. > > What's more interesting is that going from a level 2 cgroup to a level > 4 cgroup is already a big hit with or without this patch: > > Base: 40198.0 -> 33076.5 mbps (~17.7% regression) > Patched: 38629.7 -> 31410.1 (~18.7% regression) > > So going from level 2 to 4 is already a significant regression for > other reasons (e.g. hierarchical charging). This patch only makes it > marginally worse. This puts the numbers more into perspective imo than > comparing values at level 4. What do you think? I think it's reasonable. Especially comparing to how many cachelines we used to touch on the write side when all flushing happened there. This looks like a good trade-off to me.