]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf: Shrink the size of the recursion counter.
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 4 Jul 2024 17:03:38 +0000 (19:03 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 9 Jul 2024 11:26:35 +0000 (13:26 +0200)
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 <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Marco Elver <elver@google.com>
Link: https://lore.kernel.org/r/20240704170424.1466941-5-bigeasy@linutronix.de
kernel/events/callchain.c
kernel/events/core.c
kernel/events/internal.h

index 1273be84392cfcd00a9c2752a4c2c45a9f21da78..ad57944b6c40ea138006595385505ad8409d0a7c 100644 (file)
@@ -29,7 +29,7 @@ static inline size_t perf_callchain_entry__sizeof(void)
                                 sysctl_perf_event_max_contexts_per_stack));
 }
 
-static DEFINE_PER_CPU(int, callchain_recursion[PERF_NR_CONTEXTS]);
+static DEFINE_PER_CPU(u8, callchain_recursion[PERF_NR_CONTEXTS]);
 static atomic_t nr_callchain_events;
 static DEFINE_MUTEX(callchain_mutex);
 static struct callchain_cpus_entries *callchain_cpus_entries;
index 73e1b02b1c18a386bd4d5539a9e2c62b8570188b..53e2750bf720f73aff471428df4db49609f2e0ea 100644 (file)
@@ -9765,7 +9765,7 @@ struct swevent_htable {
        int                             hlist_refcount;
 
        /* Recursion avoidance in each contexts */
-       int                             recursion[PERF_NR_CONTEXTS];
+       u8                              recursion[PERF_NR_CONTEXTS];
 };
 
 static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);
index 386d21c7edfa038d51880be8789cb4c4206595e3..7f06b79b3b9fb101d8b750f38eaa01c91ec7d97a 100644 (file)
@@ -208,7 +208,7 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n)
 
 DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
 
-static inline int get_recursion_context(int *recursion)
+static inline int get_recursion_context(u8 *recursion)
 {
        unsigned char rctx = interrupt_context_level();
 
@@ -221,7 +221,7 @@ static inline int get_recursion_context(int *recursion)
        return rctx;
 }
 
-static inline void put_recursion_context(int *recursion, int rctx)
+static inline void put_recursion_context(u8 *recursion, int rctx)
 {
        barrier();
        recursion[rctx]--;