Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36027737rwd; Mon, 10 Jul 2023 16:52:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlFOqyb+CHQNfG3LEROu4ZWPf+5K7HMjUmiibmWDaOCMPPSACzCw257/fhNKQ9NPsXGSSceT X-Received: by 2002:a19:2d46:0:b0:4fb:18f4:4cd4 with SMTP id t6-20020a192d46000000b004fb18f44cd4mr10171508lft.55.1689033149845; Mon, 10 Jul 2023 16:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689033149; cv=none; d=google.com; s=arc-20160816; b=S6/bx8TP+cwPH0XYsiyF5LAuzm8ceFFaqUa0BsBt5YDCLHSrI1S2WHgZLr01aP/jWg F79Vtts08Og8Mr/QZL9pR+HWlLLcsZkrXarO9k4tPKhOV+Q8WKmAyXgVFyX5QgNm+QiY 4tNZYmmaivh10yGwl3bEWZg8FFezmTI666WIuolk/s8LTAWkYFYzVxo1D1zVsqwoc0jK s33zcJleOZODA2yLeZnxSdAi4cfdG1foNQU1pQEu0xdrZCS59XphIx3d6j19FUDJYuOO Qi5Jo6KUc3lNt3QIasHXN8qi24Sl0/alwuMLlnx8dQsSvl4nUFYOF9C4Q6kFq2e0J6nW ZPbw== 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=Ax+jVrYfNmxpClqi51wVQRM9DJaaLI9Ll9U+M+qNnIE=; fh=0c/jPSZuPfDTc9G9JqpDVn2Djrt8vwW2zwhR3fEMfpg=; b=wBRELwr+MNhy4jzUQ2qMN5gPIvaU4x+NGZ3LCfLKQhsY/by+Fs72IEa4ctaSoWzs3/ KClgwhJ6EwMMvhT/dGpIfN5ZY674m2zuIv9n3ukunguFDbyMLpd7PDyt12Gv8JIjq4cZ iS7yN2MEFqGgvnyGTlwDNXn2xTzPBVE9w/hvFNdHi7+c7jgvsnnXEScshwMwyB6I0Jfk ZiuLSW5t3P0/W3djOL4bnCGPfretr1MuNEVmjC8QyhVGHSyLInfQDSpOL0VnZFgpmzo7 es132iojB44LScx6Z1Chahaizdmb8RV6sZ9wVTL5zGBDvRZQALHlwVv9LU2yjNXORYIR 7WiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=BLXTGXAR; 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=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020a50fc1a000000b0051ddbb7c57csi718979edr.460.2023.07.10.16.52.02; Mon, 10 Jul 2023 16:52:29 -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=@cloudflare.com header.s=google header.b=BLXTGXAR; 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=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbjGJXYA (ORCPT + 99 others); Mon, 10 Jul 2023 19:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjGJXX7 (ORCPT ); Mon, 10 Jul 2023 19:23:59 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E700D99 for ; Mon, 10 Jul 2023 16:23:57 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-314313f127fso5244495f8f.1 for ; Mon, 10 Jul 2023 16:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; t=1689031436; x=1691623436; 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=Ax+jVrYfNmxpClqi51wVQRM9DJaaLI9Ll9U+M+qNnIE=; b=BLXTGXARwPCt0Z3QY6Hkyqe8P+UvKJuwOcDpcUhFrh7oauHoH7ek9S8FnzkxNKruxX h3Fkat+06xrYJVtdH+Ksjd099ymifYhPIVXtCSUuBFupjA4JzaCHCo03hWSvfs1PRNB+ k5eZnIfD3YabAza1cBlawD8pI6YWJibUkXyDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689031436; x=1691623436; 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=Ax+jVrYfNmxpClqi51wVQRM9DJaaLI9Ll9U+M+qNnIE=; b=ABZWABWDoF7MKBRO77uBgTvtbdHI/NU4Pqbexdh94IK8iAIFq67mitgJGjIDZAU9qB VRnSu1mpa4Lk+KV32MFdOxtrzUiXMoSY+XozdTRMf3d2cWNRZotR6ggV8VhpRhqE0e2w yZDAZUjABdjpXmSOJH4LXaXVn8ZyiAPvKbaZDgX7H05v9sfz3bmOtxOEtYmJ1v2qqgIU kDambI6O/7DGSbiP80c32w79Vf9epSr0VenhxP+SM64DYI0XIEPxf8c22YEuTQJV0C8g +tuuUrMX8eSaLTywf6iq7XYlF84RTIFHb5rZEvDnlW7VKr4jZwQCbbRGsAnnrTdc1qYj zFEw== X-Gm-Message-State: ABy/qLYxA++dtFFP15NaCs9jiOxSYSrVzcMOC32nHZywguJVPRnelRfx aje72ih7CZCE61MGw2Sr2QWv8uRZfvm9EM0/idikyA== X-Received: by 2002:a5d:6546:0:b0:314:420c:5ef7 with SMTP id z6-20020a5d6546000000b00314420c5ef7mr11980548wrv.11.1689031436427; Mon, 10 Jul 2023 16:23:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ivan Babrou Date: Mon, 10 Jul 2023 16:23:45 -0700 Message-ID: Subject: Re: Expensive memory.stat + cpu.stat reads To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: cgroups@vger.kernel.org, Linux MM , kernel-team , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Mon, Jul 10, 2023 at 7:44=E2=80=AFAM Michal Koutn=C3=BD wrote: > > Hello. > > On Fri, Jun 30, 2023 at 04:22:28PM -0700, Ivan Babrou wrote: > > As you might've noticed from the output, splitting the loop into two > > makes the code run 10x faster. > > That is curious. > > > We're running Linux v6.1 (the output is from v6.1.25) with no patches > > that touch the cgroup or mm subsystems, so you can assume vanilla > > kernel. > > Have you watched for this on older kernels too? We've been on v6.1 for quite a while now, but it's possible that we weren't paying enough attention before to notice. > > I am happy to try out patches or to do some tracing to help understand > > this better. > > I see in your reproducer you tried swapping order of controllers > flushed. > Have you also tried flushing same controller twice (in the inner loop)? > (Despite the expectation is that it shouldn't be different from half the > scenario where ran two loops.) Same controller twice is fast (whether it's mem + mem or cpu + cpu): warm-up completed: 17.24s [manual / cpu-stat + mem-stat] completed: 1.02s [manual / mem-stat+mem-stat] completed: 0.59s [manual / cpu-stat+cpu-stat] completed: 0.44s [manual / mem-stat] completed: 0.16s [manual / cpu-stat] running completed: 14.32s [manual / cpu-stat + mem-stat] completed: 1.25s [manual / mem-stat+mem-stat] completed: 0.42s [manual / cpu-stat+cpu-stat] completed: 0.12s [manual / mem-stat] completed: 0.50s [manual / cpu-stat]