From: Francis Deslauriers Date: Wed, 8 Mar 2017 04:37:30 +0000 (-0500) Subject: Fix: kref changes for kernel 4.11 X-Git-Tag: v2.8.5~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=64621d16b7ed3ff47549cfa851181411c9529702;p=lttng-modules.git Fix: kref changes for kernel 4.11 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 Signed-off-by: Mathieu Desnoyers --- diff --git a/wrapper/kref.h b/wrapper/kref.h index f30a9aed..3f3be7a4 100644 --- a/wrapper/kref.h +++ b/wrapper/kref.h @@ -28,15 +28,24 @@ #include #include +#include /* * 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 */