From patchwork Wed Oct 29 14:06:25 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: 39783 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CB0DC24046 for ; Wed, 29 Oct 2014 14:08:25 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id ge10sf1739880lab.5 for ; Wed, 29 Oct 2014 07:08:24 -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=Kn4gNZp2sYRJnjyY3rTLbu2e5q3QaN9XuqHKH6oNdAE=; b=NPcGBawVLwc0Zyl0MO5MRakC2jcqAE31xASoeRWl9esXD4lJGIJhAYdQGsS7uf7p96 u1FIAUAoSRDC1A2W0A7EmknBm2VEh0p8PBxSiJNXgM2RF73aWWQdnj9XgbVc/gsiZ6vw oVl0nunBAyZZYcpFBjEsbDm6Q3EjvylABobDu++L5HqlaWAkaREMp9ZggR1wBkfQdjbn IclSjPhMsVxDLhjs58ckr5Dm68IRjXQ0ET+4kmPC2Js/dkUc6RXh4fsgEFvPB65+Ec17 2oTiz5tA+IHLlXDHmVK2Un0/SMBgQKuJemI8udptRWceT8qYM44N/2Ivu1YuuqZf9Qv1 J4JA== X-Gm-Message-State: ALoCoQlOjXIZTlwdXen69ozbb6OcM6686Zn1mF1F4RA6LxoUEGE8EksVtCxVy+ug/6JVdm3er3Zb X-Received: by 10.194.178.163 with SMTP id cz3mr1816945wjc.1.1414591704619; Wed, 29 Oct 2014 07:08:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.227 with SMTP id i3ls167184lae.28.gmail; Wed, 29 Oct 2014 07:08:24 -0700 (PDT) X-Received: by 10.112.199.40 with SMTP id jh8mr5541656lbc.5.1414591704371; Wed, 29 Oct 2014 07:08:24 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id r3si7308340lar.133.2014.10.29.07.08.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 07:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id 10so2457048lbg.8 for ; Wed, 29 Oct 2014 07:08:24 -0700 (PDT) X-Received: by 10.112.14.69 with SMTP id n5mr11652399lbc.34.1414591704269; Wed, 29 Oct 2014 07:08:24 -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 c5csp663914lbz; Wed, 29 Oct 2014 07:08:23 -0700 (PDT) X-Received: by 10.70.130.47 with SMTP id ob15mr10909792pdb.112.1414591700049; Wed, 29 Oct 2014 07:08:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id km1si4168681pbd.22.2014.10.29.07.08.19 for ; Wed, 29 Oct 2014 07:08:19 -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 S933637AbaJ2OIG (ORCPT + 26 others); Wed, 29 Oct 2014 10:08:06 -0400 Received: from mail.kernel.org ([198.145.19.201]:41281 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933594AbaJ2OIA (ORCPT ); Wed, 29 Oct 2014 10:08:00 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E01122024C; Wed, 29 Oct 2014 14:07:58 +0000 (UTC) Received: from zoo.ghostprotocols.net.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 995892022A; Wed, 29 Oct 2014 14:07:54 +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 13/25] perf tools: Ensure return negative value when write header error Date: Wed, 29 Oct 2014 12:06:25 -0200 Message-Id: <1414591597-2763-14-git-send-email-acme@kernel.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1414591597-2763-1-git-send-email-acme@kernel.org> References: <1414591597-2763-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.217.177 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 26f5b2fe5dc8..0ecf4a304cbc 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -601,8 +601,10 @@ static int __write_cpudesc(int fd, const char *cpuinfo_proc) break; } - if (ret) + if (ret) { + ret = -1; goto done; + } s = buf; @@ -965,7 +967,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;