Re: [PATCH v5 10/13] mm: page_vma_mapped_walk: map_pte() use pte_offset_map_rw_nolock()

2024-09-26 Thread Muchun Song
held, > so we should get pmdval and do pmd_same() check to ensure the stability of > pvmw->pmd. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song Thanks.

Re: [PATCH v5 07/13] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

2024-09-26 Thread Muchun Song
should get pgt_pmd and do pmd_same() check after the ptl held. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song Thanks.

Re: [PATCH v4 07/13] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

2024-09-24 Thread Muchun Song
> On Sep 24, 2024, at 16:57, Qi Zheng wrote: > > > > On 2024/9/24 16:52, Muchun Song wrote: >>> On Sep 24, 2024, at 15:29, Qi Zheng wrote: >>> >>> >>> >>> On 2024/9/24 15:14, Muchun Song wrote: >>>>> On Sep 24, 2

Re: [PATCH v4 07/13] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

2024-09-24 Thread Muchun Song
> On Sep 24, 2024, at 15:29, Qi Zheng wrote: > > > > On 2024/9/24 15:14, Muchun Song wrote: >>> On Sep 24, 2024, at 14:11, Qi Zheng wrote: >>> In collapse_pte_mapped_thp(), we may modify the pte and pmd entry after >>> acquring the ptl, so co

Re: [PATCH v4 10/13] mm: page_vma_mapped_walk: map_pte() use pte_offset_map_rw_nolock()

2024-09-24 Thread Muchun Song
> On Sep 24, 2024, at 16:33, Qi Zheng wrote: > > > > On 2024/9/24 16:25, Muchun Song wrote: >>> On Sep 24, 2024, at 14:11, Qi Zheng wrote: >>> >>> In the caller of map_pte(), we may modify the pvmw->pte after acquiring >>> the pvmw

Re: [PATCH v4 10/13] mm: page_vma_mapped_walk: map_pte() use pte_offset_map_rw_nolock()

2024-09-24 Thread Muchun Song
> On Sep 24, 2024, at 14:11, Qi Zheng wrote: > > In the caller of map_pte(), we may modify the pvmw->pte after acquiring > the pvmw->ptl, so convert it to using pte_offset_map_rw_nolock(). At > this time, the pte_same() check is not performed after the pvmw->ptl held, > so we should get pmdva

Re: [PATCH v4 09/13] mm: mremap: move_ptes() use pte_offset_map_rw_nolock()

2024-09-24 Thread Muchun Song
_mapping, so there is no concurrency with retract_page_tables(). In > addition, we already hold the exclusive mmap_lock, so this new_pte page is > stable, so there is no need to get pmdval and do pmd_same() check. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song

Re: [PATCH v4 08/13] mm: copy_pte_range() use pte_offset_map_rw_nolock()

2024-09-24 Thread Muchun Song
tables() are using vma->anon_vma to be exclusive, so the PTE > page is stable, there is no need to get pmdval and do pmd_same() check. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song

Re: [PATCH v4 07/13] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

2024-09-24 Thread Muchun Song
> On Sep 24, 2024, at 14:11, Qi Zheng wrote: > In collapse_pte_mapped_thp(), we may modify the pte and pmd entry after > acquring the ptl, so convert it to using pte_offset_map_rw_nolock(). At > this time, the pte_same() check is not performed after the PTL held. So we > should get pgt_pmd and

Re: [PATCH v4 01/13] mm: pgtable: introduce pte_offset_map_{ro|rw}_nolock()

2024-09-23 Thread Muchun Song
vert pte_offset_map_nolock() into the above > two functions one by one, and finally completely delete it. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song

Re: [PATCH v3 01/14] mm: pgtable: introduce pte_offset_map_{ro|rw}_nolock()

2024-09-06 Thread Muchun Song
On 2024/9/4 16:40, Qi Zheng wrote: Currently, the usage of pte_offset_map_nolock() can be divided into the following two cases: 1) After acquiring PTL, only read-only operations are performed on the PTE page. In this case, the RCU lock in pte_offset_map_nolock() will ensure that the P

Re: [PATCH v3 13/14] mm: pgtable: remove pte_offset_map_nolock()

2024-09-05 Thread Muchun Song
> On Sep 4, 2024, at 16:40, Qi Zheng wrote: > > Now no users are using the pte_offset_map_nolock(), remove it. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song Thanks.

Re: [PATCH v3 12/14] mm: multi-gen LRU: walk_pte_range() use pte_offset_map_rw_nolock()

2024-09-05 Thread Muchun Song
al and do pmd_same() check to ensure the stability of pmd entry. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song Thanks.

Re: [PATCH v3 11/14] mm: userfaultfd: move_pages_pte() use pte_offset_map_rw_nolock()

2024-09-05 Thread Muchun Song
; pmd_same() check, just pass a dummy variable to it. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song Thanks.

Re: [PATCH v3 10/14] mm: page_vma_mapped_walk: map_pte() use pte_offset_map_rw_nolock()

