Skip to content

Commit 4baeb06

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
perf/core: Merge struct pmu::pmu_disable_count into struct perf_cpu_pmu_context::pmu_disable_count
Because it makes no sense to have two per-cpu allocations per pmu. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Ravi Bangoria <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8f2221f commit 4baeb06

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

include/linux/perf_event.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ struct pmu {
343343
*/
344344
unsigned int scope;
345345

346-
int __percpu *pmu_disable_count;
347346
struct perf_cpu_pmu_context __percpu *cpu_pmu_context;
348347
atomic_t exclusive_cnt; /* < 0: cpu; > 0: tsk */
349348
int task_ctx_nr;
@@ -1031,6 +1030,7 @@ struct perf_cpu_pmu_context {
10311030

10321031
int active_oncpu;
10331032
int exclusive;
1033+
int pmu_disable_count;
10341034

10351035
raw_spinlock_t hrtimer_lock;
10361036
struct hrtimer hrtimer;

kernel/events/core.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,21 +1219,22 @@ static int perf_mux_hrtimer_restart_ipi(void *arg)
12191219

12201220
void perf_pmu_disable(struct pmu *pmu)
12211221
{
1222-
int *count = this_cpu_ptr(pmu->pmu_disable_count);
1222+
int *count = &this_cpu_ptr(pmu->cpu_pmu_context)->pmu_disable_count;
12231223
if (!(*count)++)
12241224
pmu->pmu_disable(pmu);
12251225
}
12261226

12271227
void perf_pmu_enable(struct pmu *pmu)
12281228
{
1229-
int *count = this_cpu_ptr(pmu->pmu_disable_count);
1229+
int *count = &this_cpu_ptr(pmu->cpu_pmu_context)->pmu_disable_count;
12301230
if (!--(*count))
12311231
pmu->pmu_enable(pmu);
12321232
}
12331233

12341234
static void perf_assert_pmu_disabled(struct pmu *pmu)
12351235
{
1236-
WARN_ON_ONCE(*this_cpu_ptr(pmu->pmu_disable_count) == 0);
1236+
int *count = &this_cpu_ptr(pmu->cpu_pmu_context)->pmu_disable_count;
1237+
WARN_ON_ONCE(*count == 0);
12371238
}
12381239

12391240
static inline void perf_pmu_read(struct perf_event *event)
@@ -11906,7 +11907,6 @@ static bool idr_cmpxchg(struct idr *idr, unsigned long id, void *old, void *new)
1190611907

1190711908
static void perf_pmu_free(struct pmu *pmu)
1190811909
{
11909-
free_percpu(pmu->pmu_disable_count);
1191011910
if (pmu_bus_running && pmu->dev && pmu->dev != PMU_NULL_DEV) {
1191111911
if (pmu->nr_addr_filters)
1191211912
device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
@@ -11925,10 +11925,6 @@ int perf_pmu_register(struct pmu *_pmu, const char *name, int type)
1192511925
struct pmu *pmu __free(pmu_unregister) = _pmu;
1192611926
guard(mutex)(&pmus_lock);
1192711927

11928-
pmu->pmu_disable_count = alloc_percpu(int);
11929-
if (!pmu->pmu_disable_count)
11930-
return -ENOMEM;
11931-
1193211928
if (WARN_ONCE(!name, "Can not register anonymous pmu.\n"))
1193311929
return -EINVAL;
1193411930

0 commit comments

Comments
 (0)