#endif
/*
- * Generic helper to lookup and a per-cpu variable with an embedded spinlock.
- * Return value should be used with equivalent unlock helper.
+ * A helper to lookup and trylock pcp with embedded spinlock.
+ * The return value should be used with the unlock helper.
+ * NULL return value means the trylock failed.
*/
-#define pcpu_spin_trylock(type, member, ptr) \
+#ifdef CONFIG_SMP
+#define pcp_spin_trylock(ptr) \
({ \
- type *_ret; \
+ struct per_cpu_pages *_ret; \
pcpu_task_pin(); \
_ret = this_cpu_ptr(ptr); \
- if (!spin_trylock(&_ret->member)) { \
+ if (!spin_trylock(&_ret->lock)) { \
pcpu_task_unpin(); \
_ret = NULL; \
} \
_ret; \
})
-#define pcpu_spin_unlock(member, ptr) \
+#define pcp_spin_unlock(ptr) \
({ \
- spin_unlock(&ptr->member); \
+ spin_unlock(&ptr->lock); \
pcpu_task_unpin(); \
})
-/* struct per_cpu_pages specific helpers.*/
-#ifdef CONFIG_SMP
-#define pcp_spin_trylock(ptr) \
- pcpu_spin_trylock(struct per_cpu_pages, lock, ptr)
-
-#define pcp_spin_unlock(ptr) \
- pcpu_spin_unlock(lock, ptr)
-
/*
* On CONFIG_SMP=n the UP implementation of spin_trylock() never fails and thus
* is not compatible with our locking scheme. However we do not need pcp for