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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160830094717.GA21472@krava>
Date:   Tue, 30 Aug 2016 11:47:17 +0200
From:   Jiri Olsa <jolsa@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Vegard Nossum <vegard.nossum@...il.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Stephane Eranian <eranian@...gle.com>,
        Vince Weaver <vincent.weaver@...ne.edu>,
        Ingo Molnar <mingo@...nel.org>,
        David Carrillo-Cisneros <davidcc@...gle.com>,
        "H. Peter Anvin" <hpa@...or.com>, Kan Liang <kan.liang@...el.com>,
        Arnaldo Carvalho de Melo <acme@...hat.com>,
        Paul Turner <pjt@...gle.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        linux-tip-commits@...r.kernel.org
Subject: Re: [tip:perf/core] perf/core: Check return value of the
 perf_event_read() IPI

On Tue, Aug 30, 2016 at 09:26:03AM +0200, Peter Zijlstra wrote:
> On Tue, Aug 30, 2016 at 08:47:24AM +0200, Peter Zijlstra wrote:
> 
> > If oncpu is not valid, the sched_out that made it invalid will have
> > updated the event count and we're good.
> > 
> > All I'll leave is an explicit comment that we've ignored the
> > smp_call_function_single() return value on purpose.
> 
> Something like so..

yep, it works in my tests

also I thought there's no group time update in __perf_event_read,
so I was hunting that but then I noticed we do that after during
the read..  and meanwhile came to patch below ;-)

jirka


---
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 305dbd28ea86..c637496251fe 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3440,6 +3440,26 @@ static int find_cpu_to_read(struct perf_event *event, int local_cpu)
 	return event_cpu;
 }
 
+static void read_update_times(struct perf_event *event, bool group)
+{
+	struct perf_event_context *ctx = event->ctx;
+
+	/*
+	 * may read while context is not active
+	 * (e.g., thread is blocked), in that case
+	 * we cannot update context time
+	 */
+	if (ctx->is_active) {
+		update_context_time(ctx);
+		update_cgrp_time_from_event(event);
+	}
+
+	if (group)
+		update_group_times(event);
+	else
+		update_event_times(event);
+}
+
 /*
  * Cross CPU call to read the hardware event
  */
@@ -3462,12 +3482,9 @@ static void __perf_event_read(void *info)
 		return;
 
 	raw_spin_lock(&ctx->lock);
-	if (ctx->is_active) {
-		update_context_time(ctx);
-		update_cgrp_time_from_event(event);
-	}
 
-	update_event_times(event);
+	read_update_times(event, data->group);
+
 	if (event->state != PERF_EVENT_STATE_ACTIVE)
 		goto unlock;
 
@@ -3482,7 +3499,6 @@ static void __perf_event_read(void *info)
 	pmu->read(event);
 
 	list_for_each_entry(sub, &event->sibling_list, group_entry) {
-		update_event_times(sub);
 		if (sub->state == PERF_EVENT_STATE_ACTIVE) {
 			/*
 			 * Use sibling's PMU rather than @event's since
@@ -3596,19 +3612,7 @@ static int perf_event_read(struct perf_event *event, bool group)
 		unsigned long flags;
 
 		raw_spin_lock_irqsave(&ctx->lock, flags);
-		/*
-		 * may read while context is not active
-		 * (e.g., thread is blocked), in that case
-		 * we cannot update context time
-		 */
-		if (ctx->is_active) {
-			update_context_time(ctx);
-			update_cgrp_time_from_event(event);
-		}
-		if (group)
-			update_group_times(event);
-		else
-			update_event_times(event);
+		read_update_times(event, group);
 		raw_spin_unlock_irqrestore(&ctx->lock, flags);
 	}
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