Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2053764rdb; Tue, 3 Oct 2023 08:54:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmfNCGbeBz4xgPctEgtdfcVyctDh4gkb43SHh3ZWo0NiTMVCtI8h4KfCcTT5wV/s2xuld/ X-Received: by 2002:a17:90a:d241:b0:26b:4e40:7be8 with SMTP id o1-20020a17090ad24100b0026b4e407be8mr12538135pjw.12.1696348458331; Tue, 03 Oct 2023 08:54:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696348458; cv=none; d=google.com; s=arc-20160816; b=K2xMd615uy6dJxX31+/AzSLGN7SiVZVZgggIb7HVjSyHg4QQHjlABgd+Vkx0H77pda VLFmXJqBs7t1GFhfPnsIQQtGuGNgn7wTlBb99KOxlp94EE8S8qGwoXkAbtM6Mpph/U8b yvm9OdoeS8ZtQ4U7xtne+zE8hHCtyWVAM7pV2GXdlqObfvDUQrOy1CNB1qKPJPBuDmdz 2DdgIlO6q4IDhq8Bxdr7AHO/gGPyTi5EhTuFcy9Qo5E/oRaWacBXANMRT0+FbZxnK0+x mcmB2YkJ8YPrECvpkJvmIBhdb+edLlRky6wmJlkPUJp8/i3k1iYQHUZWnRT86Xd7e06R nCRA== 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=Dxid03xXpcvsVqUaGgfhHGeyo+iLwB2wREvZPzja/s0=; fh=pzPL35PtyysEXzIMdDTvAA1LEVHJnCydVy97ff9spqU=; b=Z0NdEd2m8jNNw34UQpzbop97P740Q4nvWa51p8Is9UvYQP70Qo0Phymdp1HEgBg4fH SDHoDPZTGk9GvcZefOZdoZRhBHyT+UsAu7HMTos5NDBnKcJqwYmYddbOKqDXNq173RZo 1vkL+C2w/sI2SQdhpXvE+sWaQ1MHsYPuvpTd6BljjCDFxod3iA7y3KR5arSrnwgH7LXr JkMTSR+6omQ1g0sfMVAg+KbEfBrpssHfgr2A6kH5jQ6AHf4lGuuABqNfT/izSldwuWlN tPri3ejzb8q3mDWd5bQWyqYRZbu+l7KITsBfPT90LDgP0b52P3sa4kGlGS/E8N82oz97 skjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=s5X5bcF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e11-20020a17090a9a8b00b002773152a294si10294070pjp.80.2023.10.03.08.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 08:54:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=s5X5bcF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 4ED618119043; Tue, 3 Oct 2023 08:54:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231795AbjJCPyK (ORCPT + 99 others); Tue, 3 Oct 2023 11:54:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbjJCPyJ (ORCPT ); Tue, 3 Oct 2023 11:54:09 -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 1E5C0A6 for ; Tue, 3 Oct 2023 08:54:06 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9b281a2aa94so194899766b.2 for ; Tue, 03 Oct 2023 08:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696348444; x=1696953244; 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=Dxid03xXpcvsVqUaGgfhHGeyo+iLwB2wREvZPzja/s0=; b=s5X5bcF5cEwHg2Yt3q4OoOnDir2XIQiefFlREGZPIJteqqnoG1xsM4L0txs5uvPNbG yLj97FglNRXzkhq2IerACzYEWr/wGW952knv0tgnPgXi3prUACrw/0ukzzqHpPNL4PV+ RhRZ7HOe3VzWIEsxI+zpe4cOqFviFWV6c1FL/JQyjP5n6srYw41nCpiELh/9WGSzfm5o wKKp+joUPXM8juR4ni294Jpiz7J6pks4oBRV9oFjYyAHBKpnn/c8z36ZyerALiY7Jb8P uvehRRzTWgE9FRfZyOET94gdiWI2BCD+K/+VaflIWIgctik8DIxi6LgcRWqsndjGT4Bt S0Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696348444; x=1696953244; 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=Dxid03xXpcvsVqUaGgfhHGeyo+iLwB2wREvZPzja/s0=; b=IRdRWswajFistHNVPZ2JUOavYX0AwGHzUYFN4+UeojBSv/OQfc/z4FMb80GTK0P0Uk WlNGk6HA1X/YtqO7YZdBELKBD2b0EEP2hG1K/whlq0czphRcGUEiuWnLGs1R/LQKCqSk ayyvN8ao1PKZgeS0bbrVuC+vuy9VZFt7OWeaxL8spAQY8fxE9siAEEMcCXDazuCP7b6c 8zqTOoXyxAyeeClyqme9CMrmU0UM95dAUFhK460CxcH0vVFuZ5Xxgyq733ye/To5Ik3X /kfwWoIFisNrP8UA/xZjXx5R2YHfSmw467LeoRvgfhgwitx/zcly3KBVg/mgnQ2LvSUj zMiA== X-Gm-Message-State: AOJu0YxapUghFmXiHJvx81CSNo4gziDr/czwUpAxOJFBnkq21sBE52XY Cu6s4pmM/ha4m4wvjzWBIHvAT5pNi/pTD92Vnz76dA== X-Received: by 2002:a17:906:738b:b0:9a2:86a:f9b7 with SMTP id f11-20020a170906738b00b009a2086af9b7mr12235071ejl.59.1696348444408; Tue, 03 Oct 2023 08:54:04 -0700 (PDT) MIME-Version: 1.0 References: <20230922175741.635002-1-yosryahmed@google.com> <20230922175741.635002-3-yosryahmed@google.com> <20231003131309.GD17012@cmpxchg.org> In-Reply-To: <20231003131309.GD17012@cmpxchg.org> From: Yosry Ahmed Date: Tue, 3 Oct 2023 08:53:25 -0700 Message-ID: Subject: Re: [PATCH v2 2/2] mm: memcg: normalize the value passed into memcg_rstat_updated() To: Johannes Weiner Cc: Andrew Morton , Shakeel Butt , Michal Hocko , 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 08:54:16 -0700 (PDT) On Tue, Oct 3, 2023 at 6:13=E2=80=AFAM Johannes Weiner = wrote: > > On Fri, Sep 22, 2023 at 05:57:40PM +0000, Yosry Ahmed wrote: > > memcg_rstat_updated() uses the value of the state update to keep track > > of the magnitude of pending updates, so that we only do a stats flush > > when it's worth the work. Most values passed into memcg_rstat_updated() > > are in pages, however, a few of them are actually in bytes or KBs. > > > > To put this into perspective, a 512 byte slab allocation today would > > look the same as allocating 512 pages. This may result in premature > > flushes, which means unnecessary work and latency. > > Yikes. > > I'm somewhat less concerned about the performance as I am about the > variance in flushing cost that could be quite difficult to pinpoint. > IMO this is a correctness fix and a code cleanup, not a performance > thing. Agreed, the code right now has a subtle mistake. > > > Normalize all the state values passed into memcg_rstat_updated() to > > pages. Round up non-zero sub-page to 1 page, because > > memcg_rstat_updated() ignores 0 page updates. > > > > Fixes: 5b3be698a872 ("memcg: better bounds on the memcg stats updates") > > Signed-off-by: Yosry Ahmed > > Acked-by: Johannes Weiner Thanks for taking a look!