From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796443008; b=htwXyZ38pAWIkxqXCjdbcPRQytlam3WcygEYlUNiPnxK70juBHp31f+HvhZefN0AAKb7 6nw/f/ZB5Am+aS/qajyTB8a3/hw7lgBLUv3Yt+gYLdXaynIsuTZtwR7+uJut9GEjWJTLs 4kUv3qwPKGG5d2+9snT7+qs6oIkmofpCF4QDsFAKWnuZDecNzoKKh789VNEXhd7vq51dg JXXTpthhUzChp3fa95u6vIAu5QKxARorcpQcmkbjKGJeK8QwqBuBG2qjER2BB3SJiMMpG vdhL+/nPALi7PA3rBnZVioGP+MnKTimHdwcGv9wA/Ya9dfio/u2zjO6uULkNse9nnQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796443008; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=LXLdHHTH83EECopkJl0CUwWSkNEHzl63oXlH4WjAezo=; b=U1tISYOTzi0zHs12OX2RB7libDC/BTdkxD7F1GEnX9NJwjRisO8Ns7GJyGizpJ9YQIlW uSGsnXgBNQgnlEQgz+9SsP5STuXyLGmGpUirUi1qoWLwJUO2TxY4OMebq2YGjdmkpw+hc muokKrexEfv5D6mUX/dOWkjB7bvIQ1WE4+v0+TR016twLnmEpYx9yzPwVAlI1podPF6o8 lq1OiAUkPcbBNKw5iOouQH/FmMmsnCS4Z621wmeXB+v79N3EZCoWjie/QANEcsyOLm2Q5 g+TKyD8y6b5A5+G5ddIuSke8Ln90NC0OJQe0Rnz6Zhh88MdreL6r7fiBlcHi+XpQ3KA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="a/OACGAL"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24839606A322 for ; Sat, 5 Dec 2026 03:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=a/OACGAL Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8FE91F00936; Sat, 5 Dec 2026 03:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796443007; bh=LXLdHHTH83EECopkJl0CUwWSkNEHzl63oXlH4WjAezo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=a/OACGALkDTFzAA+ongVWKqz8LVUTm7SimtNb8p+EY7q7U4wt62fTrS19h/4iQeNx AnYOIuO/kIhpVJi0IO0PB5ec/e28zdbw6V6U4DxD8ELyUxn/qiUz2UzBcpXoArSEpb NAG4SCgO8r2Wt7SjAkiB++aWdLSWC7ovRftcSnuPkMEICScVQHXIdTJHJR/Q2j+M5g 4J6+w5YL1H+kYdRjqOq6AGSmKnvrsIRaWCfT5MgZLns1uddBGqjH5O33wlBTofD+2w h0/fMnwAa6hCr6uMAIHIIjC1M3ZuDQ5sanhHgYFqNo3i1C/urx8yFU83E3wZdHuGnQ 08Cm0YkhoOlDg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFC PATCH 1/2] mm/mmap_lock: add try_lock_next_vma() Reply-To: sashiko-reviews@lists.linux.dev To: "Chuanhua Han" , "Suren Baghdasaryan" , "Lorenzo Stoakes" , "Liam R. Howlett" , "Andrew Morton" , "Yonghong Song" , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" Cc: "Chuanhua Han" , "Vlastimil Babka" , "Shakeel Butt" , "Pedro Falcato" , "David Hildenbrand" , "Jann Horn" , "Martin KaFai Lau" , "Song Liu" , "Jiri Olsa" , "Emil Tsalapatis" , "Ihor Solodrai" , "Barry Song" , linux-mm@kvack.org, bpf@vger.kernel.org In-Reply-To: <20261205033951.1811578-2-hanchuanhua802@gmail.com> References: <20261205033951.1811578-1-hanchuanhua802@gmail.com> <20261205033951.1811578-2-hanchuanhua802@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 03:56:45 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] mm: try_lock_next_vma() runs synchronous mmdrop() under RCU read lock -- commit fd43adadc737249dfd917dd44af112219f9309df Author: Chuanhua Han mm/mmap_lock: add try_lock_next_vma() This commit adds try_lock_next_vma() to iterate and read-lock VMAs under RCU without falling back to mmap_lock, skipping any VMA whose lock cannot be taken. > diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c > index 073c5125b4247..8933735d7bad9 100644 > --- a/mm/mmap_lock.c > +++ b/mm/mmap_lock.c > @@ -523,6 +523,68 @@ struct vm_area_struct *lock_next_vma(struct vma_rcu_= iter *rvmi, > return vma; > } [ ... ] > +struct vm_area_struct *try_lock_next_vma(struct mm_struct *mm, > + struct vma_iterator *vmi, > + unsigned long from_addr, > + unsigned long end) > +{ > + struct vm_area_struct *vma, *locked; > + unsigned long found_from; > + > + RCU_LOCKDEP_WARN(!rcu_read_lock_held(), "no rcu read lock held"); > + > + while ((vma =3D vma_find(vmi, end))) { > + /* the lowest address of interest where it was found */ > + found_from =3D max(from_addr, vma_iter_addr(vmi)); > + > + /* vma_start_read() leaves RCU on failure: keep the caller's */ > + rcu_read_lock(); > + locked =3D vma_start_read(mm, vma); [Severity: High] Can vma_start_read() still run synchronous mmdrop() while the caller's RCU read lock is held? The commit message relies on commit 44926897b6c2 ("mm/vma: drop mm asynchronously in vma_start_read()"), which is not in this tree. vma_start_read() still drops other_mm synchronously: mm/mmap_lock.c:vma_start_read() { ... err_unstable: ... rcu_read_unlock(); mmgrab(other_mm); vma_refcount_put(vma); mmdrop(other_mm); ... } Because try_lock_next_vma() takes a nested rcu_read_lock(), that single rcu_read_unlock() leaves the caller's RCU read lock held across mmdrop(other_mm). If the VMA was reused by another mm whose last reference drops here, __mmdrop() runs synchronously under RCU. In non-sleepable contexts such as the BPF task_vma iterator, __mmdrop() -> mm_free_pgd() -> pgd_free() -> pgd_dtor() on x86 takes plain spin_lock(&pgd_lock), deadlocking on the same CPU if entered from softirq or a tracepoint while pgd_lock is held (and sleeping on CONFIG_PREEMPT_RT). cleanup_lazy_tlbs() also issues synchronous cross-CPU IPIs under RCU. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205033951.1811= 578-1-hanchuanhua802@gmail.com?part=3D1