public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] enable acpi_os_allocate() to allocate larger memory
@ 2005-05-23 11:28 Kenji Kaneshige
       [not found] ` <4291BE51.1090004-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Kenji Kaneshige @ 2005-05-23 11:28 UTC (permalink / raw)
  To: Len Brown, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi,

I encountered the problem that I could not read /proc/acpi/dsdt on my
machine. It turned out that acpi_os_allocate() was failed to allocate
buffer. The DSDT on my machine was too large for acpi_os_allocate() to
allocate the buffer.

Current acpi_os_allocate() interface is implemented by using kmalloc()
whose maximum allocation size is limited. So acpi_os_allocate() would
fail if larger size than maximum allocation size of kmalloc was
specified. I think this restriction should be removed.

The following patch enables acpi_os_allocate() to allocate larger
memory.

Signed-off-by: Kenji Kaneshige <kaneshige.kenji-+CUm20s59erQFUHtdCDX3A@public.gmane.org>


---

 linux-2.6.12-rc4-kanesige/drivers/acpi/osl.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff -puN drivers/acpi/osl.c~fix_acpi_os_allocate drivers/acpi/osl.c
--- linux-2.6.12-rc4/drivers/acpi/osl.c~fix_acpi_os_allocate	2005-05-23 20:09:34.000000000 +0900
+++ linux-2.6.12-rc4-kanesige/drivers/acpi/osl.c	2005-05-23 20:09:34.000000000 +0900
@@ -37,6 +37,7 @@
 #include <linux/delay.h>
 #include <linux/workqueue.h>
 #include <linux/nmi.h>
+#include <linux/vmalloc.h>
 #include <acpi/acpi.h>
 #include <asm/io.h>
 #include <acpi/acpi_bus.h>
@@ -145,13 +146,20 @@ acpi_os_vprintf(const char *fmt, va_list
 void *
 acpi_os_allocate(acpi_size size)
 {
-	return kmalloc(size, GFP_KERNEL);
+	void *ptr = kmalloc(size, GFP_KERNEL);
+	if (!ptr)
+		ptr = vmalloc(size);
+	return ptr;
 }
 
 void
 acpi_os_free(void *ptr)
 {
-	kfree(ptr);
+	if (VMALLOC_START <= (unsigned long)ptr &&
+	    (unsigned long)ptr < VMALLOC_END)
+		vfree(ptr);
+	else
+		kfree(ptr);
 }
 EXPORT_SYMBOL(acpi_os_free);
 

_


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click

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

* Re: [PATCH] enable acpi_os_allocate() to allocate larger memory
       [not found] ` <4291BE51.1090004-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
@ 2005-05-23 13:42   ` Alan Cox
       [not found]     ` <1116855778.5744.47.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2005-05-23 13:42 UTC (permalink / raw)
  To: Kenji Kaneshige; +Cc: Len Brown, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Llu, 2005-05-23 at 12:28, Kenji Kaneshige wrote:
> -	return kmalloc(size, GFP_KERNEL);
> +	void *ptr = kmalloc(size, GFP_KERNEL);
> +	if (!ptr)


This looks reasonable. Do you think it would be better to use
GFP_KERNEL|__GFP_NORETRY|__GFP_NOWARN ?

Tbe __GFP_NORETRY tells the vm it is ok to fail the kmalloc rather than
wait
and try for a long long time. The _NOWARN says "we know this can fail in
normal
use so don't log failure". (See include/linux/gfp.h for more
documentation)

Alan



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click

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

* Re: [PATCH] enable acpi_os_allocate() to allocate larger memory
       [not found]     ` <1116855778.5744.47.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2005-05-24  2:27       ` Kenji Kaneshige
  0 siblings, 0 replies; 3+ messages in thread
From: Kenji Kaneshige @ 2005-05-24  2:27 UTC (permalink / raw)
  To: Alan Cox; +Cc: Len Brown, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Alan Cox wrote:
> On Llu, 2005-05-23 at 12:28, Kenji Kaneshige wrote:
> 
>>-	return kmalloc(size, GFP_KERNEL);
>>+	void *ptr = kmalloc(size, GFP_KERNEL);
>>+	if (!ptr)
> 
> 
> 
> This looks reasonable. Do you think it would be better to use
> GFP_KERNEL|__GFP_NORETRY|__GFP_NOWARN ?

Yes, this makes sense.
I'll update the patch and post it again.

Thanks,
Kenji Kaneshige


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click

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

end of thread, other threads:[~2005-05-24  2:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-23 11:28 [PATCH] enable acpi_os_allocate() to allocate larger memory Kenji Kaneshige
     [not found] ` <4291BE51.1090004-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2005-05-23 13:42   ` Alan Cox
     [not found]     ` <1116855778.5744.47.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2005-05-24  2:27       ` Kenji Kaneshige

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