From patchwork Thu Oct 16 03:08:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 38793 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5594D20973 for ; Thu, 16 Oct 2014 03:10:44 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf1361440lab.3 for ; Wed, 15 Oct 2014 20:10:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=1+abCJsimAq1XuGcTe8PG2mBY9S8aEpfldYpQ/SHt6c=; b=Djzrc2MCNryTB10aywoy0ZjgKtNwKTRSfR/+q4cR00NZLGv38qxxmvg1ZokI3/L2g1 Z8pGpgOheAAibC3alqL6eecw8fdpry1cGu9scbyi0AYfFmN9zebpfXmKg/I61guQzZnr JEwR+aTSZJ4oE94z5ZhuWKR2NQ6qA4NA9xrbEcjgXCp97mo/jyOHKHI2dZuYEpzvLmpf nkcJmUdErPnb3GVsGPSyxaXKBk4LQ9e0dBPgEIrpRqPsehiBAQEQdiVcvrGUafsOBtTO WeJON7Pno1nNc8MepQnrLNeDERx76qgSwlBKpXyNflIn5m5BeSmPEw8c37a/3mMvyDA1 13nA== X-Gm-Message-State: ALoCoQlf3aXuniW5xuD4PNM66RseJgbI0xQ28QGaMWVTSZCj5PudY1iELbojgtFrXzjdgnAEZ0rN X-Received: by 10.180.19.198 with SMTP id h6mr798445wie.5.1413429042911; Wed, 15 Oct 2014 20:10:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.67 with SMTP id z3ls117015lag.74.gmail; Wed, 15 Oct 2014 20:10:42 -0700 (PDT) X-Received: by 10.152.20.132 with SMTP id n4mr16691917lae.50.1413429042705; Wed, 15 Oct 2014 20:10:42 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by mx.google.com with ESMTPS id tj1si31128229lbb.73.2014.10.15.20.10.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Oct 2014 20:10:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id z12so2090270lbi.30 for ; Wed, 15 Oct 2014 20:10:42 -0700 (PDT) X-Received: by 10.152.28.134 with SMTP id b6mr16970155lah.12.1413429042527; Wed, 15 Oct 2014 20:10:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp725180lbz; Wed, 15 Oct 2014 20:10:41 -0700 (PDT) X-Received: by 10.68.162.65 with SMTP id xy1mr821635pbb.144.1413429040955; Wed, 15 Oct 2014 20:10:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rz7si17723882pab.123.2014.10.15.20.10.39 for ; Wed, 15 Oct 2014 20:10:40 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751281AbaJPDKT (ORCPT + 27 others); Wed, 15 Oct 2014 23:10:19 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:38452 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbaJPDKR (ORCPT ); Wed, 15 Oct 2014 23:10:17 -0400 Received: from 172.24.2.119 (EHLO lggeml426-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CCX68293; Thu, 16 Oct 2014 11:10:03 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml426-hub.china.huawei.com (10.72.61.36) with Microsoft SMTP Server id 14.3.158.1; Thu, 16 Oct 2014 11:09:55 +0800 From: Wang Nan To: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Namhyung Kim , Wang Nan , Waiman Long CC: , Li Zefan Subject: [PATCH] perf tools: makes CPUINFO_PROC to array for different kernel version Date: Thu, 16 Oct 2014 11:08:43 +0800 Message-ID: <1413428923-80073-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 MIME-Version: 1.0 X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , After kerne 3.7 (commit b4b8f770eb10a1bccaf8aa0ec1956e2dd7ed1e0a), /proc/cpuinfo replcae 'Processor' to 'model name'. This patch makes CPUINFO_PROC to an array and provides two choices for ARM, make it compatible for different kernel version. Signed-off-by: Wang Nan --- tools/perf/perf-sys.h | 30 +++++++++++++++--------------- tools/perf/util/header.c | 26 ++++++++++++++++++++------ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h index 937e432..a3b13d7 100644 --- a/tools/perf/perf-sys.h +++ b/tools/perf/perf-sys.h @@ -13,7 +13,7 @@ #define wmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") #define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") #define cpu_relax() asm volatile("rep; nop" ::: "memory"); -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"} #ifndef __NR_perf_event_open # define __NR_perf_event_open 336 #endif @@ -30,7 +30,7 @@ #define wmb() asm volatile("sfence" ::: "memory") #define rmb() asm volatile("lfence" ::: "memory") #define cpu_relax() asm volatile("rep; nop" ::: "memory"); -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"} #ifndef __NR_perf_event_open # define __NR_perf_event_open 298 #endif @@ -47,14 +47,14 @@ #define mb() asm volatile ("sync" ::: "memory") #define wmb() asm volatile ("sync" ::: "memory") #define rmb() asm volatile ("sync" ::: "memory") -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"} #endif #ifdef __s390__ #define mb() asm volatile("bcr 15,0" ::: "memory") #define wmb() asm volatile("bcr 15,0" ::: "memory") #define rmb() asm volatile("bcr 15,0" ::: "memory") -#define CPUINFO_PROC "vendor_id" +#define CPUINFO_PROC {"vendor_id"} #endif #ifdef __sh__ @@ -67,14 +67,14 @@ # define wmb() asm volatile("" ::: "memory") # define rmb() asm volatile("" ::: "memory") #endif -#define CPUINFO_PROC "cpu type" +#define CPUINFO_PROC {"cpu type"} #endif #ifdef __hppa__ #define mb() asm volatile("" ::: "memory") #define wmb() asm volatile("" ::: "memory") #define rmb() asm volatile("" ::: "memory") -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"} #endif #ifdef __sparc__ @@ -87,14 +87,14 @@ #endif #define wmb() asm volatile("":::"memory") #define rmb() asm volatile("":::"memory") -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"} #endif #ifdef __alpha__ #define mb() asm volatile("mb" ::: "memory") #define wmb() asm volatile("wmb" ::: "memory") #define rmb() asm volatile("mb" ::: "memory") -#define CPUINFO_PROC "cpu model" +#define CPUINFO_PROC {"cpu model"} #endif #ifdef __ia64__ @@ -102,7 +102,7 @@ #define wmb() asm volatile ("mf" ::: "memory") #define rmb() asm volatile ("mf" ::: "memory") #define cpu_relax() asm volatile ("hint @pause" ::: "memory") -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"} #endif #ifdef __arm__ @@ -113,7 +113,7 @@ #define mb() ((void(*)(void))0xffff0fa0)() #define wmb() ((void(*)(void))0xffff0fa0)() #define rmb() ((void(*)(void))0xffff0fa0)() -#define CPUINFO_PROC "Processor" +#define CPUINFO_PROC {"model name", "Processor"} #endif #ifdef __aarch64__ @@ -133,28 +133,28 @@ : "memory") #define wmb() mb() #define rmb() mb() -#define CPUINFO_PROC "cpu model" +#define CPUINFO_PROC {"cpu model"} #endif #ifdef __arc__ #define mb() asm volatile("" ::: "memory") #define wmb() asm volatile("" ::: "memory") #define rmb() asm volatile("" ::: "memory") -#define CPUINFO_PROC "Processor" +#define CPUINFO_PROC {"Processor"} #endif #ifdef __metag__ #define mb() asm volatile("" ::: "memory") #define wmb() asm volatile("" ::: "memory") #define rmb() asm volatile("" ::: "memory") -#define CPUINFO_PROC "CPU" +#define CPUINFO_PROC {"CPU"} #endif #ifdef __xtensa__ #define mb() asm volatile("memw" ::: "memory") #define wmb() asm volatile("memw" ::: "memory") #define rmb() asm volatile("" ::: "memory") -#define CPUINFO_PROC "core ID" +#define CPUINFO_PROC {"core ID"} #endif #ifdef __tile__ @@ -162,7 +162,7 @@ #define wmb() asm volatile ("mf" ::: "memory") #define rmb() asm volatile ("mf" ::: "memory") #define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory") -#define CPUINFO_PROC "model name" +#define CPUINFO_PROC {"model name"} #endif #define barrier() asm volatile ("" ::: "memory") diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 39b80ac..e23cd45 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -579,16 +579,13 @@ static int write_version(int fd, struct perf_header *h __maybe_unused, return do_write_string(fd, perf_version_string); } -static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, - struct perf_evlist *evlist __maybe_unused) +static int __write_cpudesc(int fd, struct perf_header *h __maybe_unused, + struct perf_evlist *evlist __maybe_unused, const char *cpuinfo_proc) { -#ifndef CPUINFO_PROC -#define CPUINFO_PROC NULL -#endif FILE *file; char *buf = NULL; char *s, *p; - const char *search = CPUINFO_PROC; + const char *search = cpuinfo_proc; size_t len = 0; int ret = -1; @@ -640,6 +637,23 @@ done: return ret; } +static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, + struct perf_evlist *evlist __maybe_unused) +{ +#ifndef CPUINFO_PROC +#define CPUINFO_PROC {"model name", } +#endif + const char *cpuinfo_procs[] = CPUINFO_PROC; + unsigned int i; + for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) { + int ret; + ret = __write_cpudesc(fd, h, evlist, cpuinfo_procs[i]); + if (ret >= 0) + return ret; + } + return -1; +} + static int write_nrcpus(int fd, struct perf_header *h __maybe_unused, struct perf_evlist *evlist __maybe_unused) {