Re: [PATCH 3/5] metag: hugetlb: convert to vm_unmapped_area()

2013-02-15 Thread James Hogan
On 15/02/13 08:04, Michel Lespinasse wrote:
> On Wed, Feb 13, 2013 at 4:03 AM, James Hogan  wrote:
>> Convert hugetlb_get_unmapped_area_new_pmd() to use vm_unmapped_area()
>> rather than searching the virtual address space itself. This fixes the
>> following errors in linux-next due to the specified members being
>> removed after other architectures have already been converted:
>>
>> arch/metag/mm/hugetlbpage.c: In function 'hugetlb_get_unmapped_area_new_pmd':
>> arch/metag/mm/hugetlbpage.c:199: error: 'struct mm_struct' has no member 
>> named 'cached_hole_size'
>> arch/metag/mm/hugetlbpage.c:200: error: 'struct mm_struct' has no member 
>> named 'free_area_cache'
>> arch/metag/mm/hugetlbpage.c:215: error: 'struct mm_struct' has no member 
>> named 'cached_hole_size'
>>
>> Signed-off-by: James Hogan 
>> Cc: Michel Lespinasse 
> 
> Looks good. Just one thing, which I don't have full context to evaluate:
> 
>> +   info.align_mask = PAGE_MASK & HUGEPT_MASK;
> 
> This will work only if HUGEPT_MASK == HUGEPT_SIZE - 1, as opposed to
> the PAGE_MASK definition which is ~(PAGE_SIZE - 1).
> Not sure how HUGEPT_MASK is defined, so please double check that.
> 
> Acked-by: Michel Lespinasse 
> 

Thanks Michel. HUGEPT_MASK is indeed equal to HUGEPT_SIZE - 1. I
originally did info.align_mask = PAGE_MASK & ~HUGEPT_MASK accidentally
and as you say it just didn't work :)

Cheers
James

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/5] metag: hugetlb: convert to vm_unmapped_area()

2013-02-15 Thread Michel Lespinasse
On Wed, Feb 13, 2013 at 4:03 AM, James Hogan  wrote:
> Convert hugetlb_get_unmapped_area_new_pmd() to use vm_unmapped_area()
> rather than searching the virtual address space itself. This fixes the
> following errors in linux-next due to the specified members being
> removed after other architectures have already been converted:
>
> arch/metag/mm/hugetlbpage.c: In function 'hugetlb_get_unmapped_area_new_pmd':
> arch/metag/mm/hugetlbpage.c:199: error: 'struct mm_struct' has no member 
> named 'cached_hole_size'
> arch/metag/mm/hugetlbpage.c:200: error: 'struct mm_struct' has no member 
> named 'free_area_cache'
> arch/metag/mm/hugetlbpage.c:215: error: 'struct mm_struct' has no member 
> named 'cached_hole_size'
>
> Signed-off-by: James Hogan 
> Cc: Michel Lespinasse 

Looks good. Just one thing, which I don't have full context to evaluate:

> +   info.align_mask = PAGE_MASK & HUGEPT_MASK;

This will work only if HUGEPT_MASK == HUGEPT_SIZE - 1, as opposed to
the PAGE_MASK definition which is ~(PAGE_SIZE - 1).
Not sure how HUGEPT_MASK is defined, so please double check that.

Acked-by: Michel Lespinasse 

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/5] metag: hugetlb: convert to vm_unmapped_area()

2013-02-15 Thread Michel Lespinasse
On Wed, Feb 13, 2013 at 4:03 AM, James Hogan james.ho...@imgtec.com wrote:
 Convert hugetlb_get_unmapped_area_new_pmd() to use vm_unmapped_area()
 rather than searching the virtual address space itself. This fixes the
 following errors in linux-next due to the specified members being
 removed after other architectures have already been converted:

 arch/metag/mm/hugetlbpage.c: In function 'hugetlb_get_unmapped_area_new_pmd':
 arch/metag/mm/hugetlbpage.c:199: error: 'struct mm_struct' has no member 
 named 'cached_hole_size'
 arch/metag/mm/hugetlbpage.c:200: error: 'struct mm_struct' has no member 
 named 'free_area_cache'
 arch/metag/mm/hugetlbpage.c:215: error: 'struct mm_struct' has no member 
 named 'cached_hole_size'

 Signed-off-by: James Hogan james.ho...@imgtec.com
 Cc: Michel Lespinasse wal...@google.com

Looks good. Just one thing, which I don't have full context to evaluate:

 +   info.align_mask = PAGE_MASK  HUGEPT_MASK;

