From patchwork Thu Oct 16 03:08:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 38794 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0777B20973 for ; Thu, 16 Oct 2014 03:14:02 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id d1sf1492833wiv.6 for ; Wed, 15 Oct 2014 20:14:02 -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=T0sWHa3s2vcC2VXtUDL3tvoF9vDhtkAmsUNn1CqIHy8=; b=jdgOiuKBDliG9vUsJAM98y+kkcrys6BkqkklCkG/89bdp8lGCzMerY7xwadP+l19M4 7UMpKtsom+5lo4xLSpcoocBAUWnCCiPK8uZCX9hub/4gw1jlkGVAqK5r08liT8aakZ40 oNj0p2Y/Uj00I9oohIvs90ZoOiHspdlDUTdTfvaXLd4EfoL06NPZ9fPGlirX4XEfBM6R GPrMazfSgFYFlXXEJEKZU0ivzhKrSXSVKo1/1LMcthuSchfq7suC2/e2Hw2nhfBRoxJn Xg5OhMHub8deZpKf8WeUICiOPsTtavaULNjFeQ9kXA2/lVBU665FdWbEXKK+Vw1r/yVT z11g== X-Gm-Message-State: ALoCoQnoreF3/lYfwMihxDPV7CwURYpcP2L4xu4QiCFogT1np+CpQCDfokVS1Kzl+NGb8eadq58r X-Received: by 10.180.75.133 with SMTP id c5mr2837826wiw.3.1413429242214; Wed, 15 Oct 2014 20:14:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.167 with SMTP id kr7ls109032lac.94.gmail; Wed, 15 Oct 2014 20:14:02 -0700 (PDT) X-Received: by 10.112.141.104 with SMTP id rn8mr27303lbb.87.1413429242023; Wed, 15 Oct 2014 20:14:02 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by mx.google.com with ESMTPS id dl8si13461428lad.68.2014.10.15.20.14.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Oct 2014 20:14:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gi9so2111169lab.7 for ; Wed, 15 Oct 2014 20:14:01 -0700 (PDT) X-Received: by 10.112.151.42 with SMTP id un10mr16240894lbb.21.1413429241848; Wed, 15 Oct 2014 20:14:01 -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 c5csp725442lbz; Wed, 15 Oct 2014 20:14:00 -0700 (PDT) X-Received: by 10.68.98.4 with SMTP id ee4mr16785743pbb.47.1413429239171; Wed, 15 Oct 2014 20:13:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lr3si17708849pab.140.2014.10.15.20.13.58 for ; Wed, 15 Oct 2014 20:13:59 -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 S1751342AbaJPDKn (ORCPT + 27 others); Wed, 15 Oct 2014 23:10:43 -0400 Received: from [119.145.14.65] ([119.145.14.65]:62443 "EHLO szxga02-in.huawei.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750993AbaJPDKl (ORCPT ); Wed, 15 Oct 2014 23:10:41 -0400 Received: from 172.24.2.119 (EHLO lggeml422-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CAU60845; Thu, 16 Oct 2014 11:09:51 +0800 (CST) Received: from kernel-host.huawei (10.107.197.247) by lggeml422-hub.china.huawei.com (10.72.61.32) with Microsoft SMTP Server id 14.3.158.1; Thu, 16 Oct 2014 11:09:41 +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: ensure return negitive value when write header error Date: Thu, 16 Oct 2014 11:08:29 +0800 Message-ID: <1413428909-80017-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.48 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: , When 'perf record' write headers, it calls write_xxx in tools/perf/util/header.c, and check return value. It rolls back all working only when return value is negative. This patch ensures write_cpudesc() and write_total_mem() return negative number when error. Without this patch, headers reported by 'perf report' header is error in some platform. Following output is caputured on ARM, which doesn't contain "Processor" field in /proc/cpuinfo. See "cpudesc", "total memory" and "cmdline" field. bash-4.2# perf record ls ... [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.001 MB perf.data (~36 samples) ] bash-4.2# perf report --stdio --header Error: The perf.data file has no samples! # ======== # captured on: Fri Sep 12 10:09:10 2014 # hostname : arma15el # os release : 3.17.0+ # perf version : 3.10.53 # arch : armv7l # nrcpus online : 4 # nrcpus avail : 1 # cpudesc : (null) # total memory : 0 kB # cmdline : # event : name = cycles, type = 0, config = 0x0, config1 = 0x0, config2 = 0x0, excl_usr = 0, excl_kern = 0, excl_host = 0, excl_guest = 1, precise_ip = 0 # pmu mappings: not available # ======== # Signed-off-by: Wang Nan Acked-by: Namhyung Kim --- tools/perf/util/header.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index ce0de00..39b80ac 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -605,8 +605,10 @@ static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, break; } - if (ret) + if (ret) { + ret = -1; goto done; + } s = buf; @@ -950,7 +952,8 @@ static int write_total_mem(int fd, struct perf_header *h __maybe_unused, n = sscanf(buf, "%*s %"PRIu64, &mem); if (n == 1) ret = do_write(fd, &mem, sizeof(mem)); - } + } else + ret = -1; free(buf); fclose(fp); return ret;