Skip to content

Commit ce4dce1

Browse files
urezkipaulmckrcu
authored andcommitted
rcu: Introduce 2 arg kvfree_rcu() interface
kvmalloc() can allocate two types of objects: SLAB backed and vmalloc backed. How it behaves depends on requested object's size and memory pressure. Add a kvfree_rcu() interface that can free memory allocated via kvmalloc(). It is a simple alias to kfree_rcu() which can now handle either type of object. <snip> struct test_kvfree_rcu { struct rcu_head rcu; unsigned char array[100]; }; struct test_kvfree_rcu *p; p = kvmalloc(10 * PAGE_SIZE); if (p) kvfree_rcu(p, rcu); <snip> Signed-off-by: Uladzislau Rezki (Sony) <[email protected]> Co-developed-by: Joel Fernandes (Google) <[email protected]> Reviewed-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent e0feed0 commit ce4dce1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/linux/rcupdate.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,15 @@ do { \
875875
__kvfree_rcu(&((___p)->rhf), offsetof(typeof(*(ptr)), rhf)); \
876876
} while (0)
877877

878+
/**
879+
* kvfree_rcu() - kvfree an object after a grace period.
880+
* @ptr: pointer to kvfree
881+
* @rhf: the name of the struct rcu_head within the type of @ptr.
882+
*
883+
* Same as kfree_rcu(), just simple alias.
884+
*/
885+
#define kvfree_rcu(ptr, rhf) kfree_rcu(ptr, rhf)
886+
878887
/*
879888
* Place this after a lock-acquisition primitive to guarantee that
880889
* an UNLOCK+LOCK pair acts as a full barrier. This guarantee applies

0 commit comments

Comments
 (0)