2024-09-05 Thread Muchun Song
On 2024/9/4 16:40, Qi Zheng wrote: In the caller of map_pte(), we may modify the pvmw->pte after acquiring the pvmw->ptl, so convert it to using pte_offset_map_rw_nolock(). At this time, the pte_same() check is not performed after the pvmw->ptl held, so we should get pmdval and do pmd_same() c

Re: [PATCH v3 09/14] mm: mremap: move_ptes() use pte_offset_map_rw_nolock()

2024-09-05 Thread Muchun Song
On 2024/9/4 16:40, Qi Zheng wrote: In move_ptes(), we may modify the new_pte after acquiring the new_ptl, so convert it to using pte_offset_map_rw_nolock(). Since we may free the PTE page in retract_page_tables() without holding the read lock of mmap_lock, so we still need to do a pmd_same() c

Re: [PATCH v3 08/14] mm: copy_pte_range() use pte_offset_map_rw_nolock()

2024-09-05 Thread Muchun Song
On 2024/9/4 16:40, Qi Zheng wrote: In copy_pte_range(), we may modify the src_pte entry after holding the src_ptl, so convert it to using pte_offset_map_rw_nolock(). Since we may free the PTE page in retract_page_tables() without holding the read lock of mmap_lock, so we still need to get pmdv

Re: [PATCH v2 07/14] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

2024-09-05 Thread Muchun Song
> On Sep 5, 2024, at 14:41, Qi Zheng wrote: > > > > On 2024/9/5 14:32, Muchun Song wrote: >>> On Aug 30, 2024, at 14:54, Qi Zheng wrote: >>> >>> >>> >>> On 2024/8/29 16:10, Muchun Song wrote: >>>> On 2024/8/22 15:1

Re: [PATCH v2 07/14] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

2024-09-04 Thread Muchun Song
> On Aug 30, 2024, at 14:54, Qi Zheng wrote: > > > > On 2024/8/29 16:10, Muchun Song wrote: >> On 2024/8/22 15:13, Qi Zheng wrote: >>> In collapse_pte_mapped_thp(), we may modify the pte and pmd entry after >>> acquring the ptl, so convert it to using

Re: [PATCH v2 08/14] mm: copy_pte_range() use pte_offset_map_rw_nolock()

2024-08-29 Thread Muchun Song
gt; to do pmd_same() check, just pass a dummy variable to it. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song

Re: [PATCH v2 07/14] mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

2024-08-29 Thread Muchun Song
On 2024/8/22 15:13, Qi Zheng wrote: In collapse_pte_mapped_thp(), we may modify the pte and pmd entry after acquring the ptl, so convert it to using pte_offset_map_rw_nolock(). At this time, the write lock of mmap_lock is not held, and the pte_same() check is not performed after the PTL held.

Re: [PATCH v2 06/14] mm: handle_pte_fault() use pte_offset_map_rw_nolock()

2024-08-29 Thread Muchun Song
; pmd_same() check, just pass a dummy variable to it. > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song A nit below. > --- > mm/memory.c | 12 ++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 93c0c25

Re: [PATCH v2 05/14] mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_ro_nolock()

2024-08-29 Thread Muchun Song
: Qi Zheng Reviewed-by: Muchun Song

Re: [PATCH v2 04/14] mm: filemap: filemap_fault_recheck_pte_none() use pte_offset_map_ro_nolock()

2024-08-29 Thread Muchun Song
> On Aug 22, 2024, at 15:13, Qi Zheng wrote: > > In filemap_fault_recheck_pte_none(), we just do pte_none() check, so > convert it to using pte_offset_map_ro_nolock(). > > Signed-off-by: Qi Zheng Reviewed-by: Muchun Song

Re: [PATCH v2 03/14] powerpc: assert_pte_locked() use pte_offset_map_ro_nolock()

2024-08-29 Thread Muchun Song
On 2024/8/22 15:13, Qi Zheng wrote: In assert_pte_locked(), we just get the ptl and assert if it was already held, so convert it to using pte_offset_map_ro_nolock(). Signed-off-by: Qi Zheng Reviewed-by: Muchun Song

Re: [PATCH v2 02/14] arm: adjust_pte() use pte_offset_map_rw_nolock()

2024-08-28 Thread Muchun Song
modified concurrently. Therefore, in order to ensure the stability if pmd entry, use pte_offset_map_rw_nolock() to replace pte_offset_map_nolock(), and do pmd_same() check after holding the PTL. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song ---   arch/arm/mm/fault-armv.c | 9 -   1

Re: [PATCH v2 01/14] mm: pgtable: introduce pte_offset_map_{ro|rw}_nolock()

2024-08-28 Thread Muchun Song
On 2024/8/22 15:13, Qi Zheng wrote: Currently, the usage of pte_offset_map_nolock() can be divided into the following two cases: 1) After acquiring PTL, only read-only operations are performed on the PTE page. In this case, the RCU lock in pte_offset_map_nolock() will ensure that the