This will work only if HUGEPT_MASK == HUGEPT_SIZE - 1, as opposed to
the PAGE_MASK definition which is ~(PAGE_SIZE - 1).
Not sure how HUGEPT_MASK is defined, so please double check that.

Acked-by: Michel Lespinasse wal...@google.com

-- 
Michel Walken Lespinasse
A program is never fully debugged until the last user dies.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/5] metag: hugetlb: convert to vm_unmapped_area()

2013-02-15 Thread James Hogan
On 15/02/13 08:04, Michel Lespinasse wrote:
 On Wed, Feb 13, 2013 at 4:03 AM, James Hogan james.ho...@imgtec.com wrote:
 Convert hugetlb_get_unmapped_area_new_pmd() to use vm_unmapped_area()
 rather than searching the virtual address space itself. This fixes the
 following errors in linux-next due to the specified members being
 removed after other architectures have already been converted:

 arch/metag/mm/hugetlbpage.c: In function 'hugetlb_get_unmapped_area_new_pmd':
 arch/metag/mm/hugetlbpage.c:199: error: 'struct mm_struct' has no member 
 named 'cached_hole_size'
 arch/metag/mm/hugetlbpage.c:200: error: 'struct mm_struct' has no member 
 named 'free_area_cache'
 arch/metag/mm/hugetlbpage.c:215: error: 'struct mm_struct' has no member 
 named 'cached_hole_size'

 Signed-off-by: James Hogan james.ho...@imgtec.com
 Cc: Michel Lespinasse wal...@google.com
 
 Looks good. Just one thing, which I don't have full context to evaluate:
 
 +   info.align_mask = PAGE_MASK  HUGEPT_MASK;
 
 This will work only if HUGEPT_MASK == HUGEPT_SIZE - 1, as opposed to
 the PAGE_MASK definition which is ~(PAGE_SIZE - 1).
 Not sure how HUGEPT_MASK is defined, so please double check that.
 
 Acked-by: Michel Lespinasse wal...@google.com
 

Thanks Michel. HUGEPT_MASK is indeed equal to HUGEPT_SIZE - 1. I
originally did info.align_mask = PAGE_MASK  ~HUGEPT_MASK accidentally
and as you say it just didn't work :)

Cheers
James

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] metag: hugetlb: convert to vm_unmapped_area()

2013-02-13 Thread James Hogan
Convert hugetlb_get_unmapped_area_new_pmd() to use vm_unmapped_area()
rather than searching the virtual address space itself. This fixes the
following errors in linux-next due to the specified members being
removed after other architectures have already been converted:

arch/metag/mm/hugetlbpage.c: In function 'hugetlb_get_unmapped_area_new_pmd':
arch/metag/mm/hugetlbpage.c:199: error: 'struct mm_struct' has no member named 
'cached_hole_size'
arch/metag/mm/hugetlbpage.c:200: error: 'struct mm_struct' has no member named 
'free_area_cache'
arch/metag/mm/hugetlbpage.c:215: error: 'struct mm_struct' has no member named 
'cached_hole_size'

Signed-off-by: James Hogan 
Cc: Michel Lespinasse 
---
 arch/metag/mm/hugetlbpage.c |   52 --
 1 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
index 24ceed4..3c52fa6 100644
--- a/arch/metag/mm/hugetlbpage.c
+++ b/arch/metag/mm/hugetlbpage.c
@@ -192,43 +192,15 @@ new_search:
 static unsigned long
 hugetlb_get_unmapped_area_new_pmd(unsigned long len)
 {
-   struct mm_struct *mm = current->mm;
-   struct vm_area_struct *vma;
-   unsigned long start_addr, addr;
-
-   if (ALIGN_HUGEPT(len) > mm->cached_hole_size)
-   start_addr = mm->free_area_cache;
-   else
-   start_addr = TASK_UNMAPPED_BASE;
-
-new_search:
-   addr = ALIGN_HUGEPT(start_addr);
-
-   for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
-   if (TASK_SIZE - len < addr) {
-   /*
-* Start a new search - just in case we missed
-* some holes.
-*/
-   if (start_addr != TASK_UNMAPPED_BASE) {
-   start_addr = TASK_UNMAPPED_BASE;
-   mm->cached_hole_size = 0;
-   goto new_search;
-   }
-   return 0;
-   }
-   /* skip ahead if we've aligned right over some vmas */
-   if (vma && vma->vm_end <= addr)
-   continue;
-   if (!vma || ALIGN_HUGEPT(addr + len) <= vma->vm_start) {
-#if HPAGE_SHIFT < HUGEPT_SHIFT
-   if (len & HUGEPT_MASK)
-   mm->context.part_huge = addr + len;
-#endif
-   return addr;
-   }
-   addr = ALIGN_HUGEPT(vma->vm_end);
-   }
+   struct vm_unmapped_area_info info;
+
+   info.flags = 0;
+   info.length = len;
+   info.low_limit = TASK_UNMAPPED_BASE;
+   info.high_limit = TASK_SIZE;
+   info.align_mask = PAGE_MASK & HUGEPT_MASK;
+   info.align_offset = 0;
+   return vm_unmapped_area();
 }
 
 unsigned long
