All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND] [PATCH] ACPI - change GFP_ATOMIC to GFP_KERNEL for non-atomic allocation
@ 2006-08-07 14:30 Jiri Kosina
  2006-08-07 20:58 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2006-08-07 14:30 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-acpi, linux-kernel, Andrew Morton

Hi,

acpi_pci_link_set() allocates with GFP_ATOMIC. On resume from suspend,
this is called with interrupts off, otherwise GFP_KERNEL is safe.

On the other hand, when resuming from suspend with interrupts off, the 
following callchain allocates with GFP_KERNEL, which is wrong:

acpi_pci_link_resume -> acpi_pci_link_set -> acpi_set_current_resources ->
acpi_rs_set_srs_method_data -> acpi_ut_create_internal_object_dbg ->
acpi_ut_allocate_object_desc_dbg -> acpi_os_acquire_object ->
kmem_cache_alloc(GFP_KERNEL) flag.

Resending patch, which didn't make it into -rc4, to fix both issues. The
patch is intentionally using irqs_disabled() and does not check in_resume
flag, as this is marked for removal (which is for example how
acpi_os_allocate() checks whether it should perform GFP_KERNEL or
GFP_ATOMIC allocation).

Signed-off-by: Jiri Kosina <jikos@jikos.cz>

--- drivers/acpi/osl.c.orig	2006-07-15 21:00:43.000000000 +0200
+++ drivers/acpi/osl.c	2006-07-23 16:03:08.000000000 +0200
@@ -1141,7 +1141,13 @@ acpi_status acpi_os_release_object(acpi_
 
 void *acpi_os_acquire_object(acpi_cache_t * cache)
 {
-	void *object = kmem_cache_alloc(cache, GFP_KERNEL);
+	void *object;
+
+	/* irqs could be disabled when resuming from suspend */
+	if (irqs_disabled())
+		object = kmem_cache_alloc(cache, GFP_ATOMIC);
+	else
+		object = kmem_cache_alloc(cache, GFP_KERNEL);
 	WARN_ON(!object);
 	return object;
 }
--- drivers/acpi/pci_link.c.orig	2006-07-15 21:00:43.000000000 +0200
+++ drivers/acpi/pci_link.c	2006-07-23 16:01:42.000000000 +0200
@@ -318,7 +318,12 @@ static int acpi_pci_link_set(struct acpi
 	if (!link || !irq)
 		return_VALUE(-EINVAL);
 
-	resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
+	/* irqs could be disabled when resuming from suspend */
+	if (irqs_disabled())
+		resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
+	else
+		resource = kmalloc(sizeof(*resource) + 1, GFP_KERNEL);
+	
 	if (!resource)
 		return_VALUE(-ENOMEM);
 

-- 
JiKos.

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

* Re: [RESEND] [PATCH] ACPI - change GFP_ATOMIC to GFP_KERNEL for non-atomic allocation
  2006-08-07 14:30 [RESEND] [PATCH] ACPI - change GFP_ATOMIC to GFP_KERNEL for non-atomic allocation Jiri Kosina
@ 2006-08-07 20:58 ` Andrew Morton
  2006-08-08  1:12   ` Jiri Kosina
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2006-08-07 20:58 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Len Brown, linux-acpi, linux-kernel

On Mon, 7 Aug 2006 16:30:43 +0200 (CEST)
Jiri Kosina <jikos@jikos.cz> wrote:

> acpi_pci_link_set() allocates with GFP_ATOMIC. On resume from suspend,
> this is called with interrupts off, otherwise GFP_KERNEL is safe.
> 
> On the other hand, when resuming from suspend with interrupts off, the 
> following callchain allocates with GFP_KERNEL, which is wrong:
> 
> acpi_pci_link_resume -> acpi_pci_link_set -> acpi_set_current_resources ->
> acpi_rs_set_srs_method_data -> acpi_ut_create_internal_object_dbg ->
> acpi_ut_allocate_object_desc_dbg -> acpi_os_acquire_object ->
> kmem_cache_alloc(GFP_KERNEL) flag.
> 
> Resending patch, which didn't make it into -rc4, to fix both issues. The
> patch is intentionally using irqs_disabled() and does not check in_resume
> flag, as this is marked for removal (which is for example how
> acpi_os_allocate() checks whether it should perform GFP_KERNEL or
> GFP_ATOMIC allocation).

acpi_os_acquire_object() is fixed in -rc4.  I queued the
acpi_pci_link_set() improvement for sending on to Len, thanks.  

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

* Re: [RESEND] [PATCH] ACPI - change GFP_ATOMIC to GFP_KERNEL for non-atomic allocation
  2006-08-07 20:58 ` Andrew Morton
@ 2006-08-08  1:12   ` Jiri Kosina
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2006-08-08  1:12 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Len Brown, linux-acpi, linux-kernel

On Mon, 7 Aug 2006, Andrew Morton wrote:

> acpi_os_acquire_object() is fixed in -rc4.  I queued the
> acpi_pci_link_set() improvement for sending on to Len, thanks.  

Thanks. Unfortunately, looking at the refactorized ACPI code in 
2.6.18-rc4, there are still issues with sleeping functions called with 
disabled interrupts (during resume), in ACPI code.

Two random examples:

- when acpi_pci_link_set() is called during resume (local irqs off), the 
following callchain happens, which is bad: acpi_pci_link_resume -> 
acpi_pci_link_set -> acpi_set_current_resources -> 
acpi_rs_set_srs_method_data -> acpi_ns_evaluate -> acpi_ns_get_node .. 
here the mutex is acquired. Not good. 

- device_power_up -> sysdev_resume -> __sysdev_resume -> cpufreq_resume -> 
blocking_notifier_call_chain -> down on semaphore. Not good.

Is there any general idea for solution?

-- 
JiKos.

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

end of thread, other threads:[~2006-08-08  1:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-07 14:30 [RESEND] [PATCH] ACPI - change GFP_ATOMIC to GFP_KERNEL for non-atomic allocation Jiri Kosina
2006-08-07 20:58 ` Andrew Morton
2006-08-08  1:12   ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.