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 51B86C433EF for ; Fri, 4 Mar 2022 18:53:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D806E8D0002; Fri, 4 Mar 2022 13:53:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2FA38D0001; Fri, 4 Mar 2022 13:53:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C45758D0002; Fri, 4 Mar 2022 13:53:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id B615E8D0001 for ; Fri, 4 Mar 2022 13:53:32 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 8A2F3120B06 for ; Fri, 4 Mar 2022 18:53:32 +0000 (UTC) X-FDA: 79207602264.11.7E54136 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by imf19.hostedemail.com (Postfix) with ESMTP id 08D6F1A0028 for ; Fri, 4 Mar 2022 18:53:31 +0000 (UTC) Received: by mail-yb1-f181.google.com with SMTP id b35so18601478ybi.13 for ; Fri, 04 Mar 2022 10:53:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bEOxM9dCTwOgx3v/sybpuLomdOANvZM0pQSflYOHu1w=; b=i652L4F2GnSj5foPdKPemlgr6xx94ua5Ic9XEX8NWr98rE/J8kp3lucWhLtM4AOES3 T9r1sjUabt2iScIDVpUdwI7AvcDZFK6NUnb+i966anXeK79MKuuIqPU7cQfPEN83otOC mKwkhFqmQ0lI9vTrYAN1FaKXTRwQdjLTY1yTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bEOxM9dCTwOgx3v/sybpuLomdOANvZM0pQSflYOHu1w=; b=jYgU5Ouj5Tvea+hZDIM08bf/vF+nsErEO0udeSrHS0U2B3FMXRoW3AsfDgUovrcdXJ cubU2h2MXhHOQOg8XIYwcyfpa/MLCKVpUDyc64tk+1tufxZu3FRKhRStJExciTBqcOsp vpnhsNXser2GqZySt8zG4zfjNzSQEKK/Pb6D3ihezRDLsbAogGI8tGrwHc33GxLUHiCe IAdO/GQId5AZQWLMul5Rq21CYkoOrHFFR4bs+h6TsYiZ94woUKTUiTxyXKrqgSBGv7BK t/b8kPkjwI3EKhtafaDRnehZgUbjufHPSWnJR5aCXcMib/n0jcH7tQCm/DKQIOuV34o6 NSbQ== X-Gm-Message-State: AOAM532+bcooX46EaDNYj2r1+ueYWoddnen6YDhJ8Ox6tjBEHyZaFBcp hJw+tgAVU13bEQwtf4FjKhKeqRzz8P9Ix0G3YHNeiw== X-Google-Smtp-Source: ABdhPJxmeYC7TAv458Sge2scZxXaYjCZnTUCKtizCBToEOesPPQLwrIAjrV205QglSMumtJodE5x7d4SMdWgl+HQSTw= X-Received: by 2002:a25:bc8:0:b0:628:80d9:526c with SMTP id 191-20020a250bc8000000b0062880d9526cmr17661448ybl.115.1646420011206; Fri, 04 Mar 2022 10:53:31 -0800 (PST) MIME-Version: 1.0 References: <20220304184040.1304781-1-shakeelb@google.com> In-Reply-To: <20220304184040.1304781-1-shakeelb@google.com> From: Ivan Babrou Date: Fri, 4 Mar 2022 10:53:20 -0800 Message-ID: Subject: Re: [PATCH] memcg: sync flush only if periodic flush is delayed To: Shakeel Butt Cc: =?UTF-8?Q?Michal_Koutn=C3=BD?= , Johannes Weiner , Michal Hocko , Roman Gushchin , Frank Hofmann , Andrew Morton , cgroups@vger.kernel.org, Linux MM , linux-kernel , Daniel Dao , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 08D6F1A0028 X-Stat-Signature: hi6nxudodwp563sdqd6c3g5xnr7faj5b Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=cloudflare.com header.s=google header.b=i652L4F2; spf=none (imf19.hostedemail.com: domain of ivan@cloudflare.com has no SPF policy when checking 209.85.219.181) smtp.mailfrom=ivan@cloudflare.com; dmarc=pass (policy=reject) header.from=cloudflare.com X-Rspam-User: X-HE-Tag: 1646420011-173950 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Mar 4, 2022 at 10:40 AM Shakeel Butt wrote: > > Daniel Dao has reported [1] a regression on workloads that may trigger > a lot of refaults (anon and file). The underlying issue is that flushing > rstat is expensive. Although rstat flush are batched with (nr_cpus * > MEMCG_BATCH) stat updates, it seems like there are workloads which > genuinely do stat updates larger than batch value within short amount of > time. Since the rstat flush can happen in the performance critical > codepaths like page faults, such workload can suffer greatly. > > This patch fixes this regression by making the rstat flushing > conditional in the performance critical codepaths. More specifically, > the kernel relies on the async periodic rstat flusher to flush the stats > and only if the periodic flusher is delayed by more than twice the > amount of its normal time window then the kernel allows rstat flushing > from the performance critical codepaths. > > Now the question: what are the side-effects of this change? The worst > that can happen is the refault codepath will see 4sec old lruvec stats > and may cause false (or missed) activations of the refaulted page which > may under-or-overestimate the workingset size. Though that is not very > concerning as the kernel can already miss or do false activations. > > There are two more codepaths whose flushing behavior is not changed by > this patch and we may need to come to them in future. One is the > writeback stats used by dirty throttling and second is the deactivation > heuristic in the reclaim. For now keeping an eye on them and if there is > report of regression due to these codepaths, we will reevaluate then. > > Link: https://lore.kernel.org/all/CA+wXwBSyO87ZX5PVwdHm-=dBjZYECGmfnydUicUyrQqndgX2MQ@mail.gmail.com [1] > Fixes: 1f828223b799 ("memcg: flush lruvec stats in the refault") > Signed-off-by: Shakeel Butt > Reported-by: Daniel Dao > Cc: > --- See my testing results here: https://lore.kernel.org/linux-mm/CABWYdi2usrWOnOnmKYYvuFpE=yJmgtq4a7u6FiGJGJkskv+eVQ@mail.gmail.com/ Tested-by: Ivan Babrou