Skip to content

Commit c408b21

Browse files
urezkipaulmckrcu
authored andcommitted
rcu: Rename *_kfree_callback/*_kfree_rcu_offset/kfree_call_*
The following changes are introduced: 1. Rename rcu_invoke_kfree_callback() to rcu_invoke_kvfree_callback(), as well as the associated trace events, so the rcu_kfree_callback(), becomes rcu_kvfree_callback(). The reason is to be aligned with kvfree() notation. 2. Rename __is_kfree_rcu_offset to __is_kvfree_rcu_offset. All RCU paths use kvfree() now instead of kfree(), thus rename it. 3. Rename kfree_call_rcu() to the kvfree_call_rcu(). The reason is, it is capable of freeing vmalloc() memory now. Do the same with __kfree_rcu() macro, it becomes __kvfree_rcu(), the goal is the same. Reviewed-by: Joel Fernandes (Google) <[email protected]> Co-developed-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Uladzislau Rezki (Sony) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 64d1d06 commit c408b21

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

include/linux/rcupdate.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -828,17 +828,17 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
828828

829829
/*
830830
* Does the specified offset indicate that the corresponding rcu_head
831-
* structure can be handled by kfree_rcu()?
831+
* structure can be handled by kvfree_rcu()?
832832
*/
833-
#define __is_kfree_rcu_offset(offset) ((offset) < 4096)
833+
#define __is_kvfree_rcu_offset(offset) ((offset) < 4096)
834834

835835
/*
836836
* Helper macro for kfree_rcu() to prevent argument-expansion eyestrain.
837837
*/
838-
#define __kfree_rcu(head, offset) \
838+
#define __kvfree_rcu(head, offset) \
839839
do { \
840-
BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \
841-
kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \
840+
BUILD_BUG_ON(!__is_kvfree_rcu_offset(offset)); \
841+
kvfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \
842842
} while (0)
843843

