From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756374Ab1JYCv6 (ORCPT ); Mon, 24 Oct 2011 22:51:58 -0400 Received: from mga09.intel.com ([134.134.136.24]:39962 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756354Ab1JYCv5 (ORCPT ); Mon, 24 Oct 2011 22:51:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.67,352,1309762800"; d="scan'208";a="66809823" Subject: [patch 3/5]thp: add tlb_remove_pmd_tlb_entry From: Shaohua Li To: Andrew Morton Cc: aarcange@redhat.com, Hugh Dickins , linux-mm , lkml Content-Type: text/plain; charset="UTF-8" Date: Tue, 25 Oct 2011 10:59:31 +0800 Message-ID: <1319511571.22361.139.camel@sli10-conroe> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have tlb_remove_tlb_entry to indicate a pte tlb flush entry should be flushed, but not a corresponding API for pmd entry. This isn't a problem so far because THP is only for x86 currently and tlb_flush() under x86 will flush entire TLB. But thsi is confusion and could be missed if thp is ported to other arch. Signed-off-by: Shaohua Li --- arch/x86/include/asm/tlb.h | 1 + include/asm-generic/tlb.h | 10 ++++++++++ include/linux/huge_mm.h | 2 +- mm/huge_memory.c | 3 ++- mm/memory.c | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) Index: linux/arch/x86/include/asm/tlb.h =================================================================== --- linux.orig/arch/x86/include/asm/tlb.h 2011-10-25 09:00:39.000000000 +0800 +++ linux/arch/x86/include/asm/tlb.h 2011-10-25 09:02:52.000000000 +0800 @@ -4,6 +4,7 @@ #define tlb_start_vma(tlb, vma) do { } while (0) #define tlb_end_vma(tlb, vma) do { } while (0) #define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0) +#define __tlb_remove_pmd_tlb_entry(tlb, pmdp, address) do { } while (0) #define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) #include Index: linux/include/asm-generic/tlb.h =================================================================== --- linux.orig/include/asm-generic/tlb.h 2011-10-25 09:00:23.000000000 +0800 +++ linux/include/asm-generic/tlb.h 2011-10-25 09:18:01.000000000 +0800 @@ -139,6 +139,16 @@ static inline void tlb_remove_page(struc __tlb_remove_tlb_entry(tlb, ptep, address); \ } while (0) +#ifndef __tlb_remove_pmd_tlb_entry +#define __tlb_remove_pmd_tlb_entry(tlb, pmdp, address) do {} while(0) +#endif + +#define tlb_remove_pmd_tlb_entry(tlb, pmdp, address) \ + do { \ + tlb->need_flush = 1; \ + __tlb_remove_pmd_tlb_entry(tlb, pmdp, address); \ + } while (0) + #define pte_free_tlb(tlb, ptep, address) \ do { \ tlb->need_flush = 1; \ Index: linux/include/linux/huge_mm.h =================================================================== --- linux.orig/include/linux/huge_mm.h 2011-10-25 09:07:12.000000000 +0800 +++ linux/include/linux/huge_mm.h 2011-10-25 09:07:44.000000000 +0800 @@ -18,7 +18,7 @@ extern struct page *follow_trans_huge_pm unsigned int flags); extern int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, - pmd_t *pmd); + pmd_t *pmd, unsigned long addr); extern int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, unsigned long end, unsigned char *vec); Index: linux/mm/huge_memory.c =================================================================== --- linux.orig/mm/huge_memory.c 2011-10-25 09:00:07.000000000 +0800 +++ linux/mm/huge_memory.c 2011-10-25 09:06:55.000000000 +0800 @@ -1005,7 +1005,7 @@ out: } int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, - pmd_t *pmd) + pmd_t *pmd, unsigned long addr) { int ret = 0; @@ -1021,6 +1021,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, pgtable = get_pmd_huge_pte(tlb->mm); page = pmd_page(*pmd); pmd_clear(pmd); + tlb_remove_pmd_tlb_entry(tlb, pmd, addr); page_remove_rmap(page); VM_BUG_ON(page_mapcount(page) < 0); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); Index: linux/mm/memory.c =================================================================== --- linux.orig/mm/memory.c 2011-10-25 09:07:49.000000000 +0800 +++ linux/mm/memory.c 2011-10-25 09:08:29.000000000 +0800 @@ -1231,7 +1231,7 @@ static inline unsigned long zap_pmd_rang if (next-addr != HPAGE_PMD_SIZE) { VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem)); split_huge_page_pmd(vma->vm_mm, pmd); - } else if (zap_huge_pmd(tlb, vma, pmd)) + } else if (zap_huge_pmd(tlb, vma, pmd, addr)) continue; /* fall through */ }