Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2887410ima; Sun, 3 Feb 2019 08:47:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IZD3+7nGb0Vf36kLVfxW93uutqdgJEm05VoMDkPAonFGhfSoHfkJSGFEqGi9NZOj7OMPoV9 X-Received: by 2002:a63:f94c:: with SMTP id q12mr9749876pgk.91.1549212451350; Sun, 03 Feb 2019 08:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549212451; cv=none; d=google.com; s=arc-20160816; b=O8vlMlHQOBWIQazlmsS2+FVkYt88nAm0P3PnKc2v2Q5htZGPRDfKX+NtPF8BQHkQTv jZGiWfEoRB7NTM6+BpSKRU6R96yMAAKeOKykhrwTloRo6HM6OJf4hgGVbXIQZDJpC99q 3UFIdvt8R3qiGnBwypUgqW5CIJoy6jfecdTGZmAtmUUut4pO1O/oadAW895bEGCCS+4S 81myd3qW29e0+CzX9o7EfDc+MhtwbaHVF6mCMu2Yj8YT1ej1odES20vlQYBK/3K3FfGI XIfiWNWIgGbteYNZZzULXzlN/CzgFDTBABkavXCvUveTUCVXeQj4cr/Vk91PcZSIWJ3G yxhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=u3NfMyvzeMmgMVq1y1FAsULZV+Zpzk5XB3n0cmlraoA=; b=WOcspwi4iIWxusOY+EXyM4F1zmOnkDXS/mAxozeEozXVcXWgsnIkaW0yLmd9XIATWf 2SNUFSCtC25yHtvT3zs5itFtplR1Rj6C+ocoAS4t+kimui3na3qFSmXbp+Ash2BTu/+T kVbTSXpocFAJNgZ9OOJV76fWfJ14gSHkNDe4ckXxH2S0HRVA4w43cVXga2hnnt1RAOWg Rapc3yelLbS2xqjpmrrgryua5oIY8mMYNIYz+i2i6Jqsu5zd/TWaPyVaGgBBlOd+UwMi houlLGbBNPhZeH9qE/n/oEGNK7V3/243Cd64m55YYmM6Lr5b1Eom0ffExKf8jaUxwGdV /IWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n184si8866979pgn.95.2019.02.03.08.47.15; Sun, 03 Feb 2019 08:47:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728589AbfBCPbA (ORCPT + 99 others); Sun, 3 Feb 2019 10:31:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33144 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728568AbfBCPaz (ORCPT ); Sun, 3 Feb 2019 10:30:55 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78569144041; Sun, 3 Feb 2019 15:30:55 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-46.brq.redhat.com [10.40.204.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 083FD5C23D; Sun, 3 Feb 2019 15:30:52 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Adrian Hunter , Andi Kleen , Stephane Eranian , Alexey Budankov Subject: [PATCH 11/14] perf data: Make perf_data__size to work over directory Date: Sun, 3 Feb 2019 16:30:15 +0100 Message-Id: <20190203153018.9650-12-jolsa@kernel.org> In-Reply-To: <20190203153018.9650-1-jolsa@kernel.org> References: <20190203153018.9650-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 03 Feb 2019 15:30:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Making perf_data__size to return proper size for directory data. Link: http://lkml.kernel.org/n/tip-t4dm8cctat2ginmy2bb08xe8@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/data.c | 17 +++++++++++++++++ tools/perf/util/data.h | 6 +----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index fbe46dab8dbd..a36583bced1c 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -367,3 +367,20 @@ int perf_data__switch(struct perf_data *data, free(new_filepath); return ret; } + +unsigned long perf_data__size(struct perf_data *data) +{ + u64 size = data->file.size; + int i; + + if (!data->is_dir) + return size; + + for (i = 0; i < data->dir.nr; i++) { + struct perf_data_file *file = &data->dir.files[i]; + + size += file->size; + } + + return size; +} diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h index bd7affb69dba..c1b35e7352df 100644 --- a/tools/perf/util/data.h +++ b/tools/perf/util/data.h @@ -54,11 +54,6 @@ static inline int perf_data__fd(struct perf_data *data) return data->file.fd; } -static inline unsigned long perf_data__size(struct perf_data *data) -{ - return data->file.size; -} - int perf_data__open(struct perf_data *data); void perf_data__close(struct perf_data *data); ssize_t perf_data__write(struct perf_data *data, @@ -79,4 +74,5 @@ int perf_data__switch(struct perf_data *data, int perf_data__create_dir(struct perf_data *data, int nr); void perf_data__free_dir(struct perf_data *data); int perf_data__update_dir(struct perf_data *data); +unsigned long perf_data__size(struct perf_data *data); #endif /* __PERF_DATA_H */ -- 2.17.2