From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559AbbIKLvN (ORCPT ); Fri, 11 Sep 2015 07:51:13 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:64778 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751556AbbIKLvM (ORCPT ); Fri, 11 Sep 2015 07:51:12 -0400 Message-ID: <55F2C01E.5020701@huawei.com> Date: Fri, 11 Sep 2015 19:50:54 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Arnaldo Carvalho de Melo , Kan Liang CC: Ingo Molnar , , "Arnaldo Carvalho de Melo" , Adrian Hunter , Borislav Petkov , David Ahern , "Frederic Weisbecker" , Namhyung Kim , "Stephane Eranian" Subject: Re: [PATCH 10/13] perf report: Do not blindly use env->cpu[al.cpu].socket_id References: <1441828225-667-1-git-send-email-acme@kernel.org> <1441828225-667-11-git-send-email-acme@kernel.org> In-Reply-To: <1441828225-667-11-git-send-email-acme@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0205.55F2C025.01FD,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 18cd06e89197dc6d15a2a00b6a906cd6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/9/10 3:50, Arnaldo Carvalho de Melo wrote: > From: Arnaldo Carvalho de Melo > > As al.cpu may be -1, i.e. no PERF_SAMPLE_CPU, and env->cpu may be NULL. > > Rely instead on the work now done in perf_event__preprocess_sample(), > that does all those checks. > > Reported-by: Wang Nan > Based-on-a-patch-by: Jiri Olsa > Cc: Adrian Hunter > Cc: Borislav Petkov > Cc: David Ahern > Cc: Frederic Weisbecker > Cc: Kan Liang > Cc: Namhyung Kim > Cc: Stephane Eranian > Cc: Wang Nan > Link: http://lkml.kernel.org/n/tip-2lw80g5ehsrec7tozhmnjgxw@git.kernel.org > Signed-off-by: Arnaldo Carvalho de Melo > --- > tools/perf/builtin-report.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > index 4b432453922f..9b5083630a56 100644 > --- a/tools/perf/builtin-report.c > +++ b/tools/perf/builtin-report.c > @@ -150,7 +150,6 @@ static int process_sample_event(struct perf_tool *tool, > .add_entry_cb = hist_iter__report_callback, > }; > int ret = 0; > - struct perf_env *env = evsel->evlist->env; > > if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) { > pr_debug("problem processing %d event, skipping it.\n", > @@ -158,9 +157,6 @@ static int process_sample_event(struct perf_tool *tool, > return -1; > } > > - /* read socket id from perf.data for perf report */ > - al.socket = env->cpu[al.cpu].socket_id; > - > if (rep->hide_unresolved && al.sym == NULL) > goto out_put; > I tested this patch on an 8 cores SOC. No segfault found now. Normal case: # ./perf record -a ls # ... # ./perf_arm64 report -v --stdio -s socket,cpu build id event received for [kernel.kallsyms]: ... # To display the perf.data header info, please use --header/--header-only options. # symsrc__init: cannot get elf header. Looking at the vmlinux_path (7 entries long) Failed to open /proc/kcore. Note /proc/kcore requires CAP_SYS_RAWIO capability to access. Using /proc/kallsyms for symbols Failed to open /sbin/adbd, continuing without symbols # # Total Lost Samples: 0 # # Samples: 291 of event 'cycles' # Event count (approx.): 40968659 # # Overhead Socket CPU # ........ ...... ... # 58.01% 000 004 35.61% 000 007 3.65% 000 005 1.23% 001 000 1.18% 001 001 0.19% 000 006 0.08% 001 002 0.07% 001 003 If one of CPUs is offlined before 'perf record': # ./perf record -a ls # ... # ./perf_arm64 report -v --stdio -s socket,cpu build id event received for [kernel.kallsyms]: d287ff3393fb1a01d3a785c3a1dac6e63d973bce # To display the perf.data header info, please use --header/--header-only options. # symsrc__init: cannot get elf header. Looking at the vmlinux_path (7 entries long) Failed to open /proc/kcore. Note /proc/kcore requires CAP_SYS_RAWIO capability to access. Using /proc/kallsyms for symbols Failed to open /sbin/adbd, continuing without symbols # # Total Lost Samples: 0 # # Samples: 304 of event 'cycles' # Event count (approx.): 42027298 # # Overhead Socket CPU # ........ ...... ... # 60.25% -001 004 32.69% -001 007 5.00% -001 005 1.34% -001 003 0.37% -001 000 0.20% -001 006 0.08% -001 002 0.07% -001 001 And if CPU is offlined during perf record (between build_cpu_topology() and perf_env__read_cpu_topology_map()): # ./perf report -v --stdio -s socket,cpu build id event received for [kernel.kallsyms]: ... core_id number is too big.You may need to upgrade the perf tool. <--- *please see this line* # To display the perf.data header info, please use --header/--header-only options. # symsrc__init: cannot get elf header. Looking at the vmlinux_path (7 entries long) Failed to open /proc/kcore. Note /proc/kcore requires CAP_SYS_RAWIO capability to access. Using /proc/kallsyms for symbols # # Total Lost Samples: 0 # # Samples: 278 of event 'cycles' # Event count (approx.): 37729429 # # Overhead Socket CPU # ........ ...... ... # 59.06% -001 004 36.93% -001 007 1.33% -001 000 1.18% -001 005 0.82% -001 006 0.50% -001 001 0.08% -001 002 0.08% -001 003