Skip to content

Commit 5af42f9

Browse files
Sebastian Andrzej SiewiorPeter Zijlstra
authored andcommitted
perf: Shrink the size of the recursion counter.
There are four recursion counter, one for each context. The type of the counter is `int' but the counter is used as `bool' since it is only incremented if zero. The main goal here is to shrink the whole struct into 32bit int which can later be added task_struct into an existing hole. Reduce the type of the recursion counter to an unsigned char, keep the increment/ decrement operation. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Marco Elver <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c5d93d2 commit 5af42f9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

kernel/events/callchain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static inline size_t perf_callchain_entry__sizeof(void)
2929
sysctl_perf_event_max_contexts_per_stack));
3030
}
3131

32-
static DEFINE_PER_CPU(int, callchain_recursion[PERF_NR_CONTEXTS]);
32+
static DEFINE_PER_CPU(u8, callchain_recursion[PERF_NR_CONTEXTS]);
3333
static atomic_t nr_callchain_events;
3434
static DEFINE_MUTEX(callchain_mutex);
3535
static struct callchain_cpus_entries *callchain_cpus_entries;

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9765,7 +9765,7 @@ struct swevent_htable {
97659765
int hlist_refcount;
97669766

97679767
/* Recursion avoidance in each contexts */
9768-
int recursion[PERF_NR_CONTEXTS];
9768+
u8 recursion[PERF_NR_CONTEXTS];
97699769
};
97709770

97719771
static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);

kernel/events/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
208208

209209
DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
210210

211-
static inline int get_recursion_context(int *recursion)
211+
static inline int get_recursion_context(u8 *recursion)
212212
{
213213
unsigned char rctx = interrupt_context_level();
214214

@@ -221,7 +221,7 @@ static inline int get_recursion_context(int *recursion)
221221
return rctx;
222222
}
223223

224-
static inline void put_recursion_context(int *recursion, int rctx)
224+
static inline void put_recursion_context(u8 *recursion, int rctx)
225225
{
226226
barrier();
227227
recursion[rctx]--;

0 commit comments

Comments
 (0)