[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f8a7b3a9-251f-44bc-a8db-3cafaf88487e@redhat.com>
Date: Thu, 4 Jul 2024 12:30:04 +0200
From: David Hildenbrand <david@...hat.com>
To: Oscar Salvador <osalvador@...e.de>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Peter Xu <peterx@...hat.com>, Muchun Song <muchun.song@...ux.dev>,
SeongJae Park <sj@...nel.org>, Miaohe Lin <linmiaohe@...wei.com>,
Michal Hocko <mhocko@...e.com>, Matthew Wilcox <willy@...radead.org>,
Christophe Leroy <christophe.leroy@...roup.eu>
Subject: Re: [PATCH 11/45] fs/proc: Enable smaps_pte_entry to handle cont-pte
mapped hugetlb vmas
>
> #ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
> @@ -952,6 +956,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
> struct vm_area_struct *vma = walk->vma;
> pte_t *pte;
> spinlock_t *ptl;
> + unsigned long size, cont_ptes;
>
> ptl = pmd_huge_lock(pmd, vma);
> if (ptl) {
> @@ -965,7 +970,9 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
> walk->action = ACTION_AGAIN;
> return 0;
> }
> - for (; addr != end; pte++, addr += PAGE_SIZE)
> + size = pte_cont(ptep_get(pte)) ? PAGE_SIZE * CONT_PTES : PAGE_SIZE;
> + cont_ptes = pte_cont(ptep_get(pte)) ? CONT_PTES : 1;
> + for (; addr != end; pte += cont_ptes, addr += size)
The better way to do this is to actually batch PTEs also when cont-pte
is not around (e.g., x86). folio_pte_batch() does that and optimized
automatically for the cont-pte bit -- which should only apply if we have
a present folio.
So this code might need some slight reshuffling (lookup the folio first,
if it's large use folio_pte_batch(), otherwise (small/no normal folio)
process individual PTEs).
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists