Fix: kref changes for kernel 4.11
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 8 Mar 2017 04:37:30 +0000 (23:37 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 8 Mar 2017 16:57:49 +0000 (11:57 -0500)
The underlying type of `struct kref` changed in kernel 4.11 from an
atomic_t to a refcount_t. This change was introduced in kernel
commit:10383ae. This commit also added a builtin overflow checks to
`kref_get()` so we use it.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
wrapper/kref.h

index f30a9aed515db306a1803ff5e4bcc2612a75801b..3f3be7a42d27c0445d7273fc771b5d55dd120248 100644 (file)
 
 #include <linux/kref.h>
 #include <linux/rculist.h>
+#include <linux/version.h>
 
 /*
  * lttng_kref_get: get reference count, checking for overflow.
  *
  * Return 1 if reference is taken, 0 otherwise (overflow).
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
+static inline int lttng_kref_get(struct kref *kref)
+{
+       kref_get(kref);
+       return 1;
+}
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 static inline int lttng_kref_get(struct kref *kref)
 {
        return atomic_add_unless(&kref->refcount, 1, INT_MAX);
 }
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 
 #endif /* _LTTNG_WRAPPER_KREF_H */
This page took 0.024847 seconds and 4 git commands to generate.