From 2b4abe603a50a29230022f7852f3fd57e246c974 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 11 Dec 2015 05:52:45 +0000 Subject: [PATCH] scst/include/backport.h: Add kfree_rcu() definition for kernels < 3.0 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6730 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 480b13e3c..8f7c53478 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -365,6 +365,21 @@ static inline __attribute__ ((format (printf, 1, 2))) int no_printk(const char *s, ...) { return 0; } #endif +/* */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +typedef void (*rcu_callback_t)(struct rcu_head *); +#define __is_kfree_rcu_offset(offset) ((offset) < 4096) +#define kfree_call_rcu(head, rcb) call_rcu(head, rcb) +#define __kfree_rcu(head, offset) \ + do { \ + BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \ + kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \ + } while (0) +#define kfree_rcu(ptr, rcu_head) \ + __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && \