From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753792AbbINBhe (ORCPT ); Sun, 13 Sep 2015 21:37:34 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:51012 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753392AbbINBhd (ORCPT ); Sun, 13 Sep 2015 21:37:33 -0400 Message-ID: <55F624CC.9050203@huawei.com> Date: Mon, 14 Sep 2015 09:37:16 +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 CC: Kan Liang , Ingo Molnar , , Adrian Hunter , Borislav Petkov , David Ahern , "Frederic Weisbecker" , Jiri Olsa , Namhyung Kim , Stephane Eranian Subject: Re: [RFC 00/13] perf_env/CPU socket reorg/fixes References: <1441828225-667-1-git-send-email-acme@kernel.org> <55F2C726.4080204@huawei.com> <20150911130339.GI23511@kernel.org> <20150911132937.GK23511@kernel.org> <20150911133052.GL23511@kernel.org> <20150911133606.GM23511@kernel.org> In-Reply-To: <20150911133606.GM23511@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.0A090203.55F624D3.0063,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: f33aca97197229792835275612897600 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/9/11 21:36, Arnaldo Carvalho de Melo wrote: > Em Fri, Sep 11, 2015 at 10:30:52AM -0300, Arnaldo Carvalho de Melo escreveu: >> Em Fri, Sep 11, 2015 at 10:29:37AM -0300, Arnaldo Carvalho de Melo escreveu: >>> Em Fri, Sep 11, 2015 at 10:03:39AM -0300, Arnaldo Carvalho de Melo escreveu: >>>> Em Fri, Sep 11, 2015 at 08:20:54PM +0800, Wangnan (F) escreveu: >>>>> I have tested patch 1 to 10. They looks good to me except patch 4/13. Please >>>> Ok, I'll take that as a Tested-by: you for 1-10 with 4/13 having the >>>> checks added, ok? >>> >>>>> see my email in that thread. >>> >>>> I add those checks. >>> Ok, below is the diff for adding the checks. The get_{core,socket}_id >>> functions should be moved to tools/lib/api/cpu.[ch], using the same >>> interface as cpu__get_max_freq(&value), using the int return value to >>> propagate the precise error, etc. Will do it in a follow up patch. >> Humm, but then, what happens if a CPU is offline? I'm checking it now... > # cat /sys/devices/system/cpu/cpu3/topology/core_id > 3 > # cat > /sys/devices/system/cpu/cpu3/topology/physical_package_id > 0 > # echo 0 > /sys/devices/system/cpu/cpu3/online > # cat > /sys/devices/system/cpu/cpu3/topology/physical_package_id > cat: /sys/devices/system/cpu/cpu3/topology/physical_package_id: No such file or directory > # cat /sys/devices/system/cpu/cpu3/topology/core_id > cat: /sys/devices/system/cpu/cpu3/topology/core_id: No such file or directory > # > > So we shouldn't check the result, right? We could further validate it by > checking: > > # cat /sys/devices/system/cpu/cpu3/online > 0 > # > > But assuming that not being able to access it means it is offline looks > almost reasonable, if not strictly correct, so I'm removing the tests > and will revisit this when I move those functions to > tools/lib/api/cpu.[ch]. I highly suspect that setting 'online' to 0 is not the only reason of the removal of topology directory. Testing the existance of the two files should be better. Thank you. > - Arnaldo > >>> diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c >>> index 6af4f7c36820..2e4cad84197b 100644 >>> --- a/tools/perf/util/env.c >>> +++ b/tools/perf/util/env.c >>> @@ -60,7 +60,7 @@ out_enomem: >>> >>> int perf_env__read_cpu_topology_map(struct perf_env *env) >>> { >>> - int cpu, nr_cpus; >>> + int cpu, nr_cpus, err; >>> >>> if (env->cpu != NULL) >>> return 0; >>> @@ -77,10 +77,17 @@ int perf_env__read_cpu_topology_map(struct perf_env *env) >>> return -ENOMEM; >>> >>> for (cpu = 0; cpu < nr_cpus; ++cpu) { >>> - env->cpu[cpu].core_id = cpu_map__get_core_id(cpu); >>> - env->cpu[cpu].socket_id = cpu_map__get_socket_id(cpu); >>> + err = env->cpu[cpu].core_id = cpu_map__get_core_id(cpu); >>> + if (err < 0) >>> + goto out_free; >>> + err = env->cpu[cpu].socket_id = cpu_map__get_socket_id(cpu); >>> + if (err < 0) >>> + goto out_free; >>> } >>> >>> - env->nr_cpus_avail = nr_cpus; >>> return 0; >>> + >>> +out_free: >>> + zfree(&env->cpu); >>> + return err; >>> }