Re: [PATCH v2 05/14] mm/sparc: Change pXd_huge() behavior to exclude swap entries

2024-03-18 Thread Muchun Song
> On Mar 19, 2024, at 04:03, pet...@redhat.com wrote: > > From: Peter Xu > > Please refer to the previous patch on the reasoning for x86. Now sparc is > the only architecture that will allow swap entries to be reported as > pXd_huge(). After this patch, all architectures should forbid swap

Re: [PATCH 1/1] selftests: mm: hugepage-vmemmap fails on 64K page size systems.

2024-01-10 Thread Muchun Song
t; Returned address is 0x7e00 whose pfn is 600 >> *# >> >> Result on x86 with patch (page size 4K) >> *# ./hugepage-vmemmap >> Returned address is 0x7fc7c2c0 whose pfn is 1dac00 >> *# >> >> Signed-off-by: Donet Tom >> Reported

Re: [PATCH 03/13] mm: Provide generic pmd_thp_or_huge()

2024-01-01 Thread Muchun Song
> On Jan 2, 2024, at 13:37, Peter Xu wrote: > > On Mon, Dec 25, 2023 at 02:29:53PM +0800, Muchun Song wrote: >>> @@ -1355,6 +1355,10 @@ static inline int pmd_write(pmd_t pmd) >>> #endif /* pmd_write */ >>> #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ >>

Re: [PATCH 05/13] mm: Introduce vma_pgtable_walk_{begin|end}()

2024-01-01 Thread Muchun Song
> On Jan 2, 2024, at 13:39, Peter Xu wrote: > > On Mon, Dec 25, 2023 at 02:34:48PM +0800, Muchun Song wrote: >> Reviewed-by: Muchun Song > > You're using the old email address here. Do you want me to also use the > linux.dev one that you suggested me to use?

Re: [PATCH 05/13] mm: Introduce vma_pgtable_walk_{begin|end}()

2023-12-25 Thread Muchun Song
y: Christoph Hellwig > Signed-off-by: Peter Xu Reviewed-by: Muchun Song Thanks.

Re: [PATCH 03/13] mm: Provide generic pmd_thp_or_huge()

2023-12-25 Thread Muchun Song
On 2023/12/19 15:55, pet...@redhat.com wrote: From: Peter Xu ARM defines pmd_thp_or_huge(), detecting either a THP or a huge PMD. It can be a helpful helper if we want to merge more THP and hugetlb code paths. Make it a generic default implementation, only exist when CONFIG_MMU. Arch can

Re: [PATCH 2/4] arm64/hugetlb: Implement arm64 specific hugetlb_mask_last_page

2022-06-17 Thread Muchun Song
> Signed-off-by: Baolin Wang > Signed-off-by: Mike Kravetz Acked-by: Muchun Song Thanks.

Re: [PATCH 1/4] hugetlb: skip to end of PT page mapping when pte not present

2022-06-17 Thread Muchun Song
GENERAL_HUGETLB is defined. > Architectures which provide their own versions of huge_pte_offset can also > provide their own version of hugetlb_mask_last_page. > > Signed-off-by: Mike Kravetz > Tested-by: Baolin Wang > Reviewed-by: Baolin Wang It'll be more efficient, Thanks. Acked-by: Muchun Song

Re: [PATCH v2 3/3] mm: rmap: Fix CONT-PTE/PMD size hugetlb issue when unmapping

2022-05-08 Thread Muchun Song
age. Meanwhile adding a VM_BUG_ON() > to make sure the passed hugetlb page is poisoned in try_to_unmap(). > > Signed-off-by: Baolin Wang Reviewed-by: Muchun Song Thanks.

Re: [PATCH v2 1/3] mm: change huge_ptep_clear_flush() to return the original pte

2022-05-08 Thread Muchun Song
On Sun, May 08, 2022 at 09:09:55PM +0800, Baolin Wang wrote: > > > On 5/8/2022 7:09 PM, Muchun Song wrote: > > On Sun, May 08, 2022 at 05:36:39PM +0800, Baolin Wang wrote: > > > It is incorrect to use ptep_clear_flush() to nuke a hugetlb page > > > table when

Re: [PATCH v2 2/3] mm: rmap: Fix CONT-PTE/PMD size hugetlb issue when migration

2022-05-08 Thread Muchun Song
e hugetlb. > > Signed-off-by: Baolin Wang This looks fine to me. Reviewed-by: Muchun Song Thanks.

Re: [PATCH v2 1/3] mm: change huge_ptep_clear_flush() to return the original pte

2022-05-08 Thread Muchun Song
eparation patch, which changes the huge_ptep_clear_flush() > to return the original pte to help to nuke a hugetlb page table. > > Signed-off-by: Baolin Wang > Acked-by: Mike Kravetz Reviewed-by: Muchun Song But one nit below: [...] > diff --git a/mm/hugetlb.c b/mm/hugetlb.c &