Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1344577rdg; Fri, 11 Aug 2023 19:56:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOKagu2Xf1IWYpJnr9vYbgy6cGbmR4+NuRNeal29ktWHHSQGZYZfmkwaMRps4RVl4fJLMv X-Received: by 2002:a05:6358:260b:b0:134:c37f:4b63 with SMTP id l11-20020a056358260b00b00134c37f4b63mr3308475rwc.2.1691808982959; Fri, 11 Aug 2023 19:56:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691808982; cv=none; d=google.com; s=arc-20160816; b=gHu5ZhD1XjVVU/b7um8xGW3nRhe1SlVdlR1/3X8EqOQCbvK4CAmlEIOwJprH87HcIV gSa3VvmoTq2rxIQ+cB+QnTGdwaJ0CVn3sTUN0YPUb0dutj8CClLJd5wc6JskRXOjFfcb 2283BTM6p8kpIIPezSyJigERYTGvkS2XYONzDeoKa5JSGxzE2RV4R8IVUJ7iB3LWCOTd SIZwL+tLyK/sUL/R3ktzAUGgUDl6il+3nzkqko2r19pn8+w4q/f8FhF5mTU7eB0DAIZY t4c5ddo0Tdjg1y7Jw6hNrBHoT7DNvhgOYna0ZbhbJFsavRYoc9quaOBPSmge/i46ei1O JLSQ== 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=prshbHi/RKP0L2cqyUY4iqu/u7CuqG4ghac599t9a+c=; fh=uQesB/j4nsyQIz1s1DkkWFTcwvH9YycPQtP2zp2PfZw=; b=T6V1OsK+HkaSMBXj9BTRjJAPvNGTGEarDszRCCF2RiqFMyLPDchFwWudvZPxflix4v fka8PVy9xlSl8wiay4RHVkKYDCA2/VeMmt53yGpIS4NkaI5RbldRohvTuqSyxf3kyKwI mSpMar+xaUb47PWRUITPM3igp1Fvxr1FtzGjn2thFPWEYqo/FKQe5eEFvZdTwe0U/JmW j5xM4ZwPxlqO7d1egqlaBTH+9MTFD2tjCHYkAd8eZEQTxCcDNrLZ9c6u+JqM+5YZRBuI gFdE5qKWCkjLV3KLJ4PD6I9axhF62/PxFygUvE1AMEi8QCKALl66TnJsFJHrXfbjbbB2 pFwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ReRx55kH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a056a00229100b0068131db9c6esi4411117pfe.138.2023.08.11.19.56.11; Fri, 11 Aug 2023 19:56:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ReRx55kH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235078AbjHLCIe (ORCPT + 99 others); Fri, 11 Aug 2023 22:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbjHLCId (ORCPT ); Fri, 11 Aug 2023 22:08:33 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DF230F8 for ; Fri, 11 Aug 2023 19:08:32 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-4036bd4fff1so75981cf.0 for ; Fri, 11 Aug 2023 19:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691806112; x=1692410912; 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=prshbHi/RKP0L2cqyUY4iqu/u7CuqG4ghac599t9a+c=; b=ReRx55kHOx8AyhNaCNICBO3aB+8MDPDoP1bHhZkVlrgxynlOIcCOUhQLwCn8BDNYw3 0Of4nqaCvFFX3F9rwMrq/poL70+DBi+ykgx6RuCSdq3EjKthBBGVHNqfNjwWYSiv+1Tm qM/zSvWaQg+U7H6Ln56hYIedt/nmux/3RJNo1V3dI2YA7SqezrOIdhIRDftNhBjkSSZ4 UqwMWgmQVLAuevHN83O6259kWMIvzy5lvJqosQDVH3JxJ/rEPkCzbwCaPV47rX/TTX97 glAcCit60db6/4eMR1hdiWSeq05x2fPt9Hg4Y46oEShGuTdMYhUeSHcV4dpLtBd+aeiB IgFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691806112; x=1692410912; 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=prshbHi/RKP0L2cqyUY4iqu/u7CuqG4ghac599t9a+c=; b=f2t56KOWPMxZ9Uvr9ayqlaicLNHxnUrXiuhUe/EXSAfEQQ4DGjqPlDh0pTLDYdeRJ3 nSLtXYURkcgckbG6VQ5S7xxuQkRJD5V30IrB3vESxG2w54iUN96viIhzAAT9rZXZtDUd 2kOIpSV8JR73YGjl7tFGHovYTR+aAlQXXa/80ZIkGbJ9LZWyPhqa29tjxMnVYitB+IJW vngrscTziYwukkFLIJzy3eVGCYE6KYme+UghiIADzA88z7nyCSu928RCR3MoQl21BWHa hS1jZimMvwSkXNQltW8vecPC+3/nIaQd49yX8BLIbTKIjHHLqi3OBS8wWxwqUKiVHTDP j4/g== X-Gm-Message-State: AOJu0Ywymf5s5nvgKEhMnmbU2XhMleVXL0QMLX3RL6B96E0m5UJWn5Jk WI7o0YXshMuAticHEItuCY6E4GxCwldo3a6PvwZ6Yg== X-Received: by 2002:ac8:5841:0:b0:3f8:e0a:3e66 with SMTP id h1-20020ac85841000000b003f80e0a3e66mr328551qth.3.1691806111827; Fri, 11 Aug 2023 19:08:31 -0700 (PDT) MIME-Version: 1.0 References: <20230809045810.1659356-1-yosryahmed@google.com> In-Reply-To: From: Shakeel Butt Date: Fri, 11 Aug 2023 19:08:19 -0700 Message-ID: Subject: Re: [PATCH] mm: memcg: provide accurate stats for userspace reads To: Yosry Ahmed Cc: Michal Hocko , Johannes Weiner , Roman Gushchin , Andrew Morton , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.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_BLOCKED,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 Hi all, (sorry for late response as I was away) On Fri, Aug 11, 2023 at 1:40=E2=80=AFPM Yosry Ahmed = wrote: > [...] > > > > > > > > Last note, for /proc/vmstat we have /proc/sys/vm/stat_refresh to tr= igger > > > > an explicit refresh. For those users who really need more accurate > > > > numbers we might consider interface like that. Or allow to write to= stat > > > > file and do that in the write handler. > > > > > > This wouldn't be my first option, but if that's the only way to get > > > accurate stats I'll take it. > > > > To be honest, this would be my preferable option because of 2 reasons. > > a) we do not want to guarantee to much on the precision front because > > that would just makes maintainability much more harder with different > > people having a different opinion of how much precision is enough and b= ) > > it makes the more rare (need precise) case the special case rather than > > the default. > > How about we go with the proposed approach in this patch (or the mutex > approach as it's much cleaner), and if someone complains about slow > reads we revert the change and introduce the refresh API? We might > just get away with making all reads accurate and avoid the hassle of > updating some userspace readers to do write-then-read. We don't know > for sure that something will regress. > > What do you think? Actually I am with Michal on this one. As I see multiple regression reports for reading the stats, I am inclined towards rate limiting the sync stats flushing from user readable interfaces (through mem_cgroup_flush_stats_ratelimited()) and providing a separate interface as suggested by Michal to explicitly flush the stats for users ok with the cost. Since we flush the stats every 2 seconds, most of the users should be fine and the users who care about accuracy can pay for it.