From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751885AbbIGN1p (ORCPT ); Mon, 7 Sep 2015 09:27:45 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:14506 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878AbbIGN1n (ORCPT ); Mon, 7 Sep 2015 09:27:43 -0400 Message-ID: <55ED90BE.9090706@huawei.com> Date: Mon, 7 Sep 2015 21:27:26 +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: , CC: , , , Adrian Hunter , Andi Kleen , Jiri Olsa , Namhyung Kim , "Stephane Eranian" , Arnaldo Carvalho de Melo Subject: Re: [PATCH] perf report: Fix invalid memory accessing References: <1441630315-189525-1-git-send-email-wangnan0@huawei.com> In-Reply-To: <1441630315-189525-1-git-send-email-wangnan0@huawei.com> 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.0A090202.55ED90C8.0068,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: 70b0226fd079727707ebbb56b9d988d3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/9/7 20:51, Wang Nan wrote: [SNIP] > Although theoretically CPU_TOPOLOGY feature should always be selected by > 'perf record', I did generate a perf.data without that feature. It has > header like this: > > # perf report -i ./bad.perf.data --header-only > # ======== > # captured on: Thu Jan 8 09:30:15 2009 > # hostname : localhost > # os release : 3.10.49-gd672fc4 > # perf version : 4.2.gc9df > # arch : aarch64 > # nrcpus online : 8 > # nrcpus avail : 8 > # total memory : 1850768 kB > # cmdline : /system/bin/perf record -e sync:sync_timeline -e kgsl:kgsl_register_event -g -a sleep 5 > # event : name = sync:sync_timeline, , id = { 1107, 1108, 1109, 1110, 1111, 1112 }, type = 2, size = 112, config = 0x3e7, { sample_period, sample_freq } = 1, sample_type = IP|TID|TIME|CALLCHAIN|ID|CPU|PERIOD|RAW, read_format = ID, disabled = 1, inherit = 1, mmap = 1, comm = 1, task = 1, sample_id_all = 1, exclude_guest = 1, mmap2 = 1, comm_exec = 1 > # event : name = kgsl:kgsl_register_event, , id = { 1113, 1114, 1115, 1116, 1117, 1118 }, type = 2, size = 112, config = 0x350, { sample_period, sample_freq } = 1, sample_type = IP|TID|TIME|CALLCHAIN|ID|CPU|PERIOD|RAW, read_format = ID, disabled = 1, inherit = 1, sample_id_all = 1, exclude_guest = 1 > # pmu mappings: cpu = 4, software = 1, tracepoint = 2 > # ======== > # > > It should be: > > # ======== > # captured on: Thu Jan 8 11:26:41 2009 > ... > # HEADER_CPU_TOPOLOGY info available, use -I to display > # pmu mappings: cpu = 4, software = 1, tracepoint = 2 > # ======== > > However, bad perf.data appears randomly. I can't stably reproduce it, so I > guess there might have another invalid memory accessing. > > I found the problem. perf relies on build_cpu_topology() to fetch CPU_TOPOLOGY from sysfs. It depend on the existance of /sys/devices/system/cpu/cpu%d/topology/core_siblings_list However, CPU can be canceled by hotcpu subsystem. After that the directory of /sys/devices/system/cpu/cpu%d/topology is gone, which causes perf's write_cpu_topology() --> uild_cpu_topology() to fail, result in the above perf.data. So I think my patch is required. Thank you.