slqb: fix deadlock
Subsystems (3)
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.
Cc Wu Fengguang <[email protected]>
Signed-off-by Nick Piggin <[email protected]>
---
mm/slqb.c +11 -6
@@ -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));
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.
Signed-off-by Nick Piggin <[email protected]>
---
arch/x86/include/asm/page.h +0 -1
@@ -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
@@ -156,11 +156,7 @@ static inline struct zone *slqb_page_zonstatic 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
@@ -305,11 +305,7 @@ static inline void get_page(struct pagestatic 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); }
Pekka Enberg
AppliedRe: [patch 2/2] slqb: x86 cleanup
Quoted 4 lines · Nick Piggin
My
virt_to_page_fastspeedup for x86-64 snuck in to the slqb patch, where it does not belong. Oops.Signed-off-by Nick Piggin <[email protected]>
Applied, thanks!
Pekka Enberg
AppliedQuoted 6 lines · Nick Piggin
Fix the lockdep error reported by Fengguang where
down_readslqb_lockis taken twice when reading/proc/slabinfo, with the possibility for a deadlock.Cc Wu Fengguang <[email protected]>Signed-off-by Nick Piggin <[email protected]>
Applied, thanks!