Re: [tip:perf/core] perf/core: Check return value of the perf_event_read() IPI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
 	}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux