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 2285AC25B50 for ; Mon, 23 Jan 2023 20:00:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF8B16B0071; Mon, 23 Jan 2023 15:00:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA8306B0072; Mon, 23 Jan 2023 15:00:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96FEC6B0074; Mon, 23 Jan 2023 15:00:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8675B6B0071 for ; Mon, 23 Jan 2023 15:00:29 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E34401438EC for ; Mon, 23 Jan 2023 20:00:28 +0000 (UTC) X-FDA: 80387130936.07.C7C2D23 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf14.hostedemail.com (Postfix) with ESMTP id CF033100011 for ; Mon, 23 Jan 2023 20:00:25 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=tQ2EbAB5; spf=pass (imf14.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674504026; 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=9umLbK138jo14qJ7E8MIOxomDS0h8eCmJZ+29QkDcwY=; b=tC64v0FwJgPq7HuIPNvnQp7pqSz3oHlPLctQVNGha1W3qRUDIhDorvjYDNjG6j0lecr854 TzaaXYbGcCcRlJhfctGRw8UkJAAwcW7C+9+2PsaLYet7oSf7PYnxAD7uvu8nP7Omh9bV3M /9GaOMdvMF1pEsofy5X0Gn2W8naka+Y= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=tQ2EbAB5; spf=pass (imf14.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674504026; a=rsa-sha256; cv=none; b=ZYXNsXVzJTAL76gfWWCXCyfE0pVE6YeuVnHnUIooqWlkgxNjKfHPBtc21jzXXRJykXEJC4 mxOZgpgt258RAqVPc8H6xOBNgwFJWwhMZujPaWko9/OibQdkj6GBr6MFwNHPG0C9eFa9PP sjm0DbDrxtNpj8voZr0hYw8Rorz/5tk= 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 272B9218F2; Mon, 23 Jan 2023 20:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674504024; 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=9umLbK138jo14qJ7E8MIOxomDS0h8eCmJZ+29QkDcwY=; b=tQ2EbAB5Pd9IPcZYKmKts4B7J9zBmGbFLnwbQQcjVLR9/1l2Nv5AqZ8GvPV0PD1fIOGfKy xp3I2aoV4vH56nWiCeF20k9hV8vuvOqVOb8DbURfrSSv5EeFT3E0K+tsowMHdS8b+xmH+Z mpFeUtCeqYd1GQVKlV65hKfD5gOl90E= 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 F08A51357F; Mon, 23 Jan 2023 20:00:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 47MxOlfnzmN/aAAAMHmgww (envelope-from ); Mon, 23 Jan 2023 20:00:23 +0000 Date: Mon, 23 Jan 2023 21:00:23 +0100 From: Michal Hocko To: Matthew Wilcox Cc: Suren Baghdasaryan , "Liam R. Howlett" , akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 39/41] kernel/fork: throttle call_rcu() calls in vm_area_free Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CF033100011 X-Stat-Signature: 9ngak8nh3yzbder6jhzfkq1qynf8n1ow X-HE-Tag: 1674504025-49801 X-HE-Meta: U2FsdGVkX1+XLrLUscz9lV4xHjBYjDR45SIQLjIA8+cOFd2l80AskpqL/P9CeulvqMfqHk1tb9TKfpefYn5bGHTLl9+PpFf/V51C3G20Icf6SpZsuhrw/TptxE06gXFXA6GQaZlhgxKUN19eGI9UkypVruxxluUsNFAE4Bh/7b4BUzZL9MRL5jE9GuMClz5CgWr+t2P6+enabVN9FDM10FY0bnMapWVsJvbSX8MPvy1/LbEUsM+x0hgFkMt0mWjpB/r8ng6YMo9qM3Ndvnpj/oY3EZJWhKJ9/JocZJRB8eNPj7W596vXuUR7Yn7XzbJTtuUeSX+ajbZNKSx6Ri8YdSFEgoYfwuUpV5hzteKFt8voiwdoZe804Mj8A8hTsjcz/5ZXB46Ii+bFFpCogzOyBI/7bQKnj/2PDl4844qCXLcbakCCX33AOeY6KP5NdLjRjjGepMK7QDndLiPX7HBjU/6KAtYRaXZPtpWPvD0XSsuCJCzlEqFh1HXkCqj74LmN2AH6+4OAJrKSCDXpvpY2NjaCD0M8pkU3s39EEl3Vh0GuH9OZ1E/DnDegfihrghjsQyEk73e92fbFnuqUIYBSKA+tqNQEWrk3z1cPEkf6bCj4jey58G8A1wbCs6bI8NKqHugWOpxJN6HadFB0ltAnF5nmIoD6OVa5BGjtQPoa+Fha97XkB0Qf9fe3Hcmq1sN2V0sIUwHOFUMmEbOvglfA58WYBCFTErZ+Y7l5fNdTRLf1gnV90HfuPsY+8kMbGHBYUycTuSh3i8F0evb8eWXPwnRmVHngiE3REyCxOnaETHCnikuRxvS9MsNdpQS5yWamVo/V86cf0uPCUYqo3xKyppd+im52kjzqj9TCsN1TTF5QQfCXV/8owFqg9CxB5onDpikMHD38JJ0Y+E/8U01inoURY3dsdDasBm+lwVKmPCy/D6vO1thT/5xD4YzTUxcJSlevWZ4733Sr9nRle6I SbZ7+QpJ EngVhSNvLWdOiB8NLO39t+ujzybSLnoinEvwIUlcoXoPjTPd0E1gjNK6FkJyl68IaO8gRpuW2uIkTC5gxZFHLiRUIKKHzPAc5L4yFKHlGaSBGvO7gZcbkilFwQ2ah/D9tEqbpRnvf66GfXsj9erZQhiOJU2FuEKSswr8VnSAmmXP395vGW9coewuvTrcYcxHFYMVpcuNDEo0iYu14KCVs+9HJVg== 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: On Mon 23-01-23 19:30:43, Matthew Wilcox wrote: > On Mon, Jan 23, 2023 at 08:18:37PM +0100, Michal Hocko wrote: > > On Mon 23-01-23 18:23:08, Matthew Wilcox wrote: > > > On Mon, Jan 23, 2023 at 09:46:20AM -0800, Suren Baghdasaryan wrote: > > [...] > > > > Yes, batching the vmas into a list and draining it in remove_mt() and > > > > exit_mmap() as you suggested makes sense to me and is quite simple. > > > > Let's do that if nobody has objections. > > > > > > I object. We *know* nobody has a reference to any of the VMAs because > > > you have to have a refcount on the mm before you can get a reference > > > to a VMA. If Michal is saying that somebody could do: > > > > > > mmget(mm); > > > vma = find_vma(mm); > > > lock_vma(vma); > > > mmput(mm); > > > vma->a = b; > > > unlock_vma(mm, vma); > > > > > > then that's something we'd catch in review -- you obviously can't use > > > the mm after you've dropped your reference to it. > > > > I am not claiming this is possible now. I do not think we want to have > > something like that in the future either but that is really hard to > > envision. I am claiming that it is subtle and potentially error prone to > > have two different ways of mass vma freeing wrt. locking. Also, don't we > > have a very similar situation during last munmaps? > > We shouldn't have two ways of mass VMA freeing. Nobody's suggesting that. > There are two cases; there's munmap(), which typically frees a single > VMA (yes, theoretically, you can free hundreds of VMAs with a single > call which spans multiple VMAs, but in practice that doesn't happen), > and there's exit_mmap() which happens on exec() and exit(). This requires special casing remove_vma for those two different paths (exit_mmap and remove_mt). If you ask me that sounds like a suboptimal code to even not handle potential large munmap which might very well be a rare thing as you say. But haven't we learned that sooner or later we will find out there is somebody that cares afterall? Anyway, this is not something I care about all that much. It is just weird to special case exit_mmap, if you ask me. Up to Suren to decide which way he wants to go. I just really didn't like the initial implementation of batching based on a completely arbitrary batch limit and lazy freeing. -- Michal Hocko SUSE Labs