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 54AE2EB64DA for ; Mon, 19 Jun 2023 12:53:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C802C8D0008; Mon, 19 Jun 2023 08:53:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C089A8D0001; Mon, 19 Jun 2023 08:53:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AABE98D0008; Mon, 19 Jun 2023 08:53:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 941CA8D0001 for ; Mon, 19 Jun 2023 08:53:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4C9C9120388 for ; Mon, 19 Jun 2023 12:53:19 +0000 (UTC) X-FDA: 80919488118.15.8B14CA7 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf07.hostedemail.com (Postfix) with ESMTP id 1785E4001B for ; Mon, 19 Jun 2023 12:53:16 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=m2bVWXlQ; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf07.hostedemail.com: domain of mkoutny@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mkoutny@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687179197; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TWxie6xDnsp1m4eMpouDH4sytcFkAlnBkBDPnEaF0No=; b=CNk+M7M5XOC7f0AbSfV7pzQCoSvGWKlrgYtqrzRqO1T6qhcQAt3JpsfjfypwYugUdGSzQe hMIUcth6ZDK2hh5SZi98GlSxzQu+NZKlGsbRfiBVU1z2m2q5GEd+ZuWrQQLkAT2X1bvpxq R1ogRhajDn5m4yLTITEXTJeNzNNT/2g= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=m2bVWXlQ; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf07.hostedemail.com: domain of mkoutny@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mkoutny@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687179197; a=rsa-sha256; cv=none; b=DyV84uhDDFnYTGpkdC/9CP/R1vU8AaGLhRZfFEWium3NDamm8ybn1Pg3Y6OM6mGxnmmICU 8By+VYn0ngqvhezNx6pHY7RwUpPZUIsbsjzxxrLdwtwmiTPVCPvmfTl3McZtKfgdpjus0l 3xAk3nMERbLl5QQfeNC+UxIkKRak7aE= 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-Rspamd-Queue-Id: 1785E4001B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: makcadexkak3b1k6b6bcw3789649y4im X-HE-Tag: 1687179196-841806 X-HE-Meta: U2FsdGVkX18U8Y0uiTOA5vmz9bIpAPk70RWjwtw+lU2fZCkGAJhJXurunLv53BgTcjax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XPQHvYAUryl+aIdnxP47P4usGJVaiCfANahx17xwX2h56vZcI9V8zLtNOsKtg/1oVBk1SkW1US5r+fCa26K/Sdb3LXhXepubkS9XGrtvMCDTD92Nyn8w7VFmL0NuPzQUAGDqJXW8Iwwt26HLncAnr63L+0A/AJvynJPkIK3cPW2XEWD/JddRBIr+yHvd0A/rB+SBwI06R5pKiZPMINtlM27jrnl6Dej+0YeS+K74TFKlhkGXHdR3cER+D11K8uPKKDsv1oMMNwXoYTMFgonJQPQOM8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --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--