* [PATCH 1/3] compat: backport rcu_dereference_raw
@ 2011-05-22 10:47 Hauke Mehrtens
2011-05-22 10:47 ` [PATCH 2/3] compat: backport RCU_INIT_POINTER Hauke Mehrtens
2011-05-22 10:47 ` [PATCH 3/3] compat: remove wrong backport of kfree_rcu Hauke Mehrtens
0 siblings, 2 replies; 3+ messages in thread
From: Hauke Mehrtens @ 2011-05-22 10:47 UTC (permalink / raw)
To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
include/linux/compat-2.6.34.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h
index ad06a07..663a67e 100644
--- a/include/linux/compat-2.6.34.h
+++ b/include/linux/compat-2.6.34.h
@@ -249,6 +249,8 @@ static inline int usb_disable_autosuspend(struct usb_device *udev)
#define rcu_dereference_protected(p, c) (p)
#define rcu_access_pointer(p) ACCESS_ONCE(p)
+#define rcu_dereference_raw(p) rcu_dereference(p)
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */
#endif /* LINUX_26_34_COMPAT_H */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] compat: backport RCU_INIT_POINTER
2011-05-22 10:47 [PATCH 1/3] compat: backport rcu_dereference_raw Hauke Mehrtens
@ 2011-05-22 10:47 ` Hauke Mehrtens
2011-05-22 10:47 ` [PATCH 3/3] compat: remove wrong backport of kfree_rcu Hauke Mehrtens
1 sibling, 0 replies; 3+ messages in thread
From: Hauke Mehrtens @ 2011-05-22 10:47 UTC (permalink / raw)
To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
include/linux/compat-2.6.37.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h
index a83c9c7..e0dd6b4 100644
--- a/include/linux/compat-2.6.37.h
+++ b/include/linux/compat-2.6.37.h
@@ -115,6 +115,15 @@ extern void *vzalloc(unsigned long size);
#define rtnl_dereference(p) \
rcu_dereference_protected(p, lockdep_rtnl_is_held())
+/**
+ * RCU_INIT_POINTER() - initialize an RCU protected pointer
+ *
+ * Initialize an RCU-protected pointer in such a way to avoid RCU-lockdep
+ * splats.
+ */
+#define RCU_INIT_POINTER(p, v) \
+ p = (typeof(*v) __force __rcu *)(v)
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */
#endif /* LINUX_26_37_COMPAT_H */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] compat: remove wrong backport of kfree_rcu
2011-05-22 10:47 [PATCH 1/3] compat: backport rcu_dereference_raw Hauke Mehrtens
2011-05-22 10:47 ` [PATCH 2/3] compat: backport RCU_INIT_POINTER Hauke Mehrtens
@ 2011-05-22 10:47 ` Hauke Mehrtens
1 sibling, 0 replies; 3+ messages in thread
From: Hauke Mehrtens @ 2011-05-22 10:47 UTC (permalink / raw)
To: mcgrof, lrodriguez; +Cc: linux-wireless, Hauke Mehrtens
Backporting kfree_rcu() in compat does not work as
struct rcu_head->func is always interpreted as a pointer in older
kernel versions, but when using kfree_rcu() it is set to an offset.
rcu_head->func is used in some functions in the kernel not backported
by compat-wireless.
In older kernel versions in __rcu_reclaim just the else path is available.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
include/linux/compat-2.6.40.h | 58 -----------------------------------------
1 files changed, 0 insertions(+), 58 deletions(-)
diff --git a/include/linux/compat-2.6.40.h b/include/linux/compat-2.6.40.h
index 9ec8c1b..b3fc8f7 100644
--- a/include/linux/compat-2.6.40.h
+++ b/include/linux/compat-2.6.40.h
@@ -24,64 +24,6 @@
#define br_port_exists(dev) (dev->br_port)
#endif
-static __always_inline bool __is_kfree_rcu_offset(unsigned long offset)
-{
- return offset < 4096;
-}
-
-static __always_inline
-void __kfree_rcu(struct rcu_head *head, unsigned long offset)
-{
- typedef void (*rcu_callback)(struct rcu_head *);
-
- /* This causes build failures with some kernel versions at positions
- * where this methods is not used at all.
- */
- /* BUILD_BUG_ON(!__builtin_constant_p(offset)); */
-
- /* See the kfree_rcu() header comment. */
- /* BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); */
-
- call_rcu(head, (rcu_callback)offset);
-}
-
-static inline void __rcu_reclaim(struct rcu_head *head)
-{
- unsigned long offset = (unsigned long)head->func;
-
- if (__is_kfree_rcu_offset(offset))
- kfree((void *)head - offset);
- else
- head->func(head);
-}
-
-/**
- * kfree_rcu() - kfree an object after a grace period.
- * @ptr: pointer to kfree
- * @rcu_head: the name of the struct rcu_head within the type of @ptr.
- *
- * Many rcu callbacks functions just call kfree() on the base structure.
- * These functions are trivial, but their size adds up, and furthermore
- * when they are used in a kernel module, that module must invoke the
- * high-latency rcu_barrier() function at module-unload time.
- *
- * The kfree_rcu() function handles this issue. Rather than encoding a
- * function address in the embedded rcu_head structure, kfree_rcu() instead
- * encodes the offset of the rcu_head structure within the base structure.
- * Because the functions are not allowed in the low-order 4096 bytes of
- * kernel virtual memory, offsets up to 4095 bytes can be accommodated.
- * If the offset is larger than 4095 bytes, a compile-time error will
- * be generated in __kfree_rcu(). If this error is triggered, you can
- * either fall back to use of call_rcu() or rearrange the structure to
- * position the rcu_head structure into the first 4096 bytes.
- *
- * Note that the allowable offset might decrease in the future, for example,
- * to allow something like kmem_cache_free_rcu().
- */
-#define kfree_rcu(ptr, rcu_head) \
- __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
-
-
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) */
#endif /* LINUX_26_40_COMPAT_H */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-22 10:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-22 10:47 [PATCH 1/3] compat: backport rcu_dereference_raw Hauke Mehrtens
2011-05-22 10:47 ` [PATCH 2/3] compat: backport RCU_INIT_POINTER Hauke Mehrtens
2011-05-22 10:47 ` [PATCH 3/3] compat: remove wrong backport of kfree_rcu Hauke Mehrtens
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.