@@ -266,11 +238,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long 
addr,
 * Find an unmapped naturally aligned set of 4MB blocks that we can use
 * for huge pages.
 */
-   addr = hugetlb_get_unmapped_area_new_pmd(len);
-   if (likely(addr))
-   return addr;
-
-   return -EINVAL;
+   return hugetlb_get_unmapped_area_new_pmd(len);
 }
 
 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
-- 
1.7.7.6


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5] metag: hugetlb: convert to vm_unmapped_area()

2013-02-13 Thread James Hogan
Convert hugetlb_get_unmapped_area_new_pmd() to use vm_unmapped_area()
rather than searching the virtual address space itself. This fixes the
following errors in linux-next due to the specified members being
removed after other architectures have already been converted:

arch/metag/mm/hugetlbpage.c: In function 'hugetlb_get_unmapped_area_new_pmd':
arch/metag/mm/hugetlbpage.c:199: error: 'struct mm_struct' has no member named 
'cached_hole_size'
arch/metag/mm/hugetlbpage.c:200: error: 'struct mm_struct' has no member named 
'free_area_cache'
arch/metag/mm/hugetlbpage.c:215: error: 'struct mm_struct' has no member named 
'cached_hole_size'

Signed-off-by: James Hogan james.ho...@imgtec.com
Cc: Michel Lespinasse wal...@google.com
---
 arch/metag/mm/hugetlbpage.c |   52 --
 1 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
index 24ceed4..3c52fa6 100644
--- a/arch/metag/mm/hugetlbpage.c
+++ b/arch/metag/mm/hugetlbpage.c
@@ -192,43 +192,15 @@ new_search:
 static unsigned long
 hugetlb_get_unmapped_area_new_pmd(unsigned long len)
 {
-   struct mm_struct *mm = current-mm;
-   struct vm_area_struct *vma;
-   unsigned long start_addr, addr;
-
-   if (ALIGN_HUGEPT(len)  mm-cached_hole_size)
-   start_addr = mm-free_area_cache;
-   else
-   start_addr = TASK_UNMAPPED_BASE;
-
-new_search:
-   addr = ALIGN_HUGEPT(start_addr);
-
-   for (vma = find_vma(mm, addr); ; vma = vma-vm_next) {
-   if (TASK_SIZE - len  addr) {
-   /*
-* Start a new search - just in case we missed
-* some holes.
-*/
-   if (start_addr != TASK_UNMAPPED_BASE) {
-   start_addr = TASK_UNMAPPED_BASE;
-   mm-cached_hole_size = 0;
-   goto new_search;
-   }
-   return 0;
-   }
-   /* skip ahead if we've aligned right over some vmas */
-   if (vma  vma-vm_end = addr)
-   continue;
-   if (!vma || ALIGN_HUGEPT(addr + len) = vma-vm_start) {
-#if HPAGE_SHIFT  HUGEPT_SHIFT
-   if (len  HUGEPT_MASK)
-   mm-context.part_huge = addr + len;
-#endif
-   return addr;
-   }
-   addr = ALIGN_HUGEPT(vma-vm_end);
-   }
+   struct vm_unmapped_area_info info;
+
+   info.flags = 0;
+   info.length = len;
+   info.low_limit = TASK_UNMAPPED_BASE;
+   info.high_limit = TASK_SIZE;
+   info.align_mask = PAGE_MASK  HUGEPT_MASK;
+   info.align_offset = 0;
+   return vm_unmapped_area(info);
 }
 
 unsigned long
@@ -266,11 +238,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long 
addr,
 * Find an unmapped naturally aligned set of 4MB blocks that we can use
 * for huge pages.
 */
-   addr = hugetlb_get_unmapped_area_new_pmd(len);
-   if (likely(addr))
-   return addr;
-
-   return -EINVAL;
+   return hugetlb_get_unmapped_area_new_pmd(len);
 }
 
 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
-- 
1.7.7.6


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/