linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/2] slqb: fix deadlock
@ 2009-03-02  6:47 Nick Piggin
  2009-03-02  6:52 ` [patch 2/2] slqb: x86 cleanup Nick Piggin
  2009-03-02  8:09 ` [patch 1/2] slqb: fix deadlock Pekka Enberg
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Piggin @ 2009-03-02  6:47 UTC (permalink / raw)
  To: Pekka Enberg, Linux Kernel Mailing List; +Cc: Wu Fengguang


Fix the lockdep error reported by Fengguang where down_read slqb_lock
is taken twice when reading /proc/slabinfo, with the possibility for a
deadlock.

Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Nick Piggin <npiggin@suse.de>
---
Index: linux-2.6/mm/slqb.c
===================================================================
--- linux-2.6.orig/mm/slqb.c	2009-03-02 17:42:09.000000000 +1100
+++ linux-2.6/mm/slqb.c	2009-03-02 17:44:10.000000000 +1100
@@ -3075,7 +3075,9 @@ static void __gather_stats(void *arg)
 	spin_unlock(&gather->lock);
 }
 
-static void gather_stats(struct kmem_cache *s, struct stats_gather *stats)
+/* must be called with slqb_lock held */
+static void gather_stats_locked(struct kmem_cache *s,
+				struct stats_gather *stats)
 {
 #ifdef CONFIG_NUMA
 	int node;
@@ -3085,8 +3087,6 @@ static void gather_stats(struct kmem_cac
 	stats->s = s;
 	spin_lock_init(&stats->lock);
 
-	down_read(&slqb_lock); /* hold off hotplug */
-
 	on_each_cpu(__gather_stats, stats, 1);
 
 #ifdef CONFIG_NUMA
@@ -3115,10 +3115,15 @@ static void gather_stats(struct kmem_cac
 	}
 #endif
 
-	up_read(&slqb_lock);
-
 	stats->nr_objects = stats->nr_slabs * s->objects;
 }
+
+static void gather_stats(struct kmem_cache *s, struct stats_gather *stats)
+{
+	down_read(&slqb_lock); /* hold off hotplug */
+	gather_stats_locked(s, stats);
+	up_read(&slqb_lock);
+}
 #endif
 
 /*
@@ -3171,7 +3176,7 @@ static int s_show(struct seq_file *m, vo
 
 	s = list_entry(p, struct kmem_cache, list);
 
-	gather_stats(s, &stats);
+	gather_stats_locked(s, &stats);
 
 	seq_printf(m, "%-17s %6lu %6lu %6u %4u %4d", s->name, stats.nr_inuse,
 			stats.nr_objects, s->size, s->objects, (1 << s->order));

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

* [patch 2/2] slqb: x86 cleanup
  2009-03-02  6:47 [patch 1/2] slqb: fix deadlock Nick Piggin
@ 2009-03-02  6:52 ` Nick Piggin
  2009-03-02  8:09   ` Pekka Enberg
  2009-03-02  8:09 ` [patch 1/2] slqb: fix deadlock Pekka Enberg
  1 sibling, 1 reply; 4+ messages in thread
From: Nick Piggin @ 2009-03-02  6:52 UTC (permalink / raw)
  To: Pekka Enberg, Linux Kernel Mailing List


My virt_to_page_fast speedup for x86-64 snuck in to the slqb patch, where it
does not belong. Oops.

Signed-off-by: Nick Piggin <npiggin@suse.de>
---
Index: linux-2.6/arch/x86/include/asm/page.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/page.h	2009-03-02 17:41:56.000000000 +1100
+++ linux-2.6/arch/x86/include/asm/page.h	2009-03-02 17:42:02.000000000 +1100
@@ -193,7 +193,6 @@ static inline pteval_t native_pte_flags(
  * virt_addr_valid(kaddr) returns true.
  */
 #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
-#define virt_to_page_fast(kaddr) pfn_to_page(((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT)
 #define pfn_to_kaddr(pfn)      __va((pfn) << PAGE_SHIFT)
 extern bool __virt_addr_valid(unsigned long kaddr);
 #define virt_addr_valid(kaddr)	__virt_addr_valid((unsigned long) (kaddr))
Index: linux-2.6/mm/slqb.c
===================================================================
--- linux-2.6.orig/mm/slqb.c	2009-03-02 17:41:56.000000000 +1100
+++ linux-2.6/mm/slqb.c	2009-03-02 17:42:09.000000000 +1100
@@ -156,11 +156,7 @@ static inline struct zone *slqb_page_zon
 
 static inline int virt_to_nid(const void *addr)
 {
-#ifdef virt_to_page_fast
-	return page_to_nid(virt_to_page_fast(addr));
-#else
 	return page_to_nid(virt_to_page(addr));
-#endif
 }
 
 static inline struct slqb_page *virt_to_head_slqb_page(const void *addr)
Index: linux-2.6/include/linux/mm.h
===================================================================
--- linux-2.6.orig/include/linux/mm.h	2009-03-02 17:42:59.000000000 +1100
+++ linux-2.6/include/linux/mm.h	2009-03-02 17:43:09.000000000 +1100
@@ -305,11 +305,7 @@ static inline void get_page(struct page 
 
 static inline struct page *virt_to_head_page(const void *x)
 {
-#ifdef virt_to_page_fast
-	struct page *page = virt_to_page_fast(x);
-#else
 	struct page *page = virt_to_page(x);
-#endif
 	return compound_head(page);
 }
 

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

* Re: [patch 1/2] slqb: fix deadlock
  2009-03-02  6:47 [patch 1/2] slqb: fix deadlock Nick Piggin
  2009-03-02  6:52 ` [patch 2/2] slqb: x86 cleanup Nick Piggin
@ 2009-03-02  8:09 ` Pekka Enberg
  1 sibling, 0 replies; 4+ messages in thread
From: Pekka Enberg @ 2009-03-02  8:09 UTC (permalink / raw)
  To: Nick Piggin; +Cc: Linux Kernel Mailing List, Wu Fengguang

On Mon, 2009-03-02 at 07:47 +0100, Nick Piggin wrote:
> Fix the lockdep error reported by Fengguang where down_read slqb_lock
> is taken twice when reading /proc/slabinfo, with the possibility for a
> deadlock.
> 
> Cc: Wu Fengguang <fengguang.wu@intel.com>
> Signed-off-by: Nick Piggin <npiggin@suse.de>

Applied, thanks!


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

* Re: [patch 2/2] slqb: x86 cleanup
  2009-03-02  6:52 ` [patch 2/2] slqb: x86 cleanup Nick Piggin
@ 2009-03-02  8:09   ` Pekka Enberg
  0 siblings, 0 replies; 4+ messages in thread
From: Pekka Enberg @ 2009-03-02  8:09 UTC (permalink / raw)
  To: Nick Piggin; +Cc: Linux Kernel Mailing List

On Mon, 2009-03-02 at 07:52 +0100, Nick Piggin wrote:
> My virt_to_page_fast speedup for x86-64 snuck in to the slqb patch, where it
> does not belong. Oops.
> 
> Signed-off-by: Nick Piggin <npiggin@suse.de>

Applied, thanks!


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

end of thread, other threads:[~2009-03-02  8:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-02  6:47 [patch 1/2] slqb: fix deadlock Nick Piggin
2009-03-02  6:52 ` [patch 2/2] slqb: x86 cleanup Nick Piggin
2009-03-02  8:09   ` Pekka Enberg
2009-03-02  8:09 ` [patch 1/2] slqb: fix deadlock Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).