lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  4 Aug 2017 16:50:54 +0800
From:   "石祤" <linxiulei@...il.com>
To:     yang_oliver@...mail.com, peterz@...radead.org, mingo@...hat.com,
        acme@...nel.org, alexander.shishkin@...ux.intel.com,
        linux-kernel@...r.kernel.org, tglx@...utronix.de,
        eranian@...il.com, torvalds@...ux-foundation.org, jolsa@...hat.com,
        linxiulei@...il.com
Cc:     "leilei.lin" <leilei.lin@...baba-inc.com>
Subject: [PATCH] perf/core: Avoid context switch overheads

From: "leilei.lin" <leilei.lin@...baba-inc.com>

A performance issue caused by less strickly check in task
sched when these tasks were once attached by per-task perf_event.

A task will alloc task->perf_event_ctxp[ctxn] when it was called
by perf_event_open, and task->perf_event_ctxp[ctxn] would not
ever be freed to NULL.

__perf_event_task_sched_in()
	if (task->perf_event_ctxp[ctxn]) //  here is always true
		perf_event_context_sched_in() // operate pmu

50% at most performance overhead was observed under some extreme
test case. Therefor, add a more strick check as to ctx->nr_events,
when ctx->nr_events == 0, it's no need to continue.

Signed-off-by: leilei.lin <leilei.lin@...baba-inc.com>
---
 kernel/events/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 426c2ff..f071013 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3179,6 +3179,9 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
 	if (cpuctx->task_ctx == ctx)
 		return;
 
+	if (!cpuctx->task_ctx && !ctx->nr_events)
+		return;
+
 	perf_ctx_lock(cpuctx, ctx);
 	perf_pmu_disable(ctx->pmu);
 	/*
-- 
2.8.4.31.g9ed660f

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