public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] percpu fixes for 2.6.32-rc6
@ 2009-11-10  6:04 Tejun Heo
  2009-11-10 17:10 ` Linus Torvalds
  0 siblings, 1 reply; 30+ messages in thread
From: Tejun Heo @ 2009-11-10  6:04 UTC (permalink / raw)
  To: Linus Torvalds, Linux Kernel; +Cc: Yinghai Lu, Ingo Molnar

Hello, Linus.

Please pull from the following percpu fix branch.

  git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git for-linus

It fixes a possible deadlock caused by lock ordering inversion through
irq.

Thanks.
---
Tejun Heo (1):
      percpu: fix possible deadlock via irq lock inversion

 mm/percpu.c |   17 +++++++++++++++--

diff --git a/mm/percpu.c b/mm/percpu.c
index d907971..30cd343 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -372,7 +372,7 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
 static int pcpu_extend_area_map(struct pcpu_chunk *chunk, unsigned long *flags)
 {
 	int new_alloc;
-	int *new;
+	int *new, *old = NULL;
 	size_t size;

 	/* has enough? */
@@ -407,10 +407,23 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, unsigned long *flags)
 	 * one of the first chunks and still using static map.
 	 */
 	if (chunk->map_alloc >= PCPU_DFL_MAP_ALLOC)
-		pcpu_mem_free(chunk->map, size);
+		old = chunk->map;

 	chunk->map_alloc = new_alloc;
 	chunk->map = new;
+
+	/*
+	 * pcpu_mem_free() might end up calling vfree() which uses
+	 * IRQ-unsafe lock and thus can't be called with pcpu_lock
+	 * held.  Release and reacquire pcpu_lock if old map needs to
+	 * be freed.
+	 */
+	if (old) {
+		spin_unlock_irqrestore(&pcpu_lock, *flags);
+		pcpu_mem_free(old, size);
+		spin_lock_irqsave(&pcpu_lock, *flags);
+	}
+
 	return 0;
 }

-- 
tejun

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

end of thread, other threads:[~2009-11-12 18:14 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-10  6:04 [GIT PULL] percpu fixes for 2.6.32-rc6 Tejun Heo
2009-11-10 17:10 ` Linus Torvalds
2009-11-10 18:33   ` Tejun Heo
2009-11-10 18:54     ` Linus Torvalds
2009-11-10 19:25       ` Tejun Heo
2009-11-10 19:37         ` Ingo Molnar
2009-11-10 19:50           ` Tejun Heo
2009-11-10 21:42             ` Linus Torvalds
2009-11-11  3:55               ` Tejun Heo
2009-11-11 11:31                 ` Ingo Molnar
2009-11-11 12:21                   ` Tejun Heo
2009-11-11 19:57                     ` Ingo Molnar
2009-11-12 10:11                       ` Tejun Heo
2009-11-12 10:36                         ` Ingo Molnar
2009-11-12 10:58                           ` Tejun Heo
2009-11-12 11:25                             ` Ingo Molnar
2009-11-12 14:26                             ` Oliver Neukum
2009-11-12 15:17                             ` Linus Torvalds
2009-11-12 15:30                               ` Tejun Heo
2009-11-12 15:45                                 ` Tejun Heo
2009-11-12 15:52                                   ` Linus Torvalds
2009-11-12 17:04                               ` Andres Baldrich
2009-11-12 17:18                                 ` Linus Torvalds
2009-11-12 18:04                                   ` Ingo Molnar
2009-11-12 18:14                               ` Andi Kleen
2009-11-12 11:07                         ` Ingo Molnar
2009-11-12 11:29                           ` Tejun Heo
2009-11-11  8:49           ` [PATCH percpu#for-linus] percpu: restructure pcpu_extend_area_map() to fix bugs and improve readability Tejun Heo
2009-11-11 19:25             ` Linus Torvalds
2009-11-10 19:44         ` [GIT PULL] percpu fixes for 2.6.32-rc6 Tejun Heo

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