844844
/**
@@ -857,7 +857,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
857857
* Because the functions are not allowed in the low-order 4096 bytes of
858858
* kernel virtual memory, offsets up to 4095 bytes can be accommodated.
859859
* If the offset is larger than 4095 bytes, a compile-time error will
860-
* be generated in __kfree_rcu(). If this error is triggered, you can
860+
* be generated in __kvfree_rcu(). If this error is triggered, you can
861861
* either fall back to use of call_rcu() or rearrange the structure to
862862
* position the rcu_head structure into the first 4096 bytes.
863863
*
@@ -872,7 +872,7 @@ do { \
872872
typeof (ptr) ___p = (ptr); \
873873
\
874874
if (___p) \
875-
__kfree_rcu(&((___p)->rhf), offsetof(typeof(*(ptr)), rhf)); \
875+
__kvfree_rcu(&((___p)->rhf), offsetof(typeof(*(ptr)), rhf)); \
876876
} while (0)
877877

878878
/*

include/linux/rcutiny.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static inline void synchronize_rcu_expedited(void)
3434
synchronize_rcu();
3535
}
3636

37-
static inline void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
37+
static inline void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
3838
{
3939
call_rcu(head, func);
4040
}

include/linux/rcutree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static inline void rcu_virt_note_context_switch(int cpu)
3333
}
3434

3535
void synchronize_rcu_expedited(void);
36-
void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func);
36+
void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func);
3737

3838
void rcu_barrier(void);
3939
bool rcu_eqs_special_set(int cpu);

include/trace/events/rcu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,13 @@ TRACE_EVENT_RCU(rcu_callback,
506506

507507
/*
508508
* Tracepoint for the registration of a single RCU callback of the special
509-
* kfree() form. The first argument is the RCU type, the second argument
509+
* kvfree() form. The first argument is the RCU type, the second argument
510510
* is a pointer to the RCU callback, the third argument is the offset
511511
* of the callback within the enclosing RCU-protected data structure,
512512
* the fourth argument is the number of lazy callbacks queued, and the
513513
* fifth argument is the total number of callbacks queued.
514514
*/
515-
TRACE_EVENT_RCU(rcu_kfree_callback,
515+
TRACE_EVENT_RCU(rcu_kvfree_callback,
516516

517517
TP_PROTO(const char *rcuname, struct rcu_head *rhp, unsigned long offset,
518518
long qlen),
@@ -596,12 +596,12 @@ TRACE_EVENT_RCU(rcu_invoke_callback,
596596

597597
/*
598598
* Tracepoint for the invocation of a single RCU callback of the special
599-
* kfree() form. The first argument is the RCU flavor, the second
599+
* kvfree() form. The first argument is the RCU flavor, the second
600600
* argument is a pointer to the RCU callback, and the third argument
601601
* is the offset of the callback within the enclosing RCU-protected
602602
* data structure.
603603
*/
604-
TRACE_EVENT_RCU(rcu_invoke_kfree_callback,
604+
TRACE_EVENT_RCU(rcu_invoke_kvfree_callback,
605605

606606
TP_PROTO(const char *rcuname, struct rcu_head *rhp, unsigned long offset),
607607

kernel/rcu/tiny.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ static inline bool rcu_reclaim_tiny(struct rcu_head *head)
8585
unsigned long offset = (unsigned long)head->func;
8686

8787
rcu_lock_acquire(&rcu_callback_map);
88-
if (__is_kfree_rcu_offset(offset)) {
89-
trace_rcu_invoke_kfree_callback("", head, offset);
88+
if (__is_kvfree_rcu_offset(offset)) {
89+
trace_rcu_invoke_kvfree_callback("", head, offset);
9090
kvfree((void *)head - offset);
9191
rcu_lock_release(&rcu_callback_map);
9292
return true;

kernel/rcu/tree.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,8 +2905,8 @@ __call_rcu(struct rcu_head *head, rcu_callback_t func)
29052905
return; // Enqueued onto ->nocb_bypass, so just leave.
29062906
// If no-CBs CPU gets here, rcu_nocb_try_bypass() acquired ->nocb_lock.
29072907
rcu_segcblist_enqueue(&rdp->cblist, head);
2908-
if (__is_kfree_rcu_offset((unsigned long)func))
2909-
trace_rcu_kfree_callback(rcu_state.name, head,
2908+
if (__is_kvfree_rcu_offset((unsigned long)func))
2909+
trace_rcu_kvfree_callback(rcu_state.name, head,
29102910
(unsigned long)func,
29112911
rcu_segcblist_n_cbs(&rdp->cblist));
29122912
else
@@ -3146,7 +3146,7 @@ static void kfree_rcu_work(struct work_struct *work)
31463146
bkvhead[i]->records);
31473147
} else { // vmalloc() / vfree().
31483148
for (j = 0; j < bkvhead[i]->nr_records; j++) {
3149-
trace_rcu_invoke_kfree_callback(
3149+
trace_rcu_invoke_kvfree_callback(
31503150
rcu_state.name,
31513151
bkvhead[i]->records[j], 0);
31523152

@@ -3179,9 +3179,9 @@ static void kfree_rcu_work(struct work_struct *work)
31793179
next = head->next;
31803180
debug_rcu_head_unqueue((struct rcu_head *)ptr);
31813181
rcu_lock_acquire(&rcu_callback_map);
3182-
trace_rcu_invoke_kfree_callback(rcu_state.name, head, offset);
3182+
trace_rcu_invoke_kvfree_callback(rcu_state.name, head, offset);
31833183

3184-
if (!WARN_ON_ONCE(!__is_kfree_rcu_offset(offset)))
3184+
if (!WARN_ON_ONCE(!__is_kvfree_rcu_offset(offset)))
31853185
kvfree(ptr);
31863186

31873187
rcu_lock_release(&rcu_callback_map);
@@ -3344,12 +3344,12 @@ kvfree_call_rcu_add_ptr_to_bulk(struct kfree_rcu_cpu *krcp, void *ptr)
33443344
* one, that is used only when the main path can not be maintained temporary,
33453345
* due to memory pressure.
33463346
*
3347-
* Each kfree_call_rcu() request is added to a batch. The batch will be drained
3347+
* Each kvfree_call_rcu() request is added to a batch. The batch will be drained
33483348
* every KFREE_DRAIN_JIFFIES number of jiffies. All the objects in the batch will
33493349
* be free'd in workqueue context. This allows us to: batch requests together to
33503350
* reduce the number of grace periods during heavy kfree_rcu()/kvfree_rcu() load.
33513351
*/
3352-
void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
3352+
void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
33533353
{
33543354
unsigned long flags;
33553355
struct kfree_rcu_cpu *krcp;
@@ -3388,7 +3388,7 @@ void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
33883388
unlock_return:
33893389
krc_this_cpu_unlock(krcp, flags);
33903390
}
3391-
EXPORT_SYMBOL_GPL(kfree_call_rcu);
3391+
EXPORT_SYMBOL_GPL(kvfree_call_rcu);
33923392

33933393
static unsigned long
33943394
kfree_rcu_shrink_count(struct shrinker *shrink, struct shrink_control *sc)

0 commit comments

Comments
 (0)