Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6259957rwl; Tue, 4 Apr 2023 09:54:00 -0700 (PDT) X-Google-Smtp-Source: AKy350aR1ukAiPj6+F2+kB2YHLsLiGQp//fqIKkTwtnM7lPh55W2WE/ibjgWK2IuBgwtLOvuNW7L X-Received: by 2002:a17:906:d7b8:b0:947:6ce9:705d with SMTP id pk24-20020a170906d7b800b009476ce9705dmr208086ejb.55.1680627240442; Tue, 04 Apr 2023 09:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680627240; cv=none; d=google.com; s=arc-20160816; b=kRC+DeiGmiUIjpkg0zs/YBrutjkhQEsY8oQSMsx7LEoZ2aFRBvIA657JLDBMak2UvU 1btGEVoACzUCdu5bLQ56VUbZqvyei75jpi9YBdX689RgZQ8OtNVm3hft2PhGSPeQkh08 8hUevjFlR87C421b19jhOB9uijwA3x5rq/Bs7wIVKCqg+SkN1ucfK+hGhUY8dQKOY0Hh 10ZMJVOiXpIudb2GQz01gKdAHH64j8LwJ+9x7sk1FIkwCtkRST43oWHtTDKBDJd9MZlY 2gkFPR3mO4AgZAnyQoLP5p5A9xP8UcgNNx3TEe32aGAJiHIZC4AMnd0pt5zblkRgn04Z jxIA== 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=J++lSR0qBN+0TGvxu6lzekTohutLNFEkeNAdPcqtrMc=; b=aNouxCAraV+TF72S8Q0Fj+j7hUxpGP1jDktD/65I1CYu+3G/Ef1KgHOlD6A12COWAk D9XWOk7gfnzzBt0nfUbNlwIO2rBzOUCRhNtXioNJ8O0VfAakXMBWS3THPwARYFZr5dsT 4s266QwvtNsA1vZxX/LTLBHpHJyO13ZvtFfsjCqlCXT+U7oOJRJu6LfFYJ32GNWzCqbU Qsw6ag5QPoXF7baZjpWn70xJ5KOLfDKS9gSoTmB9vAAjAjR9mqHlS6Y5ngXEabVjDu1b TpDGB9hPM3b8yOUSZyv1+Twu+3YAa6vFkm9eo8J8bwgVAWHSKPY68yycKyN2SyRsKL4J 3ZbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=qOluMdxP; 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 g23-20020a17090670d700b009227ddac2b7si10587902ejk.434.2023.04.04.09.53.36; Tue, 04 Apr 2023 09:54:00 -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=@suse.com header.s=susede1 header.b=qOluMdxP; 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 S233701AbjDDQxW (ORCPT + 99 others); Tue, 4 Apr 2023 12:53:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233879AbjDDQxP (ORCPT ); Tue, 4 Apr 2023 12:53:15 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1594C18; Tue, 4 Apr 2023 09:53:02 -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-out2.suse.de (Postfix) with ESMTPS id AA1C52068A; Tue, 4 Apr 2023 16:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1680627180; 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=J++lSR0qBN+0TGvxu6lzekTohutLNFEkeNAdPcqtrMc=; b=qOluMdxPHhvtFQLCFpQe1/5GzQwfB/aZnibvtGxy2cJj/GyfWJ5wH4U5vkOgOM4tLtt1Nu Zvy2ZDtEOpyTBqcaT3xmplxiRScoHOSM7b0DIGYzfo+dy8TIFtXcIJ/kmtMwDURxu6+1hO 2swLdLqT2gFMWpUe1QczgdY8wOiZM5Q= 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 5B2071391A; Tue, 4 Apr 2023 16:53:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MatdFexVLGTJMAAAMHmgww (envelope-from ); Tue, 04 Apr 2023 16:53:00 +0000 Date: Tue, 4 Apr 2023 18:52:58 +0200 From: Michal =?utf-8?Q?Koutn=C3=BD?= To: Yosry Ahmed Cc: Tejun Heo , Josef Bacik , Jens Axboe , Zefan Li , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Vasily Averin , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, Michal Hocko Subject: Re: [PATCH v3 4/8] memcg: replace stats_flush_lock with an atomic Message-ID: <20230404165258.ie6ttxobbmgn62hs@blackpad> References: <20230330191801.1967435-1-yosryahmed@google.com> <20230330191801.1967435-5-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pchdddtux2qbf53z" Content-Disposition: inline In-Reply-To: <20230330191801.1967435-5-yosryahmed@google.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 --pchdddtux2qbf53z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello. On Thu, Mar 30, 2023 at 07:17:57PM +0000, Yosry Ahmed wrote: > static void __mem_cgroup_flush_stats(void) > { > - unsigned long flag; > - > - if (!spin_trylock_irqsave(&stats_flush_lock, flag)) > + /* > + * We always flush the entire tree, so concurrent flushers can just > + * skip. This avoids a thundering herd problem on the rstat global lock > + * from memcg flushers (e.g. reclaim, refault, etc). > + */ > + if (atomic_read(&stats_flush_ongoing) || > + atomic_xchg(&stats_flush_ongoing, 1)) > return; I'm curious about why this instead of if (atomic_xchg(&stats_flush_ongoing, 1)) return; Is that some microarchitectural cleverness? Thanks, Michal --pchdddtux2qbf53z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTrXXag4J0QvXXBmkMkDQmsBEOquQUCZCxV6AAKCRAkDQmsBEOq ucctAP0QF3CXk51W8Pmcc0e8ZfVGikqKVH42APSyMXgCLEw4twD/ajlglQ+6Jt7N Lf+TNXVTCA0s8f9NI8huIwxn6NR+XQc= =Q0r7 -----END PGP SIGNATURE----- --pchdddtux2qbf53z--