Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1626539rdh; Mon, 25 Sep 2023 20:41:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfsJcmt1H8uge6BMicGKuUGZqNcTRN9HAl1zl3eH8DmO+aT3LKygNOmImybxLsEm0KzA6S X-Received: by 2002:a05:6a20:918a:b0:15e:d84:1c66 with SMTP id v10-20020a056a20918a00b0015e0d841c66mr8029336pzd.52.1695699704249; Mon, 25 Sep 2023 20:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695699704; cv=none; d=google.com; s=arc-20160816; b=IquenXz6pSFpmKv/8oS3TCrRd5zValazPKPcsQA6BT3hiDPvvWlFFZ28/eLkfEGJih vq1Jd78LKjHu+KNEmLufBXTqG7dWYOfPuriMpHQ7axhAh/8/72N4jaDLfv3W+Qm6uYzP DfBjGyBsOdtFkLhNvGNyj1mhXCM8kSHcQxGIF6rz7hGOKw6qqJsz30DmXXZQD1qjVsHG 7lYOJGGuwv1xoGxls6Ga9qOqJ6cr1haVvQQIMrZA26VyJuJBDlC2e97nnr/OwyG7wE1U hHmxwdZPh17UKtdr27OzX1Z9LLdn935MiusznNAPBN3hpGYT/3VO2E6wUVqcx5CdKiuN 6Omg== 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=g/hhWT30YqLg2rKDYw/SVPqxcdoluiD8cyVoB8LNRKU=; fh=cY5dfcZV64K0FB0quy6f145p5/9DqQXtZ7RpORdWNrQ=; b=wN2abmi8M86QRMhMzjFfDgJOrUpKM6xH2TR+0qHhunlhhVBZIjCexlB2L+Ww34NA0R U4m0ZazQikq6q/nq63fzA1U8b53xzBDahi0yKni/7U03c5MhORzSNgcWIW72McLcwn5z q9fhExUXXMxPRuvm74hw7dImdI4SuqXN5wEp3HeHy5m7dvOmguBOiF/ATR40VXaoNfWR 9G0twIQRSsDe/8De8jTTs6TvhInv+2+ogARKhOBeDu8TVV/yzH3BLpe/RykUsliJCkk7 rB3iOuvz9Yn8dFHAfMGlKjT4ILBBrqoLY/2SspXy1m+AlQHw5PI4O1pcRkmaDULzmCiJ IDig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BhbFLIYh; 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 q15-20020a170902dacf00b001bbb56b34e4si12469135plx.331.2023.09.25.20.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 20:41:44 -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=BhbFLIYh; 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 090FB809D32F; Mon, 25 Sep 2023 10:12:03 -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 S233065AbjIYRL7 (ORCPT + 99 others); Mon, 25 Sep 2023 13:11:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232957AbjIYRL5 (ORCPT ); Mon, 25 Sep 2023 13:11:57 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 045CE11D for ; Mon, 25 Sep 2023 10:11:46 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9ae2cc4d17eso864139166b.1 for ; Mon, 25 Sep 2023 10:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695661904; x=1696266704; 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=g/hhWT30YqLg2rKDYw/SVPqxcdoluiD8cyVoB8LNRKU=; b=BhbFLIYhbToxGSyNhmIR8RyXG8uDpP3SL/ihsVdl2fCTdoC/u3JkUu3jFcM8J9LOVR D0IwmB8UB5VHnsFDTQ/cmCpvDwBTgJYK0ZhOno12xXmA8s+MK6OPB5D848e5PNSElx+Y ptjSZDGTj7fx91tqgAz2vP1Di68wx5SYSOb/4blCBoY2M1w5lHoYqTQtvPHuolmbHfw1 BIApqzBaC/dLNjPS4UWVoNmjwOW7XC8tZjQj3Or/ADiCk/S5wezNBFfMEPRQqDu35vL0 mxxfPQpvZCylecGQZi+WKUyq2/9L+Tp6TVjNMwE+h50ji7lwrUuLuDKFIsetsQ90Me+e nADg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695661904; x=1696266704; 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=g/hhWT30YqLg2rKDYw/SVPqxcdoluiD8cyVoB8LNRKU=; b=XvWHFr9Kc14E0ik/WXtaQ931daE1NmSpcfOUOaQw7xpB07JrcdTPwJqGmuIBTOc2Ko MEa5R0Sx70TZhLGISjKIH9ml/4dPVrPgmla9c0J7EdlgJRvt03uTDHJy6/sOqbb+MAGw gT4P76Aw5Ewo46OPru0FN2WZMvlh1im4wudS6N10blfzIhmbyDrwqnx329ah42jlqpyY CmYdaYX8eTPvUr74qew3dFcNAnysvwqYStfiSWP8ycjwCwU1up1kq17ZY/EeVvyNpEKN qrRmzKEjsWr+UpRuIJaVecnfGucGa3LxEmm3pWXh/te5Nlqg4uZ+hFh2cFwVcOybyTRy jipg== X-Gm-Message-State: AOJu0YzAwSmyC2peESGJAvNPliPJe4AnustwTQS8J/xGRbUzg7Jv/P35 UwsQDlbL5fAM8rOs/h9qfvVmmJUPeW/EIW1HYhaLmw== X-Received: by 2002:a17:906:25d:b0:9ae:587a:e5ce with SMTP id 29-20020a170906025d00b009ae587ae5cemr7423657ejl.27.1695661904205; Mon, 25 Sep 2023 10:11:44 -0700 (PDT) MIME-Version: 1.0 References: <20230922175741.635002-1-yosryahmed@google.com> In-Reply-To: From: Yosry Ahmed Date: Mon, 25 Sep 2023 10:11:05 -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 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]); Mon, 25 Sep 2023 10:12:03 -0700 (PDT) On Mon, Sep 25, 2023 at 6:50=E2=80=AFAM Michal Hocko wrot= e: > > 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 pending > > updates is consistent. It is mostly in pages, but sometimes it can be i= n > > 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. > > > Patch 1 reworks memcg_page_state_unit() so that we can reuse it in patc= h > > 2 to check and normalize the units of state updates. > > > > [1]https://lore.kernel.org/lkml/20230921081057.3440885-1-yosryahmed@goo= gle.com/ > > > > v1 -> v2: > > - Rebased on top of mm-unstable. > > > > Yosry Ahmed (2): > > mm: memcg: refactor page state unit helpers > > mm: memcg: normalize the value passed into memcg_rstat_updated() > > > > mm/memcontrol.c | 64 +++++++++++++++++++++++++++++++++++++++---------- > > 1 file changed, 51 insertions(+), 13 deletions(-) > > > > -- > > 2.42.0.515.g380fc7ccd1-goog > > -- > Michal Hocko > SUSE Labs