Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp145454rdg; Thu, 12 Oct 2023 01:04:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1aKsvkih0o+dAQHTpcNJWJA28sphRBkQ1s7GVAPDvI/tWoy4fRvnSdKIXGezGMIlbGKUl X-Received: by 2002:a25:4608:0:b0:d6b:1531:bc6d with SMTP id t8-20020a254608000000b00d6b1531bc6dmr18954020yba.30.1697097894204; Thu, 12 Oct 2023 01:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697097894; cv=none; d=google.com; s=arc-20160816; b=IoDQWe38S+fq88WdmoDWB1i4Ab8Rqsum31qDyd4w9ADcBv+D5vB4Q278BxLKA+W9Ls SKT9/Qk99vO9V2RUiE+8iIzox5+0xSsLfJqZE5A+pHYhLbujKJTnfon1dvuQ7ZsFPNq0 9c9rvifoHkDmJHj2OUFyJrRIHdgdUA4aBAZ7v4mlxXqGyjbMfMRBoszsTA5i3QS08I1x EiSsPEtJJrXna8Yf8vUn5Lm+vVei8oqPizzFB+FFC4Sc0aHhKjq2Gje3M9+FIcbDS0df /ZqPOGtQL93HNFBIL8Jgjh674EF4+dLdERcwsqHWiUA5DgDOkDE9i2GCqkRSh+RIDL5/ IHPA== 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=937YDLhB/LKhEB9XjdalzzUB5ZBYWrU2yT5JnPkc4iE=; fh=xoUKUYwsHP88jVXv8iAtrUCIr9Fd+NLU74akQLg97ME=; b=akPhkKnbpytCVmlLttjo3KYKOHwrtlfScJbZZBWqgmJRueRkA4z47j6bighRzoPMxs AnWn71Svo2pOmpVZ3u1hnfL8vjyl7ecvvZjgW5ldSSTZ1xVXJ94oQ3BV4sIXJD+Oj7C4 QMMPQTxhzA0idSC1SWg7s32FRv5Zpvjf1LIsUNsiUzK2PyRWfzZ93OvL3GTXzFgBWE3N MPtGlkWiSdtApAwHXmHW3Pyw+wkjbjQDaKdBqT4p+iYbMWdcPbYp2vB4qLUPeeOYBtv7 sduGSBx53JujPInkpaIZ9lm458ak0xTzGTfx40bjYf3m6+pGJQJb4v5b9U3r0iv/HA8U ZMPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="qewU/EcE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q4-20020a056a00088400b0068fcc3406acsi14397463pfj.141.2023.10.12.01.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 01:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="qewU/EcE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 8330B80DD37C; Thu, 12 Oct 2023 01:04:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347243AbjJLIEo (ORCPT + 99 others); Thu, 12 Oct 2023 04:04:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343583AbjJLIEm (ORCPT ); Thu, 12 Oct 2023 04:04:42 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D34D2A9 for ; Thu, 12 Oct 2023 01:04:40 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-536b39daec1so1173190a12.2 for ; Thu, 12 Oct 2023 01:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697097879; x=1697702679; 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=937YDLhB/LKhEB9XjdalzzUB5ZBYWrU2yT5JnPkc4iE=; b=qewU/EcEEx41UZ8lkIg0A87JdPdglDONWNC9sEtjC4y5rLjBYQnL9A61N6cJe8sIif pxbUaECuwefSL9FIpNiVJ1xXmyHHhy5R8ot/zXVQ94xDR7R1KHNCLCE2ByQPfotfmpB+ 99eeB+cXxbYMJldlgIpfd9PZuv3nQCjE9oYk9zHXLEicFmmDXdcX/g81Bmi3Dzgep8tF QVgUAaQGMahbx0n8yv1uwNz35gYERKvJt9ut5Q4rA0vvLsHgbvxh2I8PgfZiDLQhILyF O9sXz8Lr7q+78LX6jpVyjKPcl2Ju538cjsjAT8M5/pTqwk8wanyA4zsLY8DNkMnURwLp NyRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697097879; x=1697702679; 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=937YDLhB/LKhEB9XjdalzzUB5ZBYWrU2yT5JnPkc4iE=; b=d1M/ihZyKlQ36JgzxyRCfRezlXuSVnQi8uP9D4KHUkwNgz/Coz41GBNWRKtJDZ1kq6 Nkt0PSrPwpnAeJyOKkFuZyvGtzAhOHJHvk6gtA25c/QnGT9/6SVKf9KX9Rm2+lJjT6Fg aY/erUddFcZyopYo66rbSAiEwiPrLPTAUr0EhU0EqTxi0d6m6f4TfkgG84nwXBKK8z/q inqH1gyOQdLH8RnLo6yVMksPM7+8qda/jrsgQZHZnZCP6IQ7eFvgTfonmgMTGqh1zQ6j oRWd4XewQnQJ8Yp6OCnPOs7wRKKHlFozh95yGmzKeSAfzugTtzGhK8wX5Ml6sP2qEVhl 1tww== X-Gm-Message-State: AOJu0YwWjqbnsjL3m76kk5MFdylpzveZHekQ6R11CRzLB2lKLpafExgp 3b9cwxpfqcPtDsAY/6Z1YaF7ksTbUTp8vRuUQmc/5w== X-Received: by 2002:a17:907:7636:b0:9ba:4163:1801 with SMTP id jy22-20020a170907763600b009ba41631801mr5519834ejc.60.1697097879098; Thu, 12 Oct 2023 01:04:39 -0700 (PDT) MIME-Version: 1.0 References: <20231010032117.1577496-1-yosryahmed@google.com> <20231010032117.1577496-4-yosryahmed@google.com> <20231011003646.dt5rlqmnq6ybrlnd@google.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 12 Oct 2023 01:04:03 -0700 Message-ID: Subject: Re: [PATCH v2 3/5] mm: memcg: make stats flushing threshold per-memcg To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , 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-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 01:04:51 -0700 (PDT) On Wed, Oct 11, 2023 at 8:13=E2=80=AFPM Yosry Ahmed = wrote: > > On Wed, Oct 11, 2023 at 5:46=E2=80=AFAM Shakeel Butt wrote: > > > > On Tue, Oct 10, 2023 at 6:48=E2=80=AFPM Yosry Ahmed wrote: > > > > > > On Tue, Oct 10, 2023 at 5:36=E2=80=AFPM 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_SENDFIL= E -- > > > > > -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=3D10 > > > NR_INSTANCES=3D36 > > > > > > 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 +=3D $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?