mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-19 20:05:08 +00:00
mm/damon/ops-common: refactor to use {pte|pmd}p_clear_young_notify()
With the fix in place to atomically test and clear young on ptes and pmds, simplify the code to handle the clearing for both the primary mmu and the mmu notifier with a single API call. Link: https://lkml.kernel.org/r/20230602092949.545577-4-ryan.roberts@arm.com Signed-off-by: Ryan Roberts <ryan.roberts@arm.com> Acked-by: Yu Zhao <yuzhao@google.com> Reviewed-by: SeongJae Park <sj@kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Lorenzo Stoakes <lstoakes@gmail.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Mike Rapoport (IBM) <rppt@kernel.org> Cc: Uladzislau Rezki (Sony) <urezki@gmail.com> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
c11d34fa13
commit
fa8c919dac
@ -39,21 +39,12 @@ struct folio *damon_get_folio(unsigned long pfn)
|
||||
|
||||
void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr)
|
||||
{
|
||||
bool referenced = false;
|
||||
struct folio *folio = damon_get_folio(pte_pfn(*pte));
|
||||
|
||||
if (!folio)
|
||||
return;
|
||||
|
||||
if (ptep_test_and_clear_young(vma, addr, pte))
|
||||
referenced = true;
|
||||
|
||||
#ifdef CONFIG_MMU_NOTIFIER
|
||||
if (mmu_notifier_clear_young(vma->vm_mm, addr, addr + PAGE_SIZE))
|
||||
referenced = true;
|
||||
#endif /* CONFIG_MMU_NOTIFIER */
|
||||
|
||||
if (referenced)
|
||||
if (ptep_clear_young_notify(vma, addr, pte))
|
||||
folio_set_young(folio);
|
||||
|
||||
folio_set_idle(folio);
|
||||
@ -63,21 +54,12 @@ void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr
|
||||
void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr)
|
||||
{
|
||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||
bool referenced = false;
|
||||
struct folio *folio = damon_get_folio(pmd_pfn(*pmd));
|
||||
|
||||
if (!folio)
|
||||
return;
|
||||
|
||||
if (pmdp_test_and_clear_young(vma, addr, pmd))
|
||||
referenced = true;
|
||||
|
||||
#ifdef CONFIG_MMU_NOTIFIER
|
||||
if (mmu_notifier_clear_young(vma->vm_mm, addr, addr + HPAGE_PMD_SIZE))
|
||||
referenced = true;
|
||||
#endif /* CONFIG_MMU_NOTIFIER */
|
||||
|
||||
if (referenced)
|
||||
if (pmdp_clear_young_notify(vma, addr, pmd))
|
||||
folio_set_young(folio);
|
||||
|
||||
folio_set_idle(folio);
|
||||
|
Loading…
x
Reference in New Issue
Block a user