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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F03EEC6FD1D for ; Thu, 30 Mar 2023 07:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbjC3Hut (ORCPT ); Thu, 30 Mar 2023 03:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbjC3Hug (ORCPT ); Thu, 30 Mar 2023 03:50:36 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71CF7729F; Thu, 30 Mar 2023 00:50:34 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 30E7521B0B; Thu, 30 Mar 2023 07:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1680162633; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGBp2CerBGhZkbj2lQ/nRIhr24DsF/TKy5SuxGUse2s=; b=b3sVl6y3RurKw8ub7GVYytEfZjv5e7tMzMkxjEqStKlRW0eN196yPTxmsd1WQnppK3lR2a 3NkEc1GikBqDkQ15fxo+RIJ32ywlsW/Ov47iO6zepuLhLcfl+ULGBtWgO2G+gx33rfB5vD g8jsOgtw5SluPqSGCIX1kHrMPP4REtI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0D874138FF; Thu, 30 Mar 2023 07:50:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IdIAAUk/JWRYAwAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:50:33 +0000 Date: Thu, 30 Mar 2023 09:50:32 +0200 From: Michal Hocko To: Yosry Ahmed Cc: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Michal =?iso-8859-1?Q?Koutn=FD?= , Vasily Averin , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org Subject: Re: [PATCH v2 7/9] workingset: memcg: sleep when flushing stats in workingset_refault() Message-ID: References: <20230328221644.803272-1-yosryahmed@google.com> <20230328221644.803272-8-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu 30-03-23 00:42:36, Yosry Ahmed wrote: > On Thu, Mar 30, 2023 at 12:39 AM Michal Hocko wrote: > > > > On Tue 28-03-23 22:16:42, Yosry Ahmed wrote: > > > In workingset_refault(), we call > > > mem_cgroup_flush_stats_atomic_ratelimited() to flush stats within an > > > RCU read section and with sleeping disallowed. Move the call above > > > the RCU read section and allow sleeping to avoid unnecessarily > > > performing a lot of work without sleeping. > > > > Could you say few words why the flushing is done before counters are > > updated rather than after (the RCU section)? > > It's not about the counters that are updated, it's about the counters > that we read. Stats readers do a flush first to read accurate stats. > We flush before a read, not after an update. Right you are, my bad I have misread the intention here. Acked-by: Michal Hocko -- Michal Hocko SUSE Labs