Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754380AbbLJHyV (ORCPT ); Thu, 10 Dec 2015 02:54:21 -0500 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:58081 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753751AbbLJHxo (ORCPT ); Thu, 10 Dec 2015 02:53:44 -0500 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Frederic Weisbecker , Andi Kleen , Stephane Eranian , Adrian Hunter Subject: [PATCH/RFC 10/16] perf hist: Add events_stats__add() and hists__add_stats() Date: Thu, 10 Dec 2015 16:53:29 +0900 Message-Id: <1449734015-9148-11-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449734015-9148-1-git-send-email-namhyung@kernel.org> References: <1449734015-9148-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2359 Lines: 70 These two functions are to update event and hists stats. They'll be used by multi threads to update local stats in the later patch. Signed-off-by: Namhyung Kim --- tools/perf/util/hist.c | 23 +++++++++++++++++++++++ tools/perf/util/hist.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index a12e5022fe04..08396a7fea23 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -1347,6 +1347,29 @@ void events_stats__inc(struct events_stats *stats, u32 type) ++stats->nr_events[type]; } +void events_stats__add(struct events_stats *dst, struct events_stats *src) +{ + int i; + +#define ADD(_field) dst->_field += src->_field + + ADD(total_period); + ADD(total_non_filtered_period); + ADD(total_lost); + ADD(total_invalid_chains); + ADD(nr_non_filtered_samples); + ADD(nr_lost_warned); + ADD(nr_unknown_events); + ADD(nr_invalid_chains); + ADD(nr_unknown_id); + ADD(nr_unprocessable_samples); + + for (i = 0; i < PERF_RECORD_HEADER_MAX; i++) + ADD(nr_events[i]); + +#undef ADD +} + void hists__inc_nr_events(struct hists *hists, u32 type) { events_stats__inc(&hists->stats, type); diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 670720ef8acd..725afce73738 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -141,8 +141,14 @@ void hists__inc_stats(struct hists *hists, struct hist_entry *h); void hists__inc_nr_events(struct hists *hists, u32 type); void hists__inc_nr_samples(struct hists *hists, bool filtered); void events_stats__inc(struct events_stats *stats, u32 type); +void events_stats__add(struct events_stats *dst, struct events_stats *src); size_t events_stats__fprintf(struct events_stats *stats, FILE *fp); +static inline void hists__add_stats(struct hists *dst, struct hists *src) +{ + events_stats__add(&dst->stats, &src->stats); +} + size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, int max_cols, float min_pcnt, FILE *fp); size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp); -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/