From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D55B490C0B for ; Thu, 13 Aug 2026 18:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786647287; cv=none; b=PXOHU+qdN2GJ+cT4Ewm46u2FJDYtPCqfU28LsDSU4PEO1RHfmqOpJ3/umdSD248fiCwnCBuSMGwgvM2YoVUL3m4Zpwtpor+gwKavzKDl4mRoEC53N/3K6FwmfNeYJAVI9AYKU3U+RT7CUef+Uu0gB+Y0H0676wZW6wl8ywMFGks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786647287; c=relaxed/simple; bh=bXeYqeh/2Zsw2eCjTBlC3loWIWJU8TnZgpPHen4nNO0=; h=Date:To:From:Subject:Message-Id; b=UNHfIMg9ugc65qI+wSkrs7CmS4NrZ5l6O/oQr4dndIEFrf9nHus1d7Nm3LQh7mbLKFQ7+553hEeO3htVWkuXjlygSvPrGwVCgxKikd51Sa06ROFaTzRGmtV7c3b/uVJ2+Es8Av2/eamej7BFflwt9GLOp9+nsqWoQR+8qtM2w58= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=wOswO8rW; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="wOswO8rW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0F4D1F000E9; Thu, 13 Aug 2026 18:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786647285; bh=6SekRVCiOpWLPdM8K/25DfzqPByvvjPVGfRDBPsRaZQ=; h=Date:To:From:Subject; b=wOswO8rWoYEyvRIJ2QBilGOg/R5eRYSM1Hk7HMfFMvYvcVhT1LG+yMmUtcdk4qpgq xBIFhzTFZEzPwatWlMMlfOm50bO7pqHQfuQfErHyXgg1JEHxDfBrWLTLsCCCv8VLv9 RzSeA0a2hGAklgFUejjih3bZUi1r6Vm4y3S6S6IE= Date: Thu, 13 Aug 2026 11:54:44 -0700 To: mm-commits@vger.kernel.org,ljs@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: + tools-testing-vma-add-tests-for-copy_vma-self-merge.patch added to mm-unstable branch Message-Id: <20260813185444.F0F4D1F000E9@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: tools/testing/vma: add tests for copy_vma() self-merge has been added to the -mm mm-unstable branch. Its filename is tools-testing-vma-add-tests-for-copy_vma-self-merge.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/tools-testing-vma-add-tests-for-copy_vma-self-merge.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: "Lorenzo Stoakes (ARM)" Subject: tools/testing/vma: add tests for copy_vma() self-merge Date: Thu, 13 Aug 2026 18:32:25 +0100 Assert that a VMA can be moved backwards, forwards and between a preceding VMA and its old self. In the cases in which the VMA merges only with itself expect that to be achieved by expanding its old self, so assert that these function correctly. However in the case of a merge between a preceding VMA and itself the original VMA is removed, so assert that the preceding VMA replaces the one passed in as vmap and the merge is as expected. Link: https://lore.kernel.org/20260813-b4-scalable-cow-virt-pgoff-v5-8-c21581c0c3c8@kernel.org Signed-off-by: Lorenzo Stoakes (ARM) Acked-by: David Hildenbrand (Arm) Cc: Adrian Hunter Cc: Alexander Deucher Cc: Alexander Gordeev Cc: Alexander Shishkin Cc: Alistair Popple Cc: Arnaldo Carvalho de Melo Cc: Arnd Bergmann Cc: Baolin Wang Cc: Baoquan He Cc: Barry Song Cc: Boris Brezillon Cc: Byungchul Park Cc: Chengming Zhou Cc: Chris Li Cc: Christan König Cc: Christian Borntraeger Cc: Claudio Imbrenda Cc: Dave Airlie Cc: Dev Jain Cc: Gerald Schaefer Cc: Greg Kroah-Hartman Cc: Gregory Price (Meta) Cc: Harry Yoo Cc: Heiko Carstens Cc: Huang Ray Cc: "Huang, Ying" Cc: Ian Rogers Cc: Ingo Molnar Cc: James Clark Cc: Jan Kara Cc: Jann Horn Cc: Janosch Frank Cc: Jason Gunthorpe Cc: Jiri Olsa Cc: John Hubbard Cc: Joshua Hahn Cc: Kairui Song Cc: Kees Cook Cc: Kemeng Shi Cc: Lance Yang Cc: Liam R. Howlett Cc: Liviu Dudau Cc: Maarten Lankhorst Cc: Marc Rutland Cc: "Masami Hiramatsu (Google)" Cc: Matthew Auld Cc: Matthew Brost Cc: Matthew Wilcox (Oracle) Cc: Maxime Ripard Cc: Miaohe Lin Cc: Michal Hocko Cc: Mike Rapoport Cc: Muchun Song Cc: Namhyung kim Cc: Naoya Horiguchi Cc: Nhat Pham Cc: Nico Pache Cc: Oleg Nesterov Cc: Oscar Salvador Cc: Pedro Falcato Cc: Peter Xu Cc: Peter Zijlstra Cc: Rakie Kim Cc: Rik van Riel Cc: Rodrigo Vivi Cc: Ryan Roberts Cc: Steven Price Cc: Suren Baghdasaryan Cc: Sven Schnelle Cc: Thomas Hellström Cc: Thomas Zimemrmann Cc: Vasily Gorbik Cc: Vlastimil Babka Cc: xu xin Cc: Zi Yan Signed-off-by: Andrew Morton --- tools/testing/vma/tests/vma.c | 46 +++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) --- a/tools/testing/vma/tests/vma.c~tools-testing-vma-add-tests-for-copy_vma-self-merge +++ a/tools/testing/vma/tests/vma.c @@ -33,7 +33,51 @@ static bool test_copy_vma(void) struct mm_struct mm = {}; bool need_locks = false; VMA_ITERATOR(vmi, &mm, 0); - struct vm_area_struct *vma, *vma_new, *vma_next; + struct vm_area_struct *vma, *vma_prev, *vma_new, *vma_next, *vma_orig; + + /* Move forwards, adjacent to old self - self-merge. */ + + vma = alloc_and_link_vma(&mm, 0x1000, 0x2000, 1, vma_flags); + vma_set_anonymous(vma); + vma_orig = vma; + vma_new = copy_vma(&vma, 0x2000, 0x1000, 1, &need_locks); + ASSERT_EQ(vma_new, vma_orig); + ASSERT_EQ(vma, vma_orig); + ASSERT_EQ(vma_new->vm_start, 0x1000); + ASSERT_EQ(vma_new->vm_end, 0x3000); + + cleanup_mm(&mm, &vmi); + + /* Move backwards, adjacent to old self - self-merge. */ + + vma = alloc_and_link_vma(&mm, 0x2000, 0x3000, 2, vma_flags); + vma_set_anonymous(vma); + vma_orig = vma; + vma_new = copy_vma(&vma, 0x1000, 0x1000, 2, &need_locks); + ASSERT_EQ(vma_new, vma_orig); + ASSERT_EQ(vma, vma_orig); + ASSERT_EQ(vma_new->vm_start, 0x1000); + ASSERT_EQ(vma_new->vm_end, 0x3000); + + cleanup_mm(&mm, &vmi); + + /* + * Move backwards between prior VMA and old self - self-merge and vma + * updated to a new VMA. + */ + + vma_prev = alloc_and_link_vma(&mm, 0x1000, 0x2000, 1, vma_flags); + vma_set_anonymous(vma_prev); + vma = alloc_and_link_vma(&mm, 0x3000, 0x4000, 3, vma_flags); + vma_set_anonymous(vma); + vma_orig = vma; + vma_new = copy_vma(&vma, 0x2000, 0x1000, 3, &need_locks); + ASSERT_NE(vma_new, vma_orig); + ASSERT_EQ(vma_new, vma); + ASSERT_EQ(vma_new->vm_start, 0x1000); + ASSERT_EQ(vma_new->vm_end, 0x4000); + + cleanup_mm(&mm, &vmi); /* Move backwards and do not merge. */ _ Patches currently in -mm which might be from ljs@kernel.org are mm-vma-introduce-vma-anon-page-offset-field-and-add-helpers.patch mm-provide-vma_is_cow_mapping-and-remove-is_cow_mapping.patch mm-introduce-linear_anon_page_index.patch mm-abstract-vma_address-and-introduce-vma_anon_address.patch mm-update-print_bad_page_map-to-show-anon-index-if-appropriate.patch mm-introduce-and-use-vma_filebacked_address.patch mm-vma-fix-self-merge-check-in-copy_vma.patch tools-testing-vma-add-tests-for-copy_vma-self-merge.patch mm-propagate-vma-anonymous-page-offset-on-map-remap-split-merge.patch mm-rmap-track-whether-the-page-vma-mapped-pgoff-is-anonymous.patch mm-clean-up-vma_address_end.patch mm-huge_memory-update-remove_migration_pmd-to-accept-a-folio.patch mm-migrate-calculate-large-folio-page-index-using-pfn.patch mm-rmap-use-anon-pgoff-to-track-map_private-file-backed-anon-folios.patch tools-testing-vma-expand-vma-merge-tests-to-assert-anon-pgoff.patch tools-testing-selftests-mm-test-anonymous-page-offset-merge-behaviour.patch mm-add-some-missing-includes-to-mm-local-headers.patch maintainers-add-drivers-char-memc-to-mm-misc-memory-mapping-sections.patch