2004-06-26 13:17:17

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH] kill mm_struct.used_hugetlb

Hello.

mm_struct.used_hugetlb used to eliminate costly find_vma()
from follow_page(). Now it is used only in ia64 version of
follow_huge_addr(). I know nothing about ia64, but this
REGION_NUMBER() looks simple enough to kill used_hugetlb.

There is debug version (commented out) of follow_huge_addr()
in i386 which looks at used_hugetlb, but it can work without
this check.

Am i missed somethimg?

Oleg.

Signed-off: Oleg Nesterov

diff -urp 6.7-clean/arch/i386/mm/hugetlbpage.c 6.7-hugetlb/arch/i386/mm/hugetlbpage.c
--- 6.7-clean/arch/i386/mm/hugetlbpage.c 2004-05-24 14:15:58.000000000 +0400
+++ 6.7-hugetlb/arch/i386/mm/hugetlbpage.c 2004-06-26 16:48:08.000000000 +0400
@@ -147,9 +147,6 @@ follow_huge_addr(struct mm_struct *mm, u
struct page *page;
struct vm_area_struct *vma;

- if (! mm->used_hugetlb)
- return ERR_PTR(-EINVAL);
-
vma = find_vma(mm, addr);
if (!vma || !is_vm_hugetlb_page(vma))
return ERR_PTR(-EINVAL);
diff -urp 6.7-clean/arch/ia64/mm/hugetlbpage.c 6.7-hugetlb/arch/ia64/mm/hugetlbpage.c
--- 6.7-clean/arch/ia64/mm/hugetlbpage.c 2004-05-24 14:15:58.000000000 +0400
+++ 6.7-hugetlb/arch/ia64/mm/hugetlbpage.c 2004-06-26 16:48:21.000000000 +0400
@@ -158,8 +158,6 @@ struct page *follow_huge_addr(struct mm_
struct page *page;
pte_t *ptep;

- if (! mm->used_hugetlb)
- return ERR_PTR(-EINVAL);
if (REGION_NUMBER(addr) != REGION_HPAGE)
return ERR_PTR(-EINVAL);

diff -urp 6.7-clean/include/linux/hugetlb.h 6.7-hugetlb/include/linux/hugetlb.h
--- 6.7-clean/include/linux/hugetlb.h 2004-06-08 13:44:18.000000000 +0400
+++ 6.7-hugetlb/include/linux/hugetlb.h 2004-06-26 16:50:59.000000000 +0400
@@ -34,13 +34,6 @@ extern unsigned long max_huge_pages;
extern const unsigned long hugetlb_zero, hugetlb_infinity;
extern int sysctl_hugetlb_shm_group;

-static inline void
-mark_mm_hugetlb(struct mm_struct *mm, struct vm_area_struct *vma)
-{
- if (is_vm_hugetlb_page(vma))
- mm->used_hugetlb = 1;
-}
-
#ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
#define is_hugepage_only_range(addr, len) 0
#define hugetlb_free_pgtables(tlb, prev, start, end) do { } while (0)
@@ -72,7 +65,6 @@ static inline unsigned long hugetlb_tota
#define unmap_hugepage_range(vma, start, end) BUG()
#define is_hugepage_mem_enough(size) 0
#define hugetlb_report_meminfo(buf) 0
-#define mark_mm_hugetlb(mm, vma) do { } while (0)
#define follow_huge_pmd(mm, addr, pmd, write) 0
#define is_aligned_hugepage_range(addr, len) 0
#define prepare_hugepage_range(addr, len) (-EINVAL)
diff -urp 6.7-clean/include/linux/sched.h 6.7-hugetlb/include/linux/sched.h
--- 6.7-clean/include/linux/sched.h 2004-06-16 12:38:59.000000000 +0400
+++ 6.7-hugetlb/include/linux/sched.h 2004-06-26 16:49:06.000000000 +0400
@@ -217,9 +217,6 @@ struct mm_struct {
unsigned long saved_auxv[40]; /* for /proc/PID/auxv */

unsigned dumpable:1;
-#ifdef CONFIG_HUGETLB_PAGE
- int used_hugetlb;
-#endif
cpumask_t cpu_vm_mask;

/* Architecture-specific MM context */
diff -urp 6.7-clean/mm/mmap.c 6.7-hugetlb/mm/mmap.c
--- 6.7-clean/mm/mmap.c 2004-06-08 13:44:19.000000000 +0400
+++ 6.7-hugetlb/mm/mmap.c 2004-06-26 16:51:21.000000000 +0400
@@ -318,7 +318,6 @@ static void vma_link(struct mm_struct *m
if (mapping)
spin_unlock(&mapping->i_mmap_lock);

- mark_mm_hugetlb(mm, vma);
mm->map_count++;
validate_mm(mm);
}


2004-06-28 01:44:43

by David Gibson

[permalink] [raw]
Subject: Re: [PATCH] kill mm_struct.used_hugetlb


On Sat, Jun 26, 2004 at 05:20:20PM +0400, Oleg Nesterov wrote:
> Hello.
>
> mm_struct.used_hugetlb used to eliminate costly find_vma()
> from follow_page(). Now it is used only in ia64 version of
> follow_huge_addr(). I know nothing about ia64, but this
> REGION_NUMBER() looks simple enough to kill used_hugetlb.
>
> There is debug version (commented out) of follow_huge_addr()
> in i386 which looks at used_hugetlb, but it can work without
> this check.
>
> Am i missed somethimg?

Sounds like an excellent idea to me. The find_vma()s were already
bogus - no-one used the vma returned by hugepage_vma(), except to
check if it was NULL or not. On all archs, whether the address is
hugepage or not can be determined from the address, either by walking
the pagetables or just by checking the address's range.

--
David Gibson | For every complex problem there is a
david AT gibson.dropbear.id.au | solution which is simple, neat and
| wrong.
http://www.ozlabs.org/people/dgibson