Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5836262rwl; Thu, 29 Dec 2022 03:50:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXu+7Xvv3ev28FnwYT8kIesywDqPxA/jI01hLZiEr2Z2kxecsgPqAzlu1ULQY+3anFInRttX X-Received: by 2002:a17:906:704a:b0:83f:cbc0:1b30 with SMTP id r10-20020a170906704a00b0083fcbc01b30mr21423988ejj.10.1672314638564; Thu, 29 Dec 2022 03:50:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672314638; cv=none; d=google.com; s=arc-20160816; b=k92KOoLo6BO//wp1oOq3HAHXfrjbGXfMc/rzrEc5/Zk0uh3gdUnK3xjX6X05ONvtIO N+5Al+44eG/9Yl02UElSg/rDxnXQhGwdGtdTYVrXIkzpWH02+vNCKEpYbT57723fNiwu SSLUAITrBMp6eB5xvy/ZJbOtzW645bKwuaTEk9lKUWKzPFyQNMAF/ss3KPRt1qBBAexG t5UtDs2pu4rBpDmACAiz3wxBHToH7Y/Zdb73y9vbCAyBHY+0CX2vdkRoPddAf/pAVtuR W0fNWtwbcDmAbEwQ0pt/LRt5r2aSO1Xh2a/LoDYYNwVDTvcV49pv4o9y5scfMxg/QG+/ jYGA== 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=qTVxiGDTHL6hg1UtFQZfca+oAw3eSFaWQe0kuo3tP9Q=; b=byRTfQGNnJ9XAn0QDlkjJYGEXy8n8BaU/VxdtJVpoPyKWDZ2fVx4sq69huwYlgbg+X yihJ10fHrKeAeAyiez/rN4L3hCfe2KpgFLYPmGEFde63OleTbeIwep83bdWax9xfs6yu xKQMhvDr9VRi/U5daHY4zLYbO84oJMRoJuIQCruLMrgIYOyOMyW0LbCmZ74GLk481RTU IDkNyhzLQikKDPa9zswnE6mRcfPc2AzHrVwOH7p7i1lxPvm3BgUj1RZSPvQO2lCgK+BZ 0Vu5NQPNMDByF0cx9JP7AtkU7aI082cGepyJXl4ocYBdWvDICCwdQLUIcJwNXXaWjBZz Vm0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d65eMAGG; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g7-20020a1709065d0700b0078df1c345dcsi15963743ejt.535.2022.12.29.03.50.22; Thu, 29 Dec 2022 03:50:38 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=d65eMAGG; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230052AbiL2Ldh (ORCPT + 62 others); Thu, 29 Dec 2022 06:33:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbiL2Lde (ORCPT ); Thu, 29 Dec 2022 06:33:34 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A36E13DE4 for ; Thu, 29 Dec 2022 03:33:33 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id r18so12211296pgr.12 for ; Thu, 29 Dec 2022 03:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qTVxiGDTHL6hg1UtFQZfca+oAw3eSFaWQe0kuo3tP9Q=; b=d65eMAGGk3tndOjyb0lT2sYt7tsemWRwoQqx4ooPMj0H+EA01kJ15xOPX4X+AmkZa/ x9Jc69lBdrTWFxI1uCuMx7QrRByzMJxs4vkW69MwKe7d6/A7GMVx6JgswuJ/lM+zbQJG aUnWu1GZA+jNg+4USaM37ZlA/MpyZA+69zji0o/pKdvo1rtWlJhcuqco6ZB+96p5P3kK rSt46jw3rfyfiYC0XH1iE5csFT8LSp4zoc62xHezweFq4mk3ZZ1VeaoX5fbZ2OkEm+EM 6/gLo0q3Cy1m2mETPNxJ9CTugIfAPAfTnvz8rwomFWgfek9q7jy/9/ID75afCbZ1nzql /xOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qTVxiGDTHL6hg1UtFQZfca+oAw3eSFaWQe0kuo3tP9Q=; b=2bphoWlNKa8Kae7ZWK3kAzjFQ1wn1jJdMW+ZeyVzTKLf7rCvH9rOdfeKKyDpqNIUiy gV31noMoGuh1G4KN0AmPnJTDwUZpSpZipmmTSFhsRaA0p3HQ2J7NvsSypd4FyCfXXWeJ 8gSp81Lh5iGp/baSaK+33vwUHG01ekYCehnZ0wMS7jIbTmaea7W9gK6YF3BiGEVlcYwT 0PxJBwQvrtxvtrsHQsTY6gyG7w9mHi1rSoDH0Ztl62E8g15MYYzKGfG1P0G9aTb7MVOr 0Xwe35KICcwgpkA+kA1AT0eXhBGtxeJep1x8Q0tPjEe9yJXYNqZNr4GbkKTAG7/OdMq1 zBTg== X-Gm-Message-State: AFqh2kpergk6yJYsBc5LIMD1tedlzkERGpFrrXv+YFqoPIRWW34P06Du 94zbwIcnRxPkvq6meDVfh7N3D7/3evFdjD+W X-Received: by 2002:a62:4e93:0:b0:57f:ef11:acf9 with SMTP id c141-20020a624e93000000b0057fef11acf9mr27300836pfb.10.1672313612386; Thu, 29 Dec 2022 03:33:32 -0800 (PST) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id d188-20020a6236c5000000b0057a9b146592sm11871081pfa.186.2022.12.29.03.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 03:33:31 -0800 (PST) Date: Thu, 29 Dec 2022 20:33:26 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Suren Baghdasaryan Cc: linux-mm@kvack.org, liam.howlett@oracle.com, willy@infradead.org, ldufour@linux.ibm.com, michel@lespinasse.org, vbabka@suse.cz, linux-kernel@vger.kernel.org Subject: Re: [QUESTION] about the maple tree and current status of mmap_lock scalability Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Wed, Dec 28, 2022 at 09:10:20AM -0800, Suren Baghdasaryan wrote: > Hi Hyeonggon, > > On Wed, Dec 28, 2022 at 4:49 AM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > > > Hello mm folks, > > > > I have a few questions about the current status of mmap_lock scalability. > > > > ============================================================= > > What is currently causing the kernel to use mmap_lock to protect the maple tree? > > ============================================================= > > > > I understand that the long-term goal is to remove the need for mmap_lock in readers > > while traversing the maple tree, using techniques such as RCU or SPF. > > What is the biggest obstacle preventing this from being achieved at this time? > > Maple tree has an RCU mode which does not need mmap_lock for > traversal. Liam and I were testing it recently and Liam fixed a number > of issues to enable it. It seems stable now and the fixes are > incorporated into the "per-vma locks" patchset which I prepared in > this branch: https://github.com/surenbaghdasaryan/linux/tree/per_vma_lock. Thank you for the link. I didn't realize how far the discussion had progressed. Let me check if I understand correctly: To allow non-overlapping page faults while writers are performing VMA operations, per-VMA locking moves from the mmap_lock to the VMA lock on the reader side during page fault. While maple tree traversal is done without locking, readers must take VMA lock in read mode within RCU read section (or retry taking mmap_lock if failed) to process page fault. This ensures that readers are not racing with writers for access to the same VMA. Am I getting it right? > I haven't posted this patchset upstream yet but it's pretty much ready > to go. I'm planning to post it in early January. Looking forward to that, thank you for working on this. -- Thanks, Hyeonggon