Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6341083rwd; Mon, 19 Jun 2023 06:05:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IW6fZNYevG036QM4y+1F2WbRVAqHy8F7dw+FFtTEB5dmIscZQ7RB27CmByo4kceqKv+9h X-Received: by 2002:a05:6870:a8a9:b0:19a:2a97:2755 with SMTP id eb41-20020a056870a8a900b0019a2a972755mr7162679oab.3.1687179925841; Mon, 19 Jun 2023 06:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687179925; cv=none; d=google.com; s=arc-20160816; b=BOTVHZjk08TdYi7+BjBsvGG3HHNXnR+02JeTLwP9lT2h9VooHzA03lLVQ4Uatber7G tvsx9KHf/e8phJhiEktTnBW8pcuxyP43/Gize/ozOMhktKssCheNjmSI1pm/NAVE6h3W nMtXXHVehxatlblBrh9T+8XAE6bhGSeYyg78j4bzouWgimwDTrJo1hDBAi5Nk1jPDpAx HzEkvjWw8nOQF5TcaL5y8UyEJsa/DrbDp/QegxnuVbnXjFpIZHMYYSLEkk57KVV3B9Zd THIDdKMbC631HfXIe/6L7c6fu1JeOXr3cCETk4jrUhFNRmdm8DhhDXkQbSQV5hUYXuro R59A== 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=TWxie6xDnsp1m4eMpouDH4sytcFkAlnBkBDPnEaF0No=; b=syhwThKuWcQa5Fk46ExdZWAnixLUevqMIxIL6vkGh/mFYzexPlWbwqdPe2p4IkpOv+ htlP3Tf3m9wRzjqZiu80+KshcGtJn0XHNmu37YgP4G+X9o4OTUySXUuwr2Kp47pgU+rT FW+5lV2RDXulLZmSqsdplijWoiqQmba3/hYHgFO6Ao8G3o/SnSVuoewkgtS+n/LYIQWP OwbuR+dvQkbrCWHG3oh6ByZXitxqy/YWsOIL71S204ePdaDVFfBQavjqfwvZqbeo2XC5 jmt2NZDCEqOSYunUFLQHG6AG0sCyzGJObdPM+nelWnDGVv4hyI7KRWu6JoXUezXo5/ZU K7aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=m2bVWXlQ; 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 v3-20020a655c43000000b00543ef0f981asi6198655pgr.631.2023.06.19.06.05.06; Mon, 19 Jun 2023 06:05:25 -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=m2bVWXlQ; 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 S229711AbjFSMxn (ORCPT + 99 others); Mon, 19 Jun 2023 08:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbjFSMxb (ORCPT ); Mon, 19 Jun 2023 08:53:31 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7DA21718 for ; Mon, 19 Jun 2023 05:53:16 -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 5F85F21870; Mon, 19 Jun 2023 12:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1687179195; 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=TWxie6xDnsp1m4eMpouDH4sytcFkAlnBkBDPnEaF0No=; b=m2bVWXlQZgk6+wOdr7GV8Sc7ePwkqtTVf5DFMDJKS5z2oZEeVpWvmTs1GEWsadVh3SEgki Gh+GBKVYadAbvSk1nCNKzgmS3t0bzEzMMDhX3RF0vx4OeuiYoKXEeICpGddoEjThLI7pH9 FkYDg/CY9+qg4nE6Mhjg1RgnDnGymic= 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 1BFC6139C2; Mon, 19 Jun 2023 12:53:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id T2MIBrtPkGTjewAAMHmgww (envelope-from ); Mon, 19 Jun 2023 12:53:15 +0000 Date: Mon, 19 Jun 2023 14:53:13 +0200 From: Michal =?utf-8?Q?Koutn=C3=BD?= To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christian Brauner , Suren Baghdasaryan , "Liam R . Howlett" , Mike Christie , Mathieu Desnoyers , Peter Zijlstra , Nicholas Piggin , Andrei Vagin , Shakeel Butt , Adam Majer , Jan Kara , Michal Hocko Subject: Re: [PATCH] mm: Sync percpu mm RSS counters before querying Message-ID: References: <20230616180718.17725-1-mkoutny@suse.com> <20230616123144.bd2a8120dab25736c5c37297@linux-foundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="26gv2xzmhvqwhdqa" Content-Disposition: inline In-Reply-To: <20230616123144.bd2a8120dab25736c5c37297@linux-foundation.org> 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 --26gv2xzmhvqwhdqa Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 16, 2023 at 12:31:44PM -0700, Andrew Morton wrote: > On Fri, 16 Jun 2023 20:07:18 +0200 Michal Koutn=FD wro= te: >=20 > > An issue was observed with stats collected in struct rusage on ppc64le > > with 64kB pages. The percpu counters use batching with > > percpu_counter_batch =3D max(32, nr*2) # in PAGE_SIZE > > i.e. with larger pages but similar RSS consumption (bytes), there'll be > > less flushes and error more noticeable. >=20 > A fully detailed description of the issue would be helpful. Obviously > "inaccuracy", but how bad? Any reader of get_mm_counter() could see the inaccuracy given by the formula. In this particular case it is detected by a testsuite of time(1) utility that feeds from rusage: > FAIL: tests/time-max-rss > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > time(1) failed to detect 5MB allcoation. > mem-baseline(kb): 0 > mem-5MB(kb): 4096 > delta(kb): 4096 > FAIL tests/time-max-rss.sh (exit status: 1) (i.e. 1MB missing) > Far too large to be inlined! For six callsites it adds 1kb of text. Ah, thanks, I can change that. > Why even modify the counter? Can't be > addressed by using percpu_counter_sum() in an appropriate place? I considered modifying get_mm_counter(), however, I decided not to put the per-cpu summing there as it'd incur the impact to many more places than sync_mm_rss(). > For unknown reasons percpu_counter_set() uses for_each_possible_cpu().=20 > Probably just a mistake - percpu_counters are hotplug-aware and > for_each_online_cpu should suffice. Yeah, that could be cleaned up in another patch (cf mask in __percpu_counter_sum). > I'm really not liking percpu_counter_set(). It's only safe in > situations where the caller knows that no other CPU can be modifying > the counter. I wonder if all the callers know that. I admit I only considered the do_exit() path (and even that isn't granted in a multithreaded process) -- so I don't like percpu_counter_set() in this current form neither. I will need to review effects of parallel updates more. Thanks, Michal --26gv2xzmhvqwhdqa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQQpEWyjXuwGT2dDBqAGvrMr/1gcjgUCZJBPtwAKCRAGvrMr/1gc jg7VAPwIjhi8mrzDBAOTstul/NetJ03zstiAaJYdid1vFqMbLgEAqmxlGTO1lvUR ys7xfUBwhMhNzEfzR/eXT5WpuiwVLw0= =J8jf -----END PGP SIGNATURE----- --26gv2xzmhvqwhdqa--