Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032474AbbKEMgL (ORCPT ); Thu, 5 Nov 2015 07:36:11 -0500 Received: from mail-wi0-f177.google.com ([209.85.212.177]:33919 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030793AbbKEMgJ (ORCPT ); Thu, 5 Nov 2015 07:36:09 -0500 Date: Thu, 5 Nov 2015 14:36:06 +0200 From: "Kirill A. Shutemov" To: Vladimir Davydov Cc: "Kirill A. Shutemov" , Andrew Morton , Andrea Arcangeli , Hugh Dickins , Naoya Horiguchi , Sasha Levin , Minchan Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 4/4] mm: prepare page_referenced() and page_idle to new THP refcounting Message-ID: <20151105123606.GE7614@node.shutemov.name> References: <1446564375-72143-1-git-send-email-kirill.shutemov@linux.intel.com> <1446564375-72143-5-git-send-email-kirill.shutemov@linux.intel.com> <20151105091013.GC29259@esperanza> <20151105092459.GC7614@node.shutemov.name> <20151105120726.GD29259@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151105120726.GD29259@esperanza> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1532 Lines: 53 On Thu, Nov 05, 2015 at 03:07:26PM +0300, Vladimir Davydov wrote: > @@ -849,30 +836,23 @@ static int page_referenced_one(struct page *page, struct vm_area_struct *vma, > if (pmd_page(*pmd) != page) > goto unlock_pmd; > > - if (vma->vm_flags & VM_LOCKED) { > - pra->vm_flags |= VM_LOCKED; > - ret = SWAP_FAIL; /* To break the loop */ > - goto unlock_pmd; > - } > - > - if (pmdp_clear_flush_young_notify(vma, address, pmd)) > - referenced++; > - spin_unlock(ptl); > + pte = (pte_t *)pmd; pmd_t and pte_t are not always compatible. We shouldn't pretend they are. And we shouldn't use pte_unmap_unlock() to unlock pmd table. What about interface like this (I'm not sure about helper's name): void page_check_address_transhuge(struct page *page, struct mm_struct *mm, unsigned long address, pmd_t **pmdp, pte_t **ptep, spinlock_t **ptlp); page_check_address_transhuge(page, mm, address, &pmd, &pte, &ptl); if (pmd) { /* handle pmd... */ } else if (pte) { /* handle pte... */ } else { return SWAP_AGAIN; } /* common stuff */ if (pmd) spin_unlock(ptl); else pte_unmap_unlock(pte, ptl); /* ... */ The helper shouldn't set pmd if the page is tracked to pte. -- Kirill A. Shutemov -- 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/