Skip to contentSkip to conversation

slqb: fix deadlock

PATCH Applied Nick Piggin 2 participants 4 messages Mar 2, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 slqb: fix deadlock

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.

---

mm/slqb.c +11 -6
Index: linux-2.6/mm/slqb.c
===================================================================
@@ -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));
#1 lore raw

PATCH 2/2 slqb: x86 cleanup

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

---

arch/x86/include/asm/page.h +0 -1
Index: linux-2.6/arch/x86/include/asm/page.h
===================================================================
@@ -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))
mm/slqb.c +0 -4
Index: linux-2.6/mm/slqb.c
===================================================================
@@ -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)
include/linux/mm.h +0 -4
Index: linux-2.6/include/linux/mm.h
===================================================================
@@ -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);
 }
 
Applied
#2 lore raw

Re: [patch 2/2] slqb: x86 cleanup

Quoted 4 lines · Nick Piggin

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

Applied, thanks!