Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1263034
| From | Vladimir Davydov <vdavydov@virtuozzo.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting |
| Date | 2015-11-05 10:20 +0100 |
| Message-ID | <qroS6-4FF-17@gated-at.bofh.it> (permalink) |
| References | <qqLH4-4sG-31@gated-at.bofh.it> <qqLH5-4sG-47@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Nov 03, 2015 at 05:26:15PM +0200, Kirill A. Shutemov wrote:
...
> @@ -56,23 +56,69 @@ static int page_idle_clear_pte_refs_one(struct page *page,
> {
> struct mm_struct *mm = vma->vm_mm;
> spinlock_t *ptl;
> + pgd_t *pgd;
> + pud_t *pud;
> pmd_t *pmd;
> pte_t *pte;
> bool referenced = false;
>
> - if (unlikely(PageTransHuge(page))) {
> - pmd = page_check_address_pmd(page, mm, addr, &ptl);
> - if (pmd) {
> - referenced = pmdp_clear_young_notify(vma, addr, pmd);
> + pgd = pgd_offset(mm, addr);
> + if (!pgd_present(*pgd))
> + return SWAP_AGAIN;
> + pud = pud_offset(pgd, addr);
> + if (!pud_present(*pud))
> + return SWAP_AGAIN;
> + pmd = pmd_offset(pud, addr);
> +
> + if (pmd_trans_huge(*pmd)) {
> + ptl = pmd_lock(mm, pmd);
> + if (!pmd_present(*pmd))
> + goto unlock_pmd;
> + if (unlikely(!pmd_trans_huge(*pmd))) {
> spin_unlock(ptl);
> + goto map_pte;
> }
> +
> + if (pmd_page(*pmd) != page)
> + goto unlock_pmd;
> +
> + referenced = pmdp_clear_young_notify(vma, addr, pmd);
> + spin_unlock(ptl);
> + goto found;
> +unlock_pmd:
> + spin_unlock(ptl);
> + return SWAP_AGAIN;
> } else {
> - pte = page_check_address(page, mm, addr, &ptl, 0);
> - if (pte) {
> - referenced = ptep_clear_young_notify(vma, addr, pte);
> - pte_unmap_unlock(pte, ptl);
> - }
> + pmd_t pmde = *pmd;
> + barrier();
> + if (!pmd_present(pmde) || pmd_trans_huge(pmde))
> + return SWAP_AGAIN;
> +
> + }
> +map_pte:
> + pte = pte_offset_map(pmd, addr);
> + if (!pte_present(*pte)) {
> + pte_unmap(pte);
> + return SWAP_AGAIN;
> }
> +
> + ptl = pte_lockptr(mm, pmd);
> + spin_lock(ptl);
> +
> + if (!pte_present(*pte)) {
> + pte_unmap_unlock(pte, ptl);
> + return SWAP_AGAIN;
> + }
> +
> + /* THP can be referenced by any subpage */
> + if (pte_pfn(*pte) - page_to_pfn(page) >= hpage_nr_pages(page)) {
> + pte_unmap_unlock(pte, ptl);
> + return SWAP_AGAIN;
> + }
> +
> + referenced = ptep_clear_young_notify(vma, addr, pte);
> + pte_unmap_unlock(pte, ptl);
> +found:
Can't we hide this stuff in a helper function, which would be used by
both page_referenced_one and page_idle_clear_pte_refs_one, instead of
duplicating page_referenced_one code here?
Thanks,
Vladimir
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/4] Bugfixes for THP refcounting "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100
[PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 10:20 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 10:30 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 13:10 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 13:40 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 14:00 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 17:40 +0100
[PATCH] mm: add page_check_address_transhuge helper Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-06 15:40 +0100
Re: [PATCH] mm: add page_check_address_transhuge helper "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-06 16:30 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 14:00 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-11-05 17:10 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-05 18:30 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Andrew Morton <akpm@linux-foundation.org> - 2015-11-06 01:40 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-06 11:30 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Andrew Morton <akpm@linux-foundation.org> - 2015-11-06 23:40 +0100
Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-09 00:50 +0100
[PATCH 2/4] mm: duplicate rmap reference for hugetlb pages as compound "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100
[PATCH 3/4] thp: fix split vs. unmap race "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-03 16:30 +0100
csiph-web