public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix minor error about efi memory_present
@ 2006-10-23  3:42 bibo,mao
  2006-10-23  4:45 ` Andrew Morton
  0 siblings, 1 reply; 8+ messages in thread
From: bibo,mao @ 2006-10-23  3:42 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Hi, 
   Function efi_memory_present_wrapper parameter start/end is physical address,
but function memory_present parameter is PFN, this patch converts physical
address to PFN.

  Signed-off-by: bibo, mao <bibo.mao@intel.com>

thanks
bibo,mao

diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 519e63c..141041d 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -846,7 +846,7 @@ efi_find_max_pfn(unsigned long start, un
 static int __init
 efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
 {
-	memory_present(0, start, end);
+	memory_present(0, PFN_UP(start), PFN_DOWN(end));
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] fix minor error about efi memory_present
  2006-10-23  3:42 [PATCH] fix minor error about efi memory_present bibo,mao
@ 2006-10-23  4:45 ` Andrew Morton
  2006-10-23  5:52   ` bibo,mao
  2006-10-23  8:36   ` [PATCH] vmalloc : optimization, cleanup, bugfixes Eric Dumazet
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2006-10-23  4:45 UTC (permalink / raw)
  To: bibo,mao; +Cc: linux-kernel

On Mon, 23 Oct 2006 11:42:33 +0800
"bibo,mao" <bibo.mao@intel.com> wrote:

