rcu: Replace kfree() with kvfree() as callback for kfree_rcu()
PATCH 1/1 rcu: Replace kfree() with kvfree() as callback for kfree_rcu()
Like Paul suggested, we start from simple replacing kfree() with kvfree() in kfree_rcu() callbacks:
https://www.spinics.net/lists/kernel/msg2729683.html
kvfree() works both with kmalloc()'ed and vmalloc()'ed memory, so we use it to free both of them via kfree_rcu().
Signed-off-by Kirill Tkhai <[email protected]>
--- include/linux/rcupdate.h | 2 ++ kernel/rcu/tiny.c | 2 +- kernel/rcu/tree.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
include/linux/rcupdate.h +2 -0
@@ -842,6 +842,8 @@ do { \__kfree_rcu (&((___p)->rhf), offsetof(typeof (*(ptr )), rhf)); \ } while (0) +#define kvfree_rcu (ptr, rhf) kfree_rcu(ptr, rhf) +/* * Place this after a lock-acquisition primitive to guarantee that * an UNLOCK+LOCK pair acts as a full barrier. This guarantee applies
kernel/rcu/tiny.c +1 -1
@@ -86,7 +86,7 @@ static inline bool rcu_reclaim_tiny(struct rcu_head *head)rcu_lock_acquire (&rcu_callback_map);if (__is_kfree_rcu_offset (offset)) {trace_rcu_invoke_kfree_callback ("" , head, offset); -kfree ((void *)head - offset); +kvfree ((void *)head - offset);rcu_lock_release (&rcu_callback_map);return true; }
kernel/rcu/tree.c +1 -1
@@ -2879,7 +2879,7 @@ static void kfree_rcu_work(struct work_struct *work)trace_rcu_invoke_kfree_callback (rcu_state.name, head, offset);if (!WARN_ON_ONCE (!__is_kfree_rcu_offset (offset))) -kfree ((void *)head - offset); +kvfree ((void *)head - offset);rcu_lock_release (&rcu_callback_map);cond_resched_tasks_rcu_qs ();