Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753666AbbETOjN (ORCPT ); Wed, 20 May 2015 10:39:13 -0400 Received: from mta-out1.inet.fi ([62.71.2.227]:38834 "EHLO jenni2.inet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752657AbbETOjL (ORCPT ); Wed, 20 May 2015 10:39:11 -0400 Date: Wed, 20 May 2015 17:38:43 +0300 From: "Kirill A. Shutemov" To: Vlastimil Babka Cc: "Kirill A. Shutemov" , Andrew Morton , Andrea Arcangeli , Hugh Dickins , Dave Hansen , Mel Gorman , Rik van Riel , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , Jerome Marchand , Sasha Levin , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv5 22/28] thp: implement split_huge_pmd() Message-ID: <20150520143843.GB13921@node.dhcp.inet.fi> References: <1429823043-157133-1-git-send-email-kirill.shutemov@linux.intel.com> <1429823043-157133-23-git-send-email-kirill.shutemov@linux.intel.com> <555AF37A.2060709@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <555AF37A.2060709@suse.cz> 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: 2637 Lines: 68 On Tue, May 19, 2015 at 10:25:30AM +0200, Vlastimil Babka wrote: > On 04/23/2015 11:03 PM, Kirill A. Shutemov wrote: > >Original split_huge_page() combined two operations: splitting PMDs into > >tables of PTEs and splitting underlying compound page. This patch > >implements split_huge_pmd() which split given PMD without splitting > >other PMDs this page mapped with or underlying compound page. > > > >Without tail page refcounting, implementation of split_huge_pmd() is > >pretty straight-forward. > > > >Signed-off-by: Kirill A. Shutemov > >Tested-by: Sasha Levin > >--- > > include/linux/huge_mm.h | 11 ++++- > > mm/huge_memory.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 118 insertions(+), 1 deletion(-) > > > >diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > >index 0382230b490f..b7844c73b7db 100644 > >--- a/include/linux/huge_mm.h > >+++ b/include/linux/huge_mm.h > >@@ -94,7 +94,16 @@ extern unsigned long transparent_hugepage_flags; > > > > #define split_huge_page_to_list(page, list) BUILD_BUG() > > #define split_huge_page(page) BUILD_BUG() > >-#define split_huge_pmd(__vma, __pmd, __address) BUILD_BUG() > >+ > >+void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, > >+ unsigned long address); > >+ > >+#define split_huge_pmd(__vma, __pmd, __address) \ > >+ do { \ > >+ pmd_t *____pmd = (__pmd); \ > >+ if (unlikely(pmd_trans_huge(*____pmd))) \ > > Given that most of calls to split_huge_pmd() appear to be in > if (pmd_trans_huge(...)) branches, this unlikely() seems counter-productive. Fair enough. > >+void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, > >+ unsigned long address) > >+{ > >+ spinlock_t *ptl; > >+ struct mm_struct *mm = vma->vm_mm; > >+ unsigned long haddr = address & HPAGE_PMD_MASK; > >+ > >+ mmu_notifier_invalidate_range_start(mm, haddr, haddr + HPAGE_PMD_SIZE); > >+ ptl = pmd_lock(mm, pmd); > >+ if (likely(pmd_trans_huge(*pmd))) > > This likely is likely useless :) No, it's not. We check the pmd with pmd_trans_huge() under ptl for the first time. And __split_huge_pmd_locked() assumes pmd is huge. > >+ __split_huge_pmd_locked(vma, pmd, haddr); > >+ spin_unlock(ptl); > >+ mmu_notifier_invalidate_range_end(mm, haddr, haddr + HPAGE_PMD_SIZE); > >+} > >+ -- 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/