> Hi, 
>    Function efi_memory_present_wrapper parameter start/end is physical address,
> but function memory_present parameter is PFN, this patch converts physical
> address to PFN.
> 
>   Signed-off-by: bibo, mao <bibo.mao@intel.com>
> 
> thanks
> bibo,mao
> 
> diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
> index 519e63c..141041d 100644
> --- a/arch/i386/kernel/setup.c
> +++ b/arch/i386/kernel/setup.c
> @@ -846,7 +846,7 @@ efi_find_max_pfn(unsigned long start, un
>  static int __init
>  efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
>  {
> -	memory_present(0, start, end);
> +	memory_present(0, PFN_UP(start), PFN_DOWN(end));
>  	return 0;
>  }
>  

It doesn't _seem_ like a "minor error".  How come people's machines haven't
been crashing all over the place?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fix minor error about efi memory_present
  2006-10-23  4:45 ` Andrew Morton
@ 2006-10-23  5:52   ` bibo,mao
  2006-10-23  8:36   ` [PATCH] vmalloc : optimization, cleanup, bugfixes Eric Dumazet
  1 sibling, 0 replies; 8+ messages in thread
From: bibo,mao @ 2006-10-23  5:52 UTC (permalink / raw)
  To: Andrew Morton; +Cc: bibo,mao, linux-kernel

Andrew Morton wrote:
> On Mon, 23 Oct 2006 11:42:33 +0800
> "bibo,mao" <bibo.mao@intel.com> wrote:
> 
>> Hi, 
>>    Function efi_memory_present_wrapper parameter start/end is physical address,
>> but function memory_present parameter is PFN, this patch converts physical
>> address to PFN.
>>
>>   Signed-off-by: bibo, mao <bibo.mao@intel.com>
>>
>> thanks
>> bibo,mao
>>
>> diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
>> index 519e63c..141041d 100644
>> --- a/arch/i386/kernel/setup.c
>> +++ b/arch/i386/kernel/setup.c
>> @@ -846,7 +846,7 @@ efi_find_max_pfn(unsigned long start, un
>>  static int __init
>>  efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
>>  {
>> -	memory_present(0, start, end);
>> +	memory_present(0, PFN_UP(start), PFN_DOWN(end));
>>  	return 0;
>>  }
>>  
> 
> It doesn't _seem_ like a "minor error".  How come people's machines haven't
> been crashing all over the place?
This patch is only efi bios relative, most machines in the market are
legacy bios. System only crashes when booting from EFI bios.

thanks
bibo,mao
> 
> -
> 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/
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] vmalloc : optimization, cleanup, bugfixes
  2006-10-23  4:45 ` Andrew Morton
  2006-10-23  5:52   ` bibo,mao
@ 2006-10-23  8:36   ` Eric Dumazet
  2006-10-23  9:13     ` Nick Piggin
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Dumazet @ 2006-10-23  8:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 469 bytes --]

[PATCH] vmalloc : optimization, cleanup, bugfixes

This patch does three things

1) reorder 'struct vm_struct' to speedup lookups on CPUS with small cache 
lines. The fields 'next,addr,size' should be now in the same cache line, to 
speedup lookups.

2) One minor cleanup in __get_vm_area_node()

3) Bugfixes in vmalloc_user() and vmalloc_32_user()
NULL returns from __vmalloc() and __find_vm_area() were not tested.


Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

[-- Attachment #2: vmalloc.patch --]
[-- Type: text/plain, Size: 1776 bytes --]

--- linux-2.6/include/linux/vmalloc.h	2006-10-23 10:09:48.000000000 +0200
+++ linux-2.6-ed/include/linux/vmalloc.h	2006-10-23 10:26:37.000000000 +0200
@@ -23,13 +23,14 @@
 #endif
 
 struct vm_struct {
+	/* keep next,addr,size together to speedup lookups */
+	struct vm_struct	*next;
 	void			*addr;
 	unsigned long		size;
 	unsigned long		flags;
 	struct page		**pages;
 	unsigned int		nr_pages;
 	unsigned long		phys_addr;
-	struct vm_struct	*next;
 };
 
 /*
--- linux-2.6/mm/vmalloc.c	2006-10-23 10:11:43.000000000 +0200
+++ linux-2.6-ed/mm/vmalloc.c	2006-10-23 10:17:52.000000000 +0200
@@ -180,15 +180,13 @@
 	addr = ALIGN(start, align);
 	size = PAGE_ALIGN(size);
 
+	if (unlikely(!size))
+		return NULL;
+
 	area = kmalloc_node(sizeof(*area), GFP_KERNEL, node);
 	if (unlikely(!area))
 		return NULL;
 
-	if (unlikely(!size)) {
-		kfree (area);
-		return NULL;
-	}
-
 	/*
 	 * We always allocate a guard page.
 	 */
@@ -528,11 +526,13 @@
 	void *ret;
 
 	ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
-	write_lock(&vmlist_lock);
-	area = __find_vm_area(ret);
-	area->flags |= VM_USERMAP;
-	write_unlock(&vmlist_lock);
-
+	if (ret) {
+		write_lock(&vmlist_lock);
+		area = __find_vm_area(ret);
+		if (area)
+			area->flags |= VM_USERMAP;
+		write_unlock(&vmlist_lock);
+	}
 	return ret;
 }
 EXPORT_SYMBOL(vmalloc_user);
@@ -601,11 +601,13 @@
 	void *ret;
 
 	ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
-	write_lock(&vmlist_lock);
-	area = __find_vm_area(ret);
-	area->flags |= VM_USERMAP;
-	write_unlock(&vmlist_lock);
-
+	if (ret) {
+		write_lock(&vmlist_lock);
+		area = __find_vm_area(ret);
+		if (area)
+			area->flags |= VM_USERMAP;
+		write_unlock(&vmlist_lock);
+	}
 	return ret;
 }
 EXPORT_SYMBOL(vmalloc_32_user);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vmalloc : optimization, cleanup, bugfixes
  2006-10-23  8:36   ` [PATCH] vmalloc : optimization, cleanup, bugfixes Eric Dumazet
@ 2006-10-23  9:13     ` Nick Piggin
  2006-10-23  9:30       ` Eric Dumazet
  2006-10-30 20:42       ` Zwane Mwaikambo
  0 siblings, 2 replies; 8+ messages in thread
From: Nick Piggin @ 2006-10-23  9:13 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Andrew Morton, linux-kernel

Eric Dumazet wrote:
> [PATCH] vmalloc : optimization, cleanup, bugfixes
> 
> This patch does three things
> 
> 1) reorder 'struct vm_struct' to speedup lookups on CPUS with small cache 
> lines. The fields 'next,addr,size' should be now in the same cache line, to 
> speedup lookups.
> 
> 2) One minor cleanup in __get_vm_area_node()
> 
> 3) Bugfixes in vmalloc_user() and vmalloc_32_user()
> NULL returns from __vmalloc() and __find_vm_area() were not tested.

Hmm, so they weren't. As far as testing the return of __find_vm_area,
you can just turn that into a BUG_ON(!area), because at that point,
we've established that the vmalloc succeeded.

-- 
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vmalloc : optimization, cleanup, bugfixes
  2006-10-23  9:13     ` Nick Piggin
@ 2006-10-23  9:30       ` Eric Dumazet
  2006-10-30 20:42       ` Zwane Mwaikambo
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2006-10-23  9:30 UTC (permalink / raw)
  To: Nick Piggin, Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 872 bytes --]

