Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1804144rdb; Tue, 3 Oct 2023 01:04:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjuVr1+Nn+aQylzOsaZJzZDA6yfPwm8GzLJgXNSDgXhS+3glPOYeLfSiPdxbqF0wddRn+G X-Received: by 2002:a05:6358:4404:b0:143:3a49:e30d with SMTP id z4-20020a056358440400b001433a49e30dmr14565756rwc.12.1696320296897; Tue, 03 Oct 2023 01:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696320296; cv=none; d=google.com; s=arc-20160816; b=gSK5/+8iu5h+9vs7c876ryfGQ9gvpy+DEgeYKTN+mg6wGL0E5UrAu255NA9VdY8nV1 v0852wHP9H17GmslaYshenmmBLoGGwZUKj2lt/Trjh4Z9QK2VbJMJTfFWg4SBUOlYXrz vTjhIY55/OHoIt6kBi8RZJomeN+mbpP28+TqUiLSEi+ekx7vBHB/YHCXvqSGCtnc0Lp2 /RzhMgi+3XxbpCupw4rrcRNOr9l72Arp7eE5PhLa+iT8jcamvrBN7L8VxBdHquk+3CzF BSoI6DZZ2uVXCMsOw1hn+hMDmWay5EbKWCha/LFA9T1BZXhUQYRf5UYit6t0RnE/VkuE PEZg== 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=FMsF5DJh2guzU9Ha3ynv7ZZbV5goApHMc/5lrWxMlbE=; fh=cY5dfcZV64K0FB0quy6f145p5/9DqQXtZ7RpORdWNrQ=; b=x4XsQIxkN9HbxLDmgdh6rdU23IvsLhCumH90f9Rv3SyyW1k+3BcM5aZUqqTZr8Bes3 LbQzCqOtgUnPtMF38Vj2Pf/gb64Ejkq4DZ81PFVXBEsjKmcdU2KNW7HqfmeRLdCY8ZFw FbsEv6CnEPk0pet/U4IR5qrAyE+PEZzfEWPBWbRbbB08SflA115TeRYidQ9JlK/gN7vD CanuFBwVY+ndP8+29BiQlLs7DA7viN7fnLCeCDM3cWBDF4D8ZMUndq+ssvYxWrJw9rwx fuh2Mdzh/gVxJJkiFcSo4aACWeXyhWYsiMidkraeiBoA9MK+NP4uylWKQk1hmvE+P6a9 Lljw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=q7x1iK1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k10-20020aa788ca000000b0068e47f319d9si1000490pff.280.2023.10.03.01.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:04:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=q7x1iK1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id DF39D801B1B4; Tue, 3 Oct 2023 01:04:49 -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 S231279AbjJCIEj (ORCPT + 99 others); Tue, 3 Oct 2023 04:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbjJCIEh (ORCPT ); Tue, 3 Oct 2023 04:04:37 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C23F7A3 for ; Tue, 3 Oct 2023 01:04:34 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9936b3d0286so100949266b.0 for ; Tue, 03 Oct 2023 01:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696320273; x=1696925073; 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=FMsF5DJh2guzU9Ha3ynv7ZZbV5goApHMc/5lrWxMlbE=; b=q7x1iK1hLx/t0W9PW4b35vi46jw6LKf/wHkuceuRGHJAJa+YN0Ulmv9hbq07dN4kZ8 Qy7Jh7IBBY2XpBDZ7NV2RDmxEPzGHpShtn3n4LokVr05L0n1H1S2ppZdlnozcHK2mT6G U+H/T9SxTinP1KIf0b80LaX7F28UEH8ZsKAGQ1Vra/cXlpjYYX/gPG91SrchhitRd88B jwvmTqkOqn48fZlaEtMPEZhxI9h5aAqH2DUgdWYlQdNfeQo0i+l9ZNSLlkx+SpCfnUVG rEnttUCiTM+WKpnNSOgTLJUP8XARK76xB4WWe10ZqWHMXbJPsvaDIVnmCe9J/L5OLsZA 0TNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696320273; x=1696925073; 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=FMsF5DJh2guzU9Ha3ynv7ZZbV5goApHMc/5lrWxMlbE=; b=d824q4Y3g9NswfCeWehz5uDpw7BmCkIHRj/XyXIQpOoTH3hSbN/oSp5CUXcjikUf6f CLkJ7TJOAb3I8pMYqsJF38Lfr2J85YVDRoA44iwzQTkfkQg4lqLlXqkGRXGdtqF4+rR3 04jek+nx0VjyuDLSM7oDOtaGQbEhh7JBa1uwrxM+NEZKxMhgftDu70Wex5R8YcIKudsv qBxTEQGMukF1Hg7XTjtCmABmvqf+dFNQmGadU7DJwR7FMGSuOl6NEoj1DonbDvsgTSYv sj3slFM68rlJvIha0PqW5MbduWTDl4RGaypGIYDtmrX4e8e4mbyBBVFceHfVudi4+zD3 ojEg== X-Gm-Message-State: AOJu0YyJdqPbIR7J59G0K+MmGOTl8Hi+wWqUtUv4lnGOvUjbqLabsoFg HUE44vw/8+cBNPMLCgns+4Q+si5dQKdGoIMrfu1BGQ== X-Received: by 2002:a17:906:20dd:b0:9ae:729c:f647 with SMTP id c29-20020a17090620dd00b009ae729cf647mr10694745ejc.77.1696320273081; Tue, 03 Oct 2023 01:04:33 -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:03:53 -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=-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 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]); Tue, 03 Oct 2023 01:04:50 -0700 (PDT) On Tue, Oct 3, 2023 at 12:57=E2=80=AFAM Michal Hocko wrot= e: > > 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 pass= ed > > > > into memcg_rstat_updated() to keep track of the magnitude of pendin= g > > > > 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 worth > > > 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 few > > weeks, unnecessary flushes can cause increased global lock contention > > 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 many > > flushes are requested. > > > > On a system with 100 cpus, 25M of stat updates are needed for a flush > > usually, but ~6K of slab/percpu updates will also (mistakenly) cause a > > flush. > > This surely depends on workload and that is understandable. But it would > 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. > -- > Michal Hocko > SUSE Labs