Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3735504pxm; Tue, 1 Mar 2022 04:36:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9pORds6jNx9ghIcVrJAKapnerxLY2NoFu+jk+9S9smc4f4lnmKFOHj98iH6V9K7SheNGe X-Received: by 2002:a17:906:199a:b0:6d1:aa59:2927 with SMTP id g26-20020a170906199a00b006d1aa592927mr18192826ejd.215.1646138162247; Tue, 01 Mar 2022 04:36:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646138162; cv=none; d=google.com; s=arc-20160816; b=tyaflyjytOpf/VSawNdH/KRlDqzzvJml9mTbUWf5dyI2haw5Ax2M7jhmDfYWrS9MJm 2shcI+sfXx0HDhvQz8N4VwqLZ+l+jm4qPOchMJ+jcAzaKSThgIbO8a4XFyHv5MJzvLTM H4N6OsCp247gMmzuEOE22U8SYvZnJbYUf5DQ0Xoc5KSUxgoXa8FSz08UBU0H9qMs9dCQ 01uQAiV5SM58y//y31T+4DRE2YIqfhh0BmEn8MVs3TzTdb9meHWccNSyqGX1TnVLMamD CJOASS/ZifCcYP/uBSKtNDmk98PVyJElieHWshHyz3h0cefb3tVLq/JAZkSPKZOjhpnu zeZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wGg057MYVvEAycP3sfZdyFUbrSVStkSu0yUPk3uN7Bk=; b=BoGJovZqUH6lCP5oftOXqWLW6YiUOZCXgtNik0dOBm18d/rcBpHxqOCBtGyLkdsRaQ aTvMoN1knToj1yK2YJ5/AJVshYgxVMJ2+5ISNvBeA0zBfaBAiaLtak+OKvvSHQok1cdm nBUqZUyCrSkYKsM09bmu99BvG0b5FNbR1LMit0Og6jMDH5Emfheori/8cRqLD2MMJHji t4DXluKRzu/b2UWAPznpBW6mawGYqnrKgw1UK5xz0ixp9x590cqPozIID0WXguK/v6Sq oWE9BAE2KAoISJ7JLZgzBHd9Df+SJ2TAIMC+6EMeU/AG7nirKd9XaVsfw5lGRdzYVZ/6 QrnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PJoZmxdW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a056402070100b0040fd71fbde0si8209094edx.398.2022.03.01.04.35.39; Tue, 01 Mar 2022 04:36:02 -0800 (PST) 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=@suse.com header.s=susede1 header.b=PJoZmxdW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233470AbiCAJGX (ORCPT + 99 others); Tue, 1 Mar 2022 04:06:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbiCAJGT (ORCPT ); Tue, 1 Mar 2022 04:06:19 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 290C289319; Tue, 1 Mar 2022 01:05:38 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B84BD21637; Tue, 1 Mar 2022 09:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1646125536; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wGg057MYVvEAycP3sfZdyFUbrSVStkSu0yUPk3uN7Bk=; b=PJoZmxdWQDxzOd6JDIbAkU3p3tENb3df9iSpKNeHZYe93Q99vfTMJarHj+aETJi22OlE5Q efK+c6N9PbE136rXo1pky4rH41gSHXh2m7J9RwIyMmRpO8MczpWn87pP2o6nC4Fl5P54lt Me2wF3cUpDucfbZcglIKYCU5DXTsEoQ= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 76159A3B88; Tue, 1 Mar 2022 09:05:36 +0000 (UTC) Date: Tue, 1 Mar 2022 10:05:35 +0100 From: Michal Hocko To: Shakeel Butt Cc: Michal =?iso-8859-1?Q?Koutn=FD?= , Johannes Weiner , Roman Gushchin , Ivan Babrou , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Daniel Dao , stable@vger.kernel.org Subject: Re: [PATCH] memcg: async flush memcg stats from perf sensitive codepaths Message-ID: References: <20220226002412.113819-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220226002412.113819-1-shakeelb@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Fri 25-02-22 16:24:12, 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. > > The easiest fix for now is for performance critical codepaths trigger > the rstat flush asynchronously. This patch converts the refault codepath > to use async rstat flush. In addition, this patch has premptively > converted mem_cgroup_wb_stats and shrink_node to also use the async > rstat flush as they may also similar performance regressions. Why do we need to trigger flushing in the first place from those paths. Later in the thread you are saying there is a regular flushing done every 2 seconds. What would happen if these paths didn't flush at all? Also please note that WQ context can be overwhelmed by other work so these flushes can happen much much later. So in other words why does async work (that can happen at any time without any control) make more sense than no flushing? -- Michal Hocko SUSE Labs