[PATCH 15/17] zsmalloc: Add zs_pin_lock

From: Matthew Wilcox (Oracle)
Date: Thu Apr 08 2021 - 23:01:53 EST


Allow lockdep to track zsmalloc's pin bit spin lock.

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
mm/zsmalloc.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 9a7c91c14b84..9d89a1857901 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -874,6 +874,8 @@ static unsigned long obj_to_head(struct page *page, void *obj)
return *(unsigned long *)obj;
}

+static DEFINE_SPLIT_LOCK(zs_pin_lock);
+
static inline int testpin_tag(unsigned long handle)
{
return bit_spin_is_locked(HANDLE_PIN_BIT, (unsigned long *)handle);
@@ -881,17 +883,20 @@ static inline int testpin_tag(unsigned long handle)

static inline int trypin_tag(unsigned long handle)
{
- return bit_spin_trylock(HANDLE_PIN_BIT, (unsigned long *)handle);
+ return bit_spin_trylock(HANDLE_PIN_BIT, (unsigned long *)handle,
+ &zs_pin_lock);
}

static void pin_tag(unsigned long handle) __acquires(bitlock)
{
- bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle);
+ bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle,
+ &zs_pin_lock);
}

static void unpin_tag(unsigned long handle) __releases(bitlock)
{
- bit_spin_unlock(HANDLE_PIN_BIT, (unsigned long *)handle);
+ bit_spin_unlock(HANDLE_PIN_BIT, (unsigned long *)handle,
+ &zs_pin_lock);
}

static void reset_page(struct page *page)
--
2.30.2