Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf/core: Reduce context switch overhead

Skip most of the PMU context switching overhead when ctx->nr_events is 0.

50% performance overhead was observed under an extreme testcase.

Signed-off-by: leilei.lin <leilei.lin@alibaba-inc.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: acme@kernel.org
Cc: alexander.shishkin@linux.intel.com
Cc: eranian@gmail.com
Cc: jolsa@redhat.com
Cc: linxiulei@gmail.com
Cc: yang_oliver@hotmail.com
Link: http://lkml.kernel.org/r/20170809002921.69813-1-leilei.lin@alibaba-inc.com
[ Rewrote the changelog. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

leilei.lin and committed by
Ingo Molnar
fdccc3fb ab027620

+9
+9
kernel/events/core.c
··· 3211 3211 return; 3212 3212 3213 3213 perf_ctx_lock(cpuctx, ctx); 3214 + /* 3215 + * We must check ctx->nr_events while holding ctx->lock, such 3216 + * that we serialize against perf_install_in_context(). 3217 + */ 3218 + if (!ctx->nr_events) 3219 + goto unlock; 3220 + 3214 3221 perf_pmu_disable(ctx->pmu); 3215 3222 /* 3216 3223 * We want to keep the following priority order: ··· 3231 3224 cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE); 3232 3225 perf_event_sched_in(cpuctx, ctx, task); 3233 3226 perf_pmu_enable(ctx->pmu); 3227 + 3228 + unlock: 3234 3229 perf_ctx_unlock(cpuctx, ctx); 3235 3230 } 3236 3231