[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3d3e48cc-687c-8d4e-1e33-c34fb76c284f@redhat.com>
Date: Mon, 14 Nov 2022 10:05:29 +0100
From: David Hildenbrand <david@...hat.com>
To: Mike Kravetz <mike.kravetz@...cle.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Cc: Naoya Horiguchi <naoya.horiguchi@...ux.dev>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Mina Almasry <almasrymina@...gle.com>,
Peter Xu <peterx@...hat.com>,
Nadav Amit <nadav.amit@...il.com>,
Rik van Riel <riel@...riel.com>,
Vlastimil Babka <vbabka@...e.cz>,
Matthew Wilcox <willy@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Wei Chen <harperchen1110@...il.com>, stable@...r.kernel.org
Subject: Re: [PATCH v9 1/3] madvise: use zap_page_range_single for madvise
dontneed
On 12.11.22 00:26, Mike Kravetz wrote:
> Expose the routine zap_page_range_single to zap a range within a single
> vma. The madvise routine madvise_dontneed_single_vma can use this
> routine as it explicitly operates on a single vma. Also, update the mmu
> notification range in zap_page_range_single to take hugetlb pmd sharing
> into account. This is required as MADV_DONTNEED supports hugetlb vmas.
>
> Fixes: 90e7e7f5ef3f ("mm: enable MADV_DONTNEED for hugetlb mappings")
> Signed-off-by: Mike Kravetz <mike.kravetz@...cle.com>
> Reported-by: Wei Chen <harperchen1110@...il.com>
> Cc: <stable@...r.kernel.org>
[...]
>
> -/*
> - * Parameter block passed down to zap_pte_range in exceptional cases.
> - */
> -struct zap_details {
> - struct folio *single_folio; /* Locked folio to be unmapped */
> - bool even_cows; /* Zap COWed private pages too? */
> - zap_flags_t zap_flags; /* Extra flags for zapping */
> -};
> -
> /* Whether we should zap all COWed (private) pages too */
> static inline bool should_zap_cows(struct zap_details *details)
> {
> @@ -1736,19 +1727,27 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start,
> *
> * The range must fit into one VMA.
> */
> -static void zap_page_range_single(struct vm_area_struct *vma, unsigned long address,
> +void zap_page_range_single(struct vm_area_struct *vma, unsigned long address,
> unsigned long size, struct zap_details *details)
> {
> + unsigned long end = address + size;
Could make that const.
> struct mmu_notifier_range range;
> struct mmu_gather tlb;
>
> lru_add_drain();
> mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm,
> - address, address + size);
> + address, end);
> + if (is_vm_hugetlb_page(vma))
> + adjust_range_if_pmd_sharing_possible(vma, &range.start,
> + &range.end);
> tlb_gather_mmu(&tlb, vma->vm_mm);
> update_hiwater_rss(vma->vm_mm);
> mmu_notifier_invalidate_range_start(&range);
> - unmap_single_vma(&tlb, vma, address, range.end, details);
> + /*
> + * unmap 'address-end' not 'range.start-range.end' as range
> + * could have been expanded for hugetlb pmd sharing.
> + */
> + unmap_single_vma(&tlb, vma, address, end, details);
> mmu_notifier_invalidate_range_end(&range);
> tlb_finish_mmu(&tlb);
> }
Acked-by: David Hildenbrand <david@...hat.com>
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists