Message ID | e08dfe5ec6a654e8cb48f9203d7406326368f5a6.1736488799.git-series.apopple@nvidia.com |
---|---|
State | New |
Headers | show |
Series | fs/dax: Fix ZONE_DEVICE page reference counts | expand |
Alistair Popple wrote: > At present mlock skips ptes mapping ZONE_DEVICE pages. A future change > to remove pmd_devmap will allow pmd_trans_huge_lock() to return > ZONE_DEVICE folios so make sure we continue to skip those. > > Signed-off-by: Alistair Popple <apopple@nvidia.com> > Acked-by: David Hildenbrand <david@redhat.com> This looks like a fix in that mlock_pte_range() *does* call mlock_folio() when pmd_trans_huge_lock() returns a non-NULL @ptl. So it is not in preparation for a future change it is making the pte and pmd cases behave the same to drop mlock requests. The code change looks good, but do add a Fixes tag and reword the changelog a bit before adding: Reviewed-by: Dan Williams <dan.j.williams@intel.com>
On Mon, Jan 13, 2025 at 06:42:46PM -0800, Dan Williams wrote: > Alistair Popple wrote: > > At present mlock skips ptes mapping ZONE_DEVICE pages. A future change > > to remove pmd_devmap will allow pmd_trans_huge_lock() to return > > ZONE_DEVICE folios so make sure we continue to skip those. > > > > Signed-off-by: Alistair Popple <apopple@nvidia.com> > > Acked-by: David Hildenbrand <david@redhat.com> > > This looks like a fix in that mlock_pte_range() *does* call mlock_folio() > when pmd_trans_huge_lock() returns a non-NULL @ptl. > > So it is not in preparation for a future change it is making the pte and > pmd cases behave the same to drop mlock requests. > > The code change looks good, but do add a Fixes tag and reword the > changelog a bit before adding: Yeah, that changelog is a bit whacked. In fact it's not a fix - because mlock_fixup() (the only caller) already filters dax VMAs. So this is really about fixing a possible future bug when we start having PMDs for other types of ZONE_DEVICE pages (ie. private, coherent, etc). So probably I should just roll this into "mm: Allow compound zone device pages". > Reviewed-by: Dan Williams <dan.j.williams@intel.com>
diff --git a/mm/mlock.c b/mm/mlock.c index cde076f..3cb72b5 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -368,6 +368,8 @@ static int mlock_pte_range(pmd_t *pmd, unsigned long addr, if (is_huge_zero_pmd(*pmd)) goto out; folio = pmd_folio(*pmd); + if (folio_is_zone_device(folio)) + goto out; if (vma->vm_flags & VM_LOCKED) mlock_folio(folio); else