summaryrefslogtreecommitdiff
path: root/linux/six.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/six.c')
-rw-r--r--linux/six.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/linux/six.c b/linux/six.c
index fca12087..5b2d92c6 100644
--- a/linux/six.c
+++ b/linux/six.c
@@ -757,3 +757,23 @@ void six_lock_pcpu_alloc(struct six_lock *lock)
#endif
}
EXPORT_SYMBOL_GPL(six_lock_pcpu_alloc);
+
+/*
+ * Returns lock held counts, for both read and intent
+ */
+struct six_lock_count six_lock_counts(struct six_lock *lock)
+{
+ struct six_lock_count ret = { 0, lock->state.intent_lock };
+
+ if (!lock->readers)
+ ret.read += lock->state.read_lock;
+ else {
+ int cpu;
+
+ for_each_possible_cpu(cpu)
+ ret.read += *per_cpu_ptr(lock->readers, cpu);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(six_lock_counts);