public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: 'Hugh Dickins' <hugh@veritas.com>,
	'David Gibson' <david@gibson.dropbear.id.au>
Cc: Andrew Morton <akpm@osdl.org>, William Irwin <wli@holomorphy.com>,
	linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: RE: hugepage: Fix hugepage logic in free_pgtables()
Date: Thu, 02 Mar 2006 19:42:15 +0000	[thread overview]
Message-ID: <200603021942.k22JgFg13221@unix-os.sc.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0603021836090.22007@goblin.wat.veritas.com>
In-Reply-To: <20060302045201.GA6627@localhost.localdomain>

Hugh Dickins wrote on Thursday, March 02, 2006 10:53 AM
> On Thu, 2 Mar 2006, 'David Gibson' wrote:
> > free_pgtables() has special logic to call hugetlb_free_pgd_range()
> > instead of the normal free_pgd_range() on hugepage VMAs.  However, the
> > test it uses to do so is incorrect: it calls is_hugepage_only_range on
> > a hugepage sized range at the start of the vma.
> > is_hugepage_only_range() will return true if the given range has any
> > intersection with a hugepage address region, and in this case the
> > given region need not be hugepage aligned.  So, for example, this test
> > can return true if called on, say, a 4k VMA immediately preceding a
> > (nicely aligned) hugepage VMA.
> > 
> > At present we get away with this because the powerpc version of
> > hugetlb_free_pgd_range() is just a call to free_pgd_range().  On ia64
> > (the only other arch with a non-trivial is_hugepage_only_range()) we
> > get away with it for a different reason; the hugepage area is not
> > contiguous with the rest of the user address space, and VMAs are not
> > permitted in between, so the test can't return a false positive there.
> > 
> > Nonetheless this should be fixed.  We do that in the patch below by
> > replacing the is_hugepage_only_range() test with an explicit test of
> > the VMA using is_vm_hugetlb_page().
> > 
> Yes, okay, you can add my
> 
> Acked-by: Hugh Dickins <hugh@veritas.com>
> 
> (ARCH_HAS... and HAVE_ARCH... have fallen into disfavour, but I
> don't think you're doing wrong by splitting the old one into two.)
> 
> But let me emphasize again, in case Andrew wonders, that no current bug
> is fixed by this (as indeed you indicate in your "we get away with this"
> comments).


I've double checked that David's patch is OK for ia64.


> Whereas there's still a real ia64 get_unmapped_area bug to be fixed,
> arising from the same confusion, that is_hugepage_only_range needs
> to mean overlaps_hugepage_only_range (as on PowerPC) rather than
> within_hugepage_only_range (as on IA64).  Is Ken fixing that one?


Yes, I'm fixing it.  See patch below.


[patch] ia64: fix is_hugepage_only_range() definition to be overlaps
        instead of within architectural restricted hugetlb address
        range.  Fix all affected usages.

Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>

--- ./include/asm-ia64/page.h.orig	2006-03-02 12:16:00.636688455 -0800
+++ ./include/asm-ia64/page.h	2006-03-02 12:23:30.151331386 -0800
@@ -147,7 +147,7 @@ typedef union ia64_va {
 				 | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT)))
 # define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
 # define is_hugepage_only_range(mm, addr, len)		\
-	 (REGION_NUMBER(addr) = RGN_HPAGE &&	\
+	 (REGION_NUMBER(addr) = RGN_HPAGE ||	\
 	  REGION_NUMBER((addr)+(len)-1) = RGN_HPAGE)
 extern unsigned int hpage_shift;
 #endif
--- ./arch/ia64/mm/hugetlbpage.c.orig	2006-03-02 12:31:12.020466353 -0800
+++ ./arch/ia64/mm/hugetlbpage.c	2006-03-02 12:31:02.944294589 -0800
@@ -112,8 +112,7 @@ void hugetlb_free_pgd_range(struct mmu_g
 			unsigned long floor, unsigned long ceiling)
 {
 	/*
-	 * This is called only when is_hugepage_only_range(addr,),
-	 * and it follows that is_hugepage_only_range(end,) also.
+	 * This is called to free hugetlb page tables.
 	 *
 	 * The offset of these addresses from the base of the hugetlb
 	 * region must be scaled down by HPAGE_SIZE/PAGE_SIZE so that
@@ -125,9 +124,9 @@ void hugetlb_free_pgd_range(struct mmu_g
 
 	addr = htlbpage_to_page(addr);
 	end  = htlbpage_to_page(end);
-	if (is_hugepage_only_range(tlb->mm, floor, HPAGE_SIZE))
+	if (REGION_NUMBER(floor) = RGN_HPAGE)
 		floor = htlbpage_to_page(floor);
-	if (is_hugepage_only_range(tlb->mm, ceiling, HPAGE_SIZE))
+	if (REGION_NUMBER(ceiling) = RGN_HPAGE)
 		ceiling = htlbpage_to_page(ceiling);
 
 	free_pgd_range(tlb, addr, end, floor, ceiling);






  parent reply	other threads:[~2006-03-02 19:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02  4:52 hugepage: Fix hugepage logic in free_pgtables() 'David Gibson'
2006-03-02 18:53 ` Hugh Dickins
2006-03-02 19:42 ` Chen, Kenneth W [this message]
2006-03-02 20:27   ` Hugh Dickins
2006-03-02 23:14   ` 'David Gibson'
2006-03-02 21:29 ` Chen, Kenneth W
2006-03-02 23:00   ` 'David Gibson'
2006-03-03  1:04 ` hugepage: Fix hugepage logic in free_pgtables() harder 'David Gibson'
2006-03-03  5:18   ` Hugh Dickins
2006-03-03  5:26     ` 'David Gibson'

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200603021942.k22JgFg13221@unix-os.sc.intel.com \
    --to=kenneth.w.chen@intel.com \
    --cc=akpm@osdl.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=hugh@veritas.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wli@holomorphy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox