On (25/02/03 12:13), Sergey Senozhatsky wrote: > > Just my 2c. > > Perhaps we can sprinkle some lockdep on it. I forgot to rwsem_release() in zspage_write_unlock() and that has triggered lockdep :) --- mm/zsmalloc.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 956445f4d554..1d4700e457d4 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -308,6 +308,10 @@ struct zspage { struct list_head list; /* fullness list */ struct zs_pool *pool; atomic_t lock; + +#ifdef CONFIG_DEBUG_LOCK_ALLOC + struct lockdep_map lockdep_map; +#endif }; struct mapping_area { @@ -319,6 +323,12 @@ struct mapping_area { static void zspage_lock_init(struct zspage *zspage) { +#ifdef CONFIG_DEBUG_LOCK_ALLOC + static struct lock_class_key key; + + lockdep_init_map(&zspage->lockdep_map, "zsmalloc-page", &key, 0); +#endif + atomic_set(&zspage->lock, ZS_PAGE_UNLOCKED); } @@ -344,11 +354,19 @@ static void zspage_read_lock(struct zspage *zspage) continue; } } while (!atomic_try_cmpxchg(lock, &old, old + 1)); + +#ifdef CONFIG_DEBUG_LOCK_ALLOC + rwsem_acquire_read(&zspage->lockdep_map, 0, 0, _RET_IP_); +#endif } static void zspage_read_unlock(struct zspage *zspage) { atomic_dec(&zspage->lock); + +#ifdef CONFIG_DEBUG_LOCK_ALLOC + rwsem_release(&zspage->lockdep_map, _RET_IP_); +#endif } static bool zspage_try_write_lock(struct zspage *zspage) @@ -357,8 +375,12 @@ static bool zspage_try_write_lock(struct zspage *zspage) int old = ZS_PAGE_UNLOCKED; preempt_disable(); - if (atomic_try_cmpxchg(lock, &old, ZS_PAGE_WRLOCKED)) + if (atomic_try_cmpxchg(lock, &old, ZS_PAGE_WRLOCKED)) { +#ifdef CONFIG_DEBUG_LOCK_ALLOC + rwsem_acquire(&zspage->lockdep_map, 0, 0, _RET_IP_); +#endif return true; + } preempt_enable(); return false; @@ -367,6 +389,9 @@ static bool zspage_try_write_lock(struct zspage *zspage) static void zspage_write_unlock(struct zspage *zspage) { atomic_set(&zspage->lock, ZS_PAGE_UNLOCKED); +#ifdef CONFIG_DEBUG_LOCK_ALLOC + rwsem_release(&zspage->lockdep_map, _RET_IP_); +#endif preempt_enable(); } -- 2.48.1.362.g079036d154-goog