From patchwork Wed Oct 22 07:40:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 39258 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4F70920341 for ; Wed, 22 Oct 2014 07:42:47 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id b6sf1666648lbj.11 for ; Wed, 22 Oct 2014 00:42:46 -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=U6NJG8shzoZayaFOhXulGjxgS+jR2V6MdEYR1m/iWHQ=; b=EnFiW3B+rSh0Xh2Pp2S6fKDYUb/oRXmPpJwo8Sx5VpZKSyGnZb1Gytu3be2op4qUt4 82d531DxsGtN5E6qWiASLkqm0Zkg2iQBHSnA6ihZSbGQ/jePj5J1eY5ETVKRKbwCiSbZ kFVDvblKdzbBfwY7eA0Ub5iNd3xVz65JCQYoROynXWCdwbiAdVSSE+L04DxDxiXpfzZs NkqQPmkEKomgfHHnbyZU3e6w/TfprOtshPuxWdW+rlVUgsBRAsgdcaulDHSmCPdswz0o WRWtp2tG7rGSHVbhOhmF1WjTZjBFGchgsbwivbfA7kRFOY85LJV20/LXAoylwoEdMw1h x0zQ== X-Gm-Message-State: ALoCoQlFcfvkfJuC3PyIrN3nuJ3vAnhQg5FuuELNmS/ZpBjVUD4IhJZiXlis3sf8sFe0O2It+CmV X-Received: by 10.194.242.36 with SMTP id wn4mr317031wjc.4.1413963766118; Wed, 22 Oct 2014 00:42:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.1 with SMTP id 1ls176130laq.59.gmail; Wed, 22 Oct 2014 00:42:45 -0700 (PDT) X-Received: by 10.112.52.33 with SMTP id q1mr41019113lbo.42.1413963765741; Wed, 22 Oct 2014 00:42:45 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id o7si18051370lbp.45.2014.10.22.00.42.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 00:42:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id hs14so2427250lab.31 for ; Wed, 22 Oct 2014 00:42:45 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr40205283lbb.46.1413963765640; Wed, 22 Oct 2014 00:42:45 -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 c5csp26866lbz; Wed, 22 Oct 2014 00:42:44 -0700 (PDT) X-Received: by 10.68.136.195 with SMTP id qc3mr40492194pbb.40.1413963764057; Wed, 22 Oct 2014 00:42:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ak3si13488863pbc.91.2014.10.22.00.42.14 for ; Wed, 22 Oct 2014 00:42:44 -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 S932595AbaJVHmK (ORCPT + 27 others); Wed, 22 Oct 2014 03:42:10 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:5868 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752039AbaJVHmI (ORCPT ); Wed, 22 Oct 2014 03:42:08 -0400 Received: from 172.24.2.119 (EHLO lggeml425-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBC20499; Wed, 22 Oct 2014 15:41:51 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml425-hub.china.huawei.com (10.72.61.35) with Microsoft SMTP Server id 14.3.158.1; Wed, 22 Oct 2014 15:41:43 +0800 From: Wang Nan To: Namhyung Kim , CC: , , , , , , , Subject: [PATCH v2 RESEND] perf tools: makes CPUINFO_PROC to array for different kernel version Date: Wed, 22 Oct 2014 15:40:14 +0800 Message-ID: <1413963614-7251-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.215.44 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 kernel 3.7 (commit b4b8f770eb10a1bccaf8aa0ec1956e2dd7ed1e0a), /proc/cpuinfo replaces 'Processor' to 'model name'. This patch makes CPUINFO_PROC to an array and provides two choices for ARM, makes it compatible for different kernel version. v1 -> v2: minor changes as suggested by Namhyung Kim: - Doesn't pass @h and @evlist to __write_cpudesc; - Coding style fix. Signed-off-by: Wang Nan Cc: Namhyung Kim Acked-by: Namhyung Kim --- tools/perf/perf.h | 24 ++++++++++++------------ tools/perf/util/header.c | 27 +++++++++++++++++++++------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 32bd102..1a23392 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -6,7 +6,7 @@ #if defined(__i386__) #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 @@ -15,7 +15,7 @@ #if defined(__x86_64__) #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 @@ -25,7 +25,7 @@ #include "../../arch/powerpc/include/uapi/asm/unistd.h" #define rmb() asm volatile ("sync" ::: "memory") #define cpu_relax() asm volatile ("" ::: "memory"); -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"} #endif #ifdef __s390__ @@ -40,31 +40,31 @@ # define rmb() asm volatile("" ::: "memory") #endif #define cpu_relax() asm volatile("" ::: "memory") -#define CPUINFO_PROC "cpu type" +#define CPUINFO_PROC {"cpu type"} #endif #ifdef __hppa__ #define rmb() asm volatile("" ::: "memory") #define cpu_relax() asm volatile("" ::: "memory"); -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"} #endif #ifdef __sparc__ #define rmb() asm volatile("":::"memory") #define cpu_relax() asm volatile("":::"memory") -#define CPUINFO_PROC "cpu" +#define CPUINFO_PROC {"cpu"} #endif #ifdef __alpha__ #define rmb() asm volatile("mb" ::: "memory") #define cpu_relax() asm volatile("" ::: "memory") -#define CPUINFO_PROC "cpu model" +#define CPUINFO_PROC {"cpu model"} #endif #ifdef __ia64__ #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__ @@ -74,7 +74,7 @@ */ #define rmb() ((void(*)(void))0xffff0fa0)() #define cpu_relax() asm volatile("":::"memory") -#define CPUINFO_PROC "Processor" +#define CPUINFO_PROC {"model name", "Processor"} #endif #ifdef __aarch64__ @@ -91,19 +91,19 @@ : /* no input */ \ : "memory") #define cpu_relax() asm volatile("" ::: "memory") -#define CPUINFO_PROC "cpu model" +#define CPUINFO_PROC {"cpu model"} #endif #ifdef __arc__ #define rmb() asm volatile("" ::: "memory") #define cpu_relax() rmb() -#define CPUINFO_PROC "Processor" +#define CPUINFO_PROC {"Processor"} #endif #ifdef __metag__ #define rmb() asm volatile("" ::: "memory") #define cpu_relax() asm volatile("" ::: "memory") -#define CPUINFO_PROC "CPU" +#define CPUINFO_PROC {"CPU"} #endif #include diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index b59350f..d48f571 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -550,16 +550,12 @@ 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, 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; @@ -611,6 +607,25 @@ 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, 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) {