Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1821482rdb; Tue, 3 Oct 2023 01:50:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0GklgII3vvJxrOjKU0n2lZvyYHnMOISKjVKbkACQv6O9i6ucQDdCxyfmfEC4JDPJ9rLH+ X-Received: by 2002:a05:6122:138:b0:49d:fab:fa42 with SMTP id a24-20020a056122013800b0049d0fabfa42mr9566617vko.1.1696323008544; Tue, 03 Oct 2023 01:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696323008; cv=none; d=google.com; s=arc-20160816; b=IOVau0lVh+sRWHraOhycMtXxO8t5PnGrh7Pkhc+bGNwNSkiALllqBq6lXrgBzTbzZc MkGsu95AiPR9CjvaLvKkHtB4YzzsXYkpYC50FA5BugoK4w4iAfVOuXI6uYVa8rRLcDH5 3VZ7IaNVShrJyawpjAemSr9AqBH2HM/7WvULQJs5bHJ0IqHSls9drKI46psqHAHQwbKO vKSojMTdouVSC1ZUnhXTL1M624mEOKeMby3GvcybsA9XlGaROR+KqjnOEAcxhZ0WoMTi aiDgkd0/RNmZ0ANBBluMooQ3mMOB/AEH3ymvHQjpIp7KBeYBWowK3WZu3F1JBcGeDfOY 8tPA== 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=/0JTpNHaoGiA988EVZvIhjeIbRusRoOXVDRZstAjXHc=; fh=cY5dfcZV64K0FB0quy6f145p5/9DqQXtZ7RpORdWNrQ=; b=gP0ctZCkn3+isqA7rA3GCkklEigsUwwRNKEqMzjBd1Zzm8RGOup1bjV51z4+MIr6NL YbFYkiwla1UkR/Chr9OOLjEwNywuU2QBpPlVQIaM2TXFbBwKuTMUTy0m1XKwtIkHMYJn JhEssTI6tRREmlBXQBGPo8+jWt8awfFkQWXVwyO1PzYvb6T6RaPv+83h24Jllnj9NaCP C4j1gs5+vS1RlaIhJgHBMaQCC4XdqVUt+kC7myfmbsDXE6z8i/KsqfgYIrJ8ntEnN4yM 7pvb6CsIyqEtzqfPwVDzi17XQTKm8Sze+qANwaQwuS+BED7WUH0T+ueayO6HHGaDEbJJ oV1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Crs1iIu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t7-20020a17090a510700b00263f3d759cdsi979967pjh.78.2023.10.03.01.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Crs1iIu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 7F5898159608; Tue, 3 Oct 2023 01:50:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231383AbjJCIuG (ORCPT + 99 others); Tue, 3 Oct 2023 04:50:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231398AbjJCIuC (ORCPT ); Tue, 3 Oct 2023 04:50:02 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA15AD for ; Tue, 3 Oct 2023 01:49:59 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9a645e54806so109196666b.0 for ; Tue, 03 Oct 2023 01:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696322998; x=1696927798; 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=/0JTpNHaoGiA988EVZvIhjeIbRusRoOXVDRZstAjXHc=; b=Crs1iIu6w7O//RXyGvoZLrFqNciD74xeXoBcdT6kCH+F6n0xMErEtnFrOJWHRCgz7r 06OEwMI+qnZ/tVmusTCC+yJz/TFvRmYRK40c7N379zy3zZ2crF12AoOVF6ijkhjxBmJY l7XslEUqkAY2JgH8hR3CMTMF6Aak2HxD6Nyg93VDobK1jvTz7p4cHIyf2I8pXJkfaKSs +qEetTRI2tUJM/IjmKTRr4os95Hsgq9D86fPSsomtFNc4aOQP7YQEQeFIIjd2R2Ih9K2 B7+bNxKln3jL3xPVmXoImA5cqis8tnC/n3JQfZ0/EWEJhmsXjMm/5EL0lV1k2TgrFqNU t4Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696322998; x=1696927798; 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=/0JTpNHaoGiA988EVZvIhjeIbRusRoOXVDRZstAjXHc=; b=Epl/iGzO2v+o3ZIIfSEMH0W5CYtzehFihXlhU/l396/cz9I3fHaOcLcbF5glHFy6nN e/AC1JsD6VNW8KJ8znzQMQhKTGBKkmX/6rR3tilGgJMRfTVbef4yqg5D4SfriA6YyIOj 3DJee8ZIZCUUL9lBULcTKxJD2Fi5J3h5BcnGPmla5WjIxoPqKOMLQa69nCBi6p2uX8Mg eaWrTkkka6+28hB/UjttqJJuys89paqUyJ85TCAwgW4k8XXin40Ugxf6rblHRk+4tRtZ uAppU3UZ6DKhDkfX6AfnwiwFedDBUumTdDpyUfPTqnSoKNxS1QyayHf2qrFjD+NRObE7 BeYw== X-Gm-Message-State: AOJu0YzgATyVCY2oOjo9/lQkLDyWWg1+XfYd0NlDBWlf0DWZEKkTPgY9 wqJ6/6+3Ttt566uGuCf9PXBc1gegP1SvNA9o4Ycy2g== X-Received: by 2002:a17:907:2e01:b0:9ae:6389:911 with SMTP id ig1-20020a1709072e0100b009ae63890911mr12233677ejc.31.1696322997687; Tue, 03 Oct 2023 01:49:57 -0700 (PDT) MIME-Version: 1.0 References: <20230922175741.635002-1-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Tue, 3 Oct 2023 01:49:19 -0700 Message-ID: Subject: Re: [PATCH v2 0/2] mm: memcg: fix tracking of pending stats updates values To: Michal Hocko Cc: Andrew Morton , Shakeel Butt , Johannes Weiner , Roman Gushchin , Muchun Song , =?UTF-8?Q?Michal_Koutn=C3=BD?= , 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:50:07 -0700 (PDT) On Tue, Oct 3, 2023 at 1:09=E2=80=AFAM Michal Hocko wrote= : > > On Tue 03-10-23 01:03:53, Yosry Ahmed wrote: > > On Tue, Oct 3, 2023 at 12:57=E2=80=AFAM Michal Hocko = wrote: > > > > > > On Mon 25-09-23 10:11:05, Yosry Ahmed wrote: > > > > On Mon, Sep 25, 2023 at 6:50=E2=80=AFAM Michal Hocko wrote: > > > > > > > > > > On Fri 22-09-23 17:57:38, Yosry Ahmed wrote: > > > > > > While working on adjacent code [1], I realized that the values = passed > > > > > > into memcg_rstat_updated() to keep track of the magnitude of pe= nding > > > > > > updates is consistent. It is mostly in pages, but sometimes it = can be in > > > > > > bytes or KBs. Fix that. > > > > > > > > > > What kind of practical difference does this change make? Is it wo= rth > > > > > additional code? > > > > > > > > As explained in patch 2's commit message, the value passed into > > > > memcg_rstat_updated() is used for the "flush only if not worth it" > > > > heuristic. As we have discussed in different threads in the past fe= w > > > > weeks, unnecessary flushes can cause increased global lock contenti= on > > > > and/or latency. > > > > > > > > Byte-sized paths (percpu, slab, zswap, ..) feed bytes into the > > > > heuristic, but those are interpreted as pages, which means we will > > > > flush earlier than we should. This was noticed by code inspection. = How > > > > much does this matter in practice? I would say it depends on the > > > > workload: how many percpu/slab allocations are being made vs. how m= any > > > > flushes are requested. > > > > > > > > On a system with 100 cpus, 25M of stat updates are needed for a flu= sh > > > > usually, but ~6K of slab/percpu updates will also (mistakenly) caus= e a > > > > flush. > > > > > > This surely depends on workload and that is understandable. But it wo= uld > > > be really nice to provide some numbers for typical workloads which > > > exercise slab heavily. > > > > If you have a workload in mind I can run it and see how many flushes > > we get with/without this patch. The first thing that pops into my head > > is creating a bunch of empty files but I don't know if that's the best > > thing to get numbers from. > > Let me remind you that you are proposing a performance optimization and > such a change requires some numbers to actually show it is benefitial. > There are cases where the resulting code is clearly an improvement and > the performance benefit is just a nice side effect. I do not consider > this to be the case. The whole thing is quite convoluted even without > a better precision you are proposing. And let me be clear, I am not > opposing your patch but I would rather see it based on more than just > hand waving. It is purely based on code inspection, and honestly I don't have numbers to support it. I saw something wrong with the code and I tried to fix it, I was working on something else when I noticed it. That being said, I acknowledge it's not making the code any prettier :) Feel free to suggest improvements to the code to make it more bearable, otherwise if you don't like it I will just leave it to be honest. Thanks for taking a look! > -- > Michal Hocko > SUSE Labs