On Monday 23 October 2006 11:13, Nick Piggin wrote:
> Eric Dumazet wrote:
> > 3) Bugfixes in vmalloc_user() and vmalloc_32_user()
> > NULL returns from __vmalloc() and __find_vm_area() were not tested.
>
> Hmm, so they weren't. As far as testing the return of __find_vm_area,
> you can just turn that into a BUG_ON(!area), because at that point,
> we've established that the vmalloc succeeded.

OK :) 

[PATCH] vmalloc : optimization, cleanup, bugfixes

This patch does three things

1) reorder 'struct vm_struct' to speedup lookups on CPUS with small cache 
lines. The fields 'next,addr,size' should be now in the same cache line, to 
speedup lookups.

2) One minor cleanup in __get_vm_area_node()

3) Bugfixes in vmalloc_user() and vmalloc_32_user()
NULL returns from __vmalloc() and __find_vm_area() were not tested.


Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

[-- Attachment #2: vmalloc.patch --]
[-- Type: text/plain, Size: 1784 bytes --]

--- linux-2.6/include/linux/vmalloc.h	2006-10-23 10:09:48.000000000 +0200
+++ linux-2.6-ed/include/linux/vmalloc.h	2006-10-23 10:26:37.000000000 +0200
@@ -23,13 +23,14 @@
 #endif
 
 struct vm_struct {
+	/* keep next,addr,size together to speedup lookups */
+	struct vm_struct	*next;
 	void			*addr;
 	unsigned long		size;
 	unsigned long		flags;
 	struct page		**pages;
 	unsigned int		nr_pages;
 	unsigned long		phys_addr;
-	struct vm_struct	*next;
 };
 
 /*
--- linux-2.6/mm/vmalloc.c	2006-10-23 10:11:43.000000000 +0200
+++ linux-2.6-ed/mm/vmalloc.c	2006-10-23 11:26:47.000000000 +0200
@@ -180,15 +180,13 @@
 	addr = ALIGN(start, align);
 	size = PAGE_ALIGN(size);
 
+	if (unlikely(!size))
+		return NULL;
+
 	area = kmalloc_node(sizeof(*area), GFP_KERNEL, node);
 	if (unlikely(!area))
 		return NULL;
 
-	if (unlikely(!size)) {
-		kfree (area);
-		return NULL;
-	}
-
 	/*
 	 * We always allocate a guard page.
 	 */
@@ -528,11 +526,13 @@
 	void *ret;
 
 	ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
-	write_lock(&vmlist_lock);
-	area = __find_vm_area(ret);
-	area->flags |= VM_USERMAP;
-	write_unlock(&vmlist_lock);
-
+	if (ret) {
+		write_lock(&vmlist_lock);
+		area = __find_vm_area(ret);
+		BUG_ON(!area);
+		area->flags |= VM_USERMAP;
+		write_unlock(&vmlist_lock);
+	}
 	return ret;
 }
 EXPORT_SYMBOL(vmalloc_user);
@@ -601,11 +601,13 @@
 	void *ret;
 
 	ret = __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
