From patchwork Tue Oct 28 13:32:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 39665 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8003424026 for ; Tue, 28 Oct 2014 13:34:13 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d17sf705167eek.3 for ; Tue, 28 Oct 2014 06:34:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=+6UZoomR9CpI1IfSgaElxzOMnamvJIyggYzT80gY1yw=; b=m4LmhVfRGKCHjFOM5n8oNc2HHVx12z1eElWYNsnmIYVGmYAIoXgShZk81lHu785dqE wiEddVvCXEQlW4EE87cfnd4Qj1XmoBuwmeCxIh1tOkpBjVgFHtPBgb6jxooAvDciS+SU 1Hz21F/S1th0xpOAAgJINIygNRGWR/jL+hAtp8RW/OhxQhHEu/MDmY4sPBj0I4v2CKvT mzZNYCLWe3M3QsEgaEebYxawxj8v8oEGt6F+AHOpCwvmwnwRnvAYxDPOpyYg+LoQmSqn D/rd7RJ/p0iK3Y02csrD/gEEc/k2Zs2HAf4/nr3rDmcRRK6el8alwMwAHqUmoQzXXZAC VaHA== X-Gm-Message-State: ALoCoQkWdfYVEGsZYbspZbvLvsqmLYnUAgFXgOmKzN13FpOfMOqryY+h8Ulw6xAjJd+pebtmk4Nc X-Received: by 10.180.93.35 with SMTP id cr3mr763064wib.2.1414503252698; Tue, 28 Oct 2014 06:34:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.226 with SMTP id z2ls64644lad.13.gmail; Tue, 28 Oct 2014 06:34:12 -0700 (PDT) X-Received: by 10.112.201.138 with SMTP id ka10mr4178800lbc.20.1414503252378; Tue, 28 Oct 2014 06:34:12 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id e3si2626138lam.28.2014.10.28.06.34.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 06:34:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id hs14so614805lab.19 for ; Tue, 28 Oct 2014 06:34:12 -0700 (PDT) X-Received: by 10.112.14.69 with SMTP id n5mr4127424lbc.34.1414503252263; Tue, 28 Oct 2014 06:34:12 -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 c5csp481022lbz; Tue, 28 Oct 2014 06:34:11 -0700 (PDT) X-Received: by 10.70.92.68 with SMTP id ck4mr3760892pdb.28.1414503240927; Tue, 28 Oct 2014 06:34:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id py4si1329994pbb.157.2014.10.28.06.34.00 for ; Tue, 28 Oct 2014 06:34:00 -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 S1754534AbaJ1Ndt (ORCPT + 26 others); Tue, 28 Oct 2014 09:33:49 -0400 Received: from mail.kernel.org ([198.145.19.201]:51375 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754463AbaJ1Ndo (ORCPT ); Tue, 28 Oct 2014 09:33:44 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 980192024F; Tue, 28 Oct 2014 13:33:43 +0000 (UTC) Received: from zoo.home (unknown [191.250.127.60]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DD7A2024D; Tue, 28 Oct 2014 13:33:39 +0000 (UTC) From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Wang Nan , Adrian Hunter , Ingo Molnar , Jiri Olsa , Li Zefan , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Waiman Long , Arnaldo Carvalho de Melo Subject: [PATCH 14/32] perf tools: Ensure return negative value when write header error Date: Tue, 28 Oct 2014 11:32:08 -0200 Message-Id: <1414503146-22789-15-git-send-email-acme@kernel.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1414503146-22789-1-git-send-email-acme@kernel.org> References: <1414503146-22789-1-git-send-email-acme@kernel.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: acme@kernel.org 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.46 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: , From: Wang Nan 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 # ======== # Cc: Adrian Hunter Cc: Ingo Molnar Cc: Jiri Olsa Cc: Li Zefan Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Waiman Long Link: http://lkml.kernel.org/r/1413428909-80017-1-git-send-email-wangnan0@huawei.com Signed-off-by: Wang Nan Signed-off-by: Arnaldo Carvalho de Melo --- 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 ce0de00399da..39b80ac9f698 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;