From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AC08E75433 for ; Tue, 3 Oct 2023 08:50:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DEB88D0065; Tue, 3 Oct 2023 04:50:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7678A8D0003; Tue, 3 Oct 2023 04:50:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6081B8D0065; Tue, 3 Oct 2023 04:50:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4CABD8D0003 for ; Tue, 3 Oct 2023 04:50:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 207841201FB for ; Tue, 3 Oct 2023 08:50:02 +0000 (UTC) X-FDA: 81303527844.02.1651C75 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by imf06.hostedemail.com (Postfix) with ESMTP id 54F1F180010 for ; Tue, 3 Oct 2023 08:49:59 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=pzE5xIY9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696322999; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/0JTpNHaoGiA988EVZvIhjeIbRusRoOXVDRZstAjXHc=; b=IwKu4U48MInghicmrXGJss68ZU6ccwRPW+lqeMDA69UOWbfgogW0cx6qOiXK1U6we4zBwa wMh/jIBEQzLU4vKuaDcbTcXB+vEnwTUrrwO1qj11DEdxauCey6vMA8hUigwkOmxi9CDsab /fOPGAeo+hzzhQINbr1EQiv4cKGuM5A= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=pzE5xIY9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696322999; a=rsa-sha256; cv=none; b=YI72NxozQb175eAyZ645EiOA66p90VwCL1X0UCqnX1SgPrXyUIetYBDJ+hSw4G+v/E1dCI qARQYNpX5xa1C35oId9CpxYZbj2S0ZI8gQ29C5VuLmq1w5OzCalrcFSOQSNmU9uUXPy/XS +0iSDvE93VcjI462RBJbvoFO3sljO4o= Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-9b281a2aa94so106178666b.2 for ; Tue, 03 Oct 2023 01:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696322998; x=1696927798; darn=kvack.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=pzE5xIY9db8TFTSfQEFd8Qvir/f9uboJ9HiAoVcZHsg2fmO0CPRTFoiwCqGgYRMGT/ dKPi6tUwBZk4J1d1AMtt2dXqjGpxVHX/2dakrjuf0AgH99oxQ4RnhXzpIxNXacEPS0kX QJwkwA0XKKdqM4B7SOOdRkj0LSRlYumS6l+62YFhVrvLo4bcq1B7upotbru/HqZDoC1n 9dvWz996oOv8sAraDtSzkHZdnYQ6LuHVK65WIJkR+TxojzAD3z9iJwz2JAki2+jJugZG 2zQQNJrKhyGesuBJGCrIPix5o3IRdudsZX1sSv/WUCrscL6v0Z54+QGHvZ+XD7Ll0iZr DnuQ== 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=UaSQP9lt/Z0RXIwY4NBT6C0//5uwS1C0F8MJn3zqr1wssdA3R778I4zuOBMPyDgx3i AG4TmwlWGWS0CPlcZWnKQRNPhCqoIx3tNuGTUkIBDDGz6iVMMw367UotgY2Jz28muavg HazzU8Y9eG8f/pQqJcs5tfXTN+jQbaMlb0IkNIKk+WaD3OheW0KzntrChOzuWnuwPdP2 XsOu/xNl4DCF5hnZztz4DoGDf5+H//Bek2dVk23zpe7P+Juxrx9JuInYk6AotTcvGmbL PwyWS1SnZptUVvk8rWib8zXsmVgiRYFvJ4IdsKXvDn1iewlWW3+XFSXmu46A/1byV/a4 52Cg== X-Gm-Message-State: AOJu0YyXhbRzqB7cnNPAQNg3/nzVrHUhscElCaMF5Je06yh4coiJswfO 6GYipAdHXdvdXUnkKdZkVIsHmJE9XSvSf7XocW0XcA== X-Google-Smtp-Source: AGHT+IE/rRUq2nOuhn7JqQ2cqMxNW59rUeB4tBcbgslLSABRUEhuhdcBREiy64prQ88LyzMxrnIQeWLA6K/I8PudtWQ= 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 54F1F180010 X-Stat-Signature: qh3w551eomh4tijn4567cpn9awork7n1 X-HE-Tag: 1696322999-571344 X-HE-Meta: U2FsdGVkX1/1olOsQCmoXdyfaoUo4Jmlz8+KQ1hhtb2x4Wp3FmwFVKfn7eTcMd7C3XFTNR7A5ASmKmueaNjbc3+lBafzm+qpsl1NRLYjX3voOTOphba5BqaO/UKmR5Z26WIhG94TlVO07n04IZ8qgxzvrB39xaiovN7SwNsqPu+9idLdmUnPYoBavyhR3GolSYevl6q7FkWMMd0nq/le2xIchxY+uhSFtF3eHipEKfG0voxZ/3+X08/0QB9ZujcxVipmBW04L7PifiOgx9GisOufjG5gx7mkFycBb3qSr2FPAWs0BA7ZTKhUfjtmWzBmOS+T6w12I+Zmvu+4t84WsfTNE37WrA8coff7lV9x8qu+UaaVvMSpNunWepLkmgyEY2H16TC0aKwB68yJVFMHz+vUpyq5Rap3B/Y7ZZHGq1kHlSCAuFaEjP6AlukPNWF7SXSuntCIMk214u2ZLmF96njnyez6JWWb3Spk29YSzbVvtMZGwQXZf5542WqHRyciLhrGKLwDvvW7hSpXbImDCoH/QCVVxtcrrJnYbQqCxvq214Zmd8xzdZIYFlGPj/yG33NS/hJfnGnc2xOBCu8Ak51Za9HqvtGFs9fRiYBdwNWOMUfd5qhDEDJIzO2IzTLZopr36nqnVQVSt3UPVUTyb16C1t3IKFV8IUc3HHw7q0RwGF0v9XUddKQ0wK6DG9KKJy+dRZ2Uy/IhO3HyS4GaRYh3fNhfyg8ozTDhGgzki0DtX5aH1W0FdJoxoIjkQzcsBnGgvnd/+AG3JgdYrCFcWLjTUbI5Po4SjLrTqGHtUaPvUHwUjj6Dx6CoUX3vHeEHx3Nb2CCwuJCzj/fkhSes2YRktPncgOvVM9Ya4BWVGJhM4yWUAbBNlz+izvT155yHR7jsG5OElHdDqvpij2fRrf89JkD1R9EOw5+hIUKlG2enMM4/Zg7XmoIAMLKeHPtdwnRZSDV7wieVs1U88C2 bkvcZbt9 g7ga88TfuZ4jw8p2RZsdLHycKAlHaepiDri2cuNI4StC3EkFI+4Kqh+t/5eC3dwu8E9UDEJdzr7e9XaKJfKQ8572bVdr43zeMnSHrUeL2rKGdLkvanxQJMr73yXkp2L2xUw2XvEGBxjZgQbjlHqjDeBRba8oxpoOZH8zKSfOAHGbOQCvcovduWie78HIbl0s8/eM3gtwtrCFRz0j54EgYW6OEpuzfYw1U7RVYdJzSPeq+4a08eROtPVqZ5/EcOPU5yw9zt3AiC8rWXT+U86zDBSzq5Fe9Fjw5E7AmLo+jgIwcpcj4xi6d0nxU3afVzOE1kCcV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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