Re: [lttng-dev] [PATCH lttng-modules] Fix: kref changes for kernel 4.11

2017-03-08 Thread Mathieu Desnoyers


- On Mar 7, 2017, at 11:37 PM, Francis Deslauriers 
francis.deslauri...@efficios.com wrote:

> 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 
> ---
> wrapper/kref.h | 8 
> 1 file changed, 8 insertions(+)
> 
> diff --git a/wrapper/kref.h b/wrapper/kref.h
> index f30a9ae..8db05b5 100644
> --- a/wrapper/kref.h
> +++ b/wrapper/kref.h
> @@ -34,9 +34,17 @@
>  *
>  * Return 1 if reference is taken, 0 otherwise (overflow).
>  */
> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))

Don't forget to include 

#include 

I'll add it locally as I merge it into master and 2.9.

Thanks,

Mathieu

> +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(>refcount, 1, INT_MAX);
> }
> +#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
> 
> #endif /* _LTTNG_WRAPPER_KREF_H */
> --
> 2.7.4

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-modules] Fix: kref changes for kernel 4.11

2017-03-07 Thread Francis Deslauriers
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 
---
 wrapper/kref.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/wrapper/kref.h b/wrapper/kref.h
index f30a9ae..8db05b5 100644
--- a/wrapper/kref.h
+++ b/wrapper/kref.h
@@ -34,9 +34,17 @@
  *
  * 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(>refcount, 1, INT_MAX);
 }
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
 
 #endif /* _LTTNG_WRAPPER_KREF_H */
-- 
2.7.4

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev