Skip to contentSkip to conversation

zsmalloc: use bit_spin_lock

PATCH New [email protected] 1 participant 1 message Jul 26, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 46/126 zsmalloc: use bit_spin_lock

From: Minchan Kim <[email protected]>
Subject: zsmalloc: use bit_spin_lock

Use kernel standard bit spin-lock instead of custom mess. Even, it has a bug which doesn't disable preemption. The reason we don't have any problem is that we have used it during preemption disable section by class->lock spinlock. So no need to go to stable.

---

 mm/zsmalloc.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
mm/zsmalloc.c renamed from mm/zsmalloc.c~zsmalloc-use-bit_spin_lock +2 -5
diff -puN mm/zsmalloc.c~zsmalloc-use-bit_spin_lock mm/zsmalloc.c
@@ -868,21 +868,17 @@ static unsigned long obj_idx_to_offset(s
 
 static inline int trypin_tag(unsigned long handle)
 {
-	unsigned long *ptr = (unsigned long *)handle;
-
-	return !test_and_set_bit_lock(HANDLE_PIN_BIT, ptr);
+	return bit_spin_trylock(HANDLE_PIN_BIT, (unsigned long *)handle);
 }
 
 static void pin_tag(unsigned long handle)
 {
-	while (!trypin_tag(handle));
+	bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle);
 }
 
 static void unpin_tag(unsigned long handle)
 {
-	unsigned long *ptr = (unsigned long *)handle;