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 1CA08C433EF for ; Thu, 16 Dec 2021 11:09:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E15E6B0080; Thu, 16 Dec 2021 06:09:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9914F6B0083; Thu, 16 Dec 2021 06:09:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 831F76B0085; Thu, 16 Dec 2021 06:09:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id 7169C6B0080 for ; Thu, 16 Dec 2021 06:09:27 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1FA71181AEF09 for ; Thu, 16 Dec 2021 11:09:17 +0000 (UTC) X-FDA: 78923385954.16.09FB5BE Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf13.hostedemail.com (Postfix) with ESMTP id 34C7A20015 for ; Thu, 16 Dec 2021 11:09:10 +0000 (UTC) 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 1358521125; Thu, 16 Dec 2021 11:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1639652954; 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=7O8lNZpNSZ7eUndQ51AE8lYh9+aQbI+sqqjkZKfjseM=; b=udj1lzgT7YU7o/k0DR2+6Jr6sMXnEHS94/kLrOV+QhYHvyIhfH5HRyifZw5cSzXwG+UzQL a+G3BcF11AS4lyGeJsfzURZlH7rpmpr1j0++0oXQMt9qaOd1k4F8XAu30Z1otUmrVFD7j6 moM2TmqzDfFtnnWNZTn6NccdKbf+JmA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1639652954; 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=7O8lNZpNSZ7eUndQ51AE8lYh9+aQbI+sqqjkZKfjseM=; b=mmrMPN9OPZMl+KGF0KI4rnEf9JzPsAjN+SnLdLXrg8+Rapw2tybzWE6rPY59JRsU4zmL7H L4hMRMKtG7xQCbDQ== 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 B7D4C13B4B; Thu, 16 Dec 2021 11:09:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mGA0LFkeu2GrMQAAMHmgww (envelope-from ); Thu, 16 Dec 2021 11:09:13 +0000 Message-ID: Date: Thu, 16 Dec 2021 12:09:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v4 12/66] kernel/fork: Use maple tree for dup_mmap() during forking Content-Language: en-US To: Liam Howlett , "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton Cc: Song Liu , Davidlohr Bueso , "Paul E . McKenney" , Matthew Wilcox , Laurent Dufour , David Rientjes , Axel Rasmussen , Suren Baghdasaryan , Rik van Riel , Peter Zijlstra , Michel Lespinasse , Jerome Glisse , Minchan Kim , Joel Fernandes , Rom Lemarchand References: <20211201142918.921493-1-Liam.Howlett@oracle.com> <20211201142918.921493-13-Liam.Howlett@oracle.com> From: Vlastimil Babka In-Reply-To: <20211201142918.921493-13-Liam.Howlett@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=udj1lzgT; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mmrMPN9O; spf=pass (imf13.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Queue-Id: 34C7A20015 X-Stat-Signature: xqcahqajatskyxiseyzrbr5y4shig9t5 X-Rspamd-Server: rspam04 X-HE-Tag: 1639652950-401723 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 12/1/21 15:29, Liam Howlett wrote: > From: "Liam R. Howlett" > > The maple tree was already tracking VMAs in this function by an earlier > commit, but the rbtree iterator was being used to iterate the list. > Change the iterator to use a maple tree native iterator and switch to > the maple tree advanced API to avoid multiple walks of the tree during > insert operations. Unexport the now-unused vma_store() function. > > We track whether we need to free the VMAs and tree nodes through RCU > (ie whether there have been multiple threads that can see the mm_struct > simultaneously; by pthread(), ptrace() or looking at /proc/$pid/maps). > This setting is sticky because it's too tricky to decide when it's safe > to exit RCU mode. I don't immediately see why enabling the RCU tracking in mmget is part of the dup_mmap() change? > For performance reasons we bulk allocate the maple tree nodes. The node > calculations are done internally to the tree and use the VMA count and > assume the worst-case node requirements. The VM_DONT_COPY flag does > not allow for the most efficient copy method of the tree and so a bulk > loading algorithm is used. > > Signed-off-by: Liam R. Howlett > Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Vlastimil Babka > static inline bool mmget_not_zero(struct mm_struct *mm) > { > + /* > + * There is a race below during task tear down that can cause the maple What does 'below' refer to here? > + * tree to enter rcu mode with only a single user. If this race > + * happens, the result would be that the maple tree nodes would remain > + * active for an extra RCU read cycle. > + */ > + if (!mt_in_rcu(&mm->mm_mt)) > + mm_set_in_rcu(mm); > return atomic_inc_not_zero(&mm->mm_users); > } > > diff --git a/kernel/fork.c b/kernel/fork.c > index cc9bb95c7678..c9f8465d8ae2 100644