Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752111AbcCGDvy (ORCPT ); Sun, 6 Mar 2016 22:51:54 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:20532 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751902AbcCGDvr (ORCPT ); Sun, 6 Mar 2016 22:51:47 -0500 From: Wang Nan To: , CC: , Wang Nan , He Kuang , Alexei Starovoitov , "Arnaldo Carvalho de Melo" , Brendan Gregg , "Jiri Olsa" , Masami Hiramatsu , Namhyung Kim , Zefan Li , Subject: [RESEND PATCH 2/5] perf core: Set event's default overflow_handler Date: Mon, 7 Mar 2016 03:50:16 +0000 Message-ID: <1457322619-170254-3-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1457322619-170254-1-git-send-email-wangnan0@huawei.com> References: <1457322619-170254-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.56DCFA8E.000B,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: a45c1fa2d72f06767e65609b14e5b070 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2120 Lines: 62 Set a default event->overflow_handler in perf_event_alloc() so don't need checking event->overflow_handler in __perf_event_overflow(). Following commits can give a different default overflow_handler. No extra performance introduced into hot path because in the original code we still need reading this handler from memory. A conditional branch is avoided so actually we remove some instructions. Initial idea comes from Peter at [1]. [1] http://lkml.kernel.org/r/20130708121557.GA17211@twins.programming.kicks-ass.net Signed-off-by: Wang Nan Cc: He Kuang Cc: Alexei Starovoitov Cc: Arnaldo Carvalho de Melo Cc: Brendan Gregg Cc: Ingo Molnar Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com --- kernel/events/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 088c7fe..ed94c91 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6467,10 +6467,7 @@ static int __perf_event_overflow(struct perf_event *event, irq_work_queue(&event->pending); } - if (event->overflow_handler) - event->overflow_handler(event, data, regs); - else - perf_event_output(event, data, regs); + event->overflow_handler(event, data, regs); if (*perf_event_fasync(event) && event->pending_kill) { event->pending_wakeup = 1; @@ -7963,8 +7960,13 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, context = parent_event->overflow_handler_context; } - event->overflow_handler = overflow_handler; - event->overflow_handler_context = context; + if (overflow_handler) { + event->overflow_handler = overflow_handler; + event->overflow_handler_context = context; + } else { + event->overflow_handler = perf_event_output; + event->overflow_handler_context = NULL; + } perf_event__state_init(event); -- 1.8.3.4