-	write_lock(&vmlist_lock);
-	area = __find_vm_area(ret);
-	area->flags |= VM_USERMAP;
-	write_unlock(&vmlist_lock);
-
+	if (ret) {
+		write_lock(&vmlist_lock);
+		area = __find_vm_area(ret);
+		BUG_ON(!area);
+		area->flags |= VM_USERMAP;
+		write_unlock(&vmlist_lock);
+	}
 	return ret;
 }
 EXPORT_SYMBOL(vmalloc_32_user);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vmalloc : optimization, cleanup, bugfixes
  2006-10-23  9:13     ` Nick Piggin
  2006-10-23  9:30       ` Eric Dumazet
@ 2006-10-30 20:42       ` Zwane Mwaikambo
  2006-10-30 21:09         ` Eric Dumazet
  1 sibling, 1 reply; 8+ messages in thread
From: Zwane Mwaikambo @ 2006-10-30 20:42 UTC (permalink / raw)
  To: Nick Piggin; +Cc: Eric Dumazet, Andrew Morton, linux-kernel

On Mon, 23 Oct 2006, Nick Piggin wrote:

> Eric Dumazet wrote:
> > [PATCH] vmalloc : optimization, cleanup, bugfixes
> > 
> > This patch does three things
> > 
> > 1) reorder 'struct vm_struct' to speedup lookups on CPUS with small cache
> > lines. The fields 'next,addr,size' should be now in the same cache line, to
> > speedup lookups.
> > 
> > 2) One minor cleanup in __get_vm_area_node()
> > 
> > 3) Bugfixes in vmalloc_user() and vmalloc_32_user()
> > NULL returns from __vmalloc() and __find_vm_area() were not tested.
> 
> Hmm, so they weren't. As far as testing the return of __find_vm_area,
> you can just turn that into a BUG_ON(!area), because at that point,
> we've established that the vmalloc succeeded.

No need for a BUG_ON it'll simply be a NULL dereference, at which point 
we're back to the original code.

	Zwane


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vmalloc : optimization, cleanup, bugfixes
  2006-10-30 20:42       ` Zwane Mwaikambo
@ 2006-10-30 21:09         ` Eric Dumazet
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2006-10-30 21:09 UTC (permalink / raw)
  To: Zwane Mwaikambo; +Cc: Nick Piggin, Andrew Morton, linux-kernel

Zwane Mwaikambo a écrit :
> On Mon, 23 Oct 2006, Nick Piggin wrote:
> 
>> Eric Dumazet wrote:
>>> [PATCH] vmalloc : optimization, cleanup, bugfixes
>>>
>>> This patch does three things
>>>
>>> 1) reorder 'struct vm_struct' to speedup lookups on CPUS with small cache
>>> lines. The fields 'next,addr,size' should be now in the same cache line, to
>>> speedup lookups.
>>>
>>> 2) One minor cleanup in __get_vm_area_node()
>>>
>>> 3) Bugfixes in vmalloc_user() and vmalloc_32_user()
>>> NULL returns from __vmalloc() and __find_vm_area() were not tested.
>> Hmm, so they weren't. As far as testing the return of __find_vm_area,
>> you can just turn that into a BUG_ON(!area), because at that point,
>> we've established that the vmalloc succeeded.
> 
> No need for a BUG_ON it'll simply be a NULL dereference, at which point 
> we're back to the original code.

Indeed

This is what Andrew said one week ago :)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-10-30 21:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-23  3:42 [PATCH] fix minor error about efi memory_present bibo,mao
2006-10-23  4:45 ` Andrew Morton
2006-10-23  5:52   ` bibo,mao
2006-10-23  8:36   ` [PATCH] vmalloc : optimization, cleanup, bugfixes Eric Dumazet
2006-10-23  9:13     ` Nick Piggin
2006-10-23  9:30       ` Eric Dumazet
2006-10-30 20:42       ` Zwane Mwaikambo
2006-10-30 21:09         ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox