Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp68873imm; Wed, 5 Sep 2018 15:08:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaxN2dT+xh86B5gnFXd3JQJcWpZWk/ZgOD3lrtnggv9n10GDjSeGbzO/p/5tcZmspePFIxb X-Received: by 2002:a62:9bc9:: with SMTP id e70-v6mr42035994pfk.95.1536185320915; Wed, 05 Sep 2018 15:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185320; cv=none; d=google.com; s=arc-20160816; b=DHoNPDe9gZK5WZ9M1VvGYXA4LiNuP51/mWqGj0wSKW1oG4JzOJp91Z9IW9Cg6guIbF Rr7KwE+OLTXWsBaXJFXB/oH3/u3lgC2w05md97QjuPrpkwC2jbLnFMCfoiZp0gznG9fi wi40WW+frxlnY4W4HvJFFR+6ZjaJhigEf9Ncq+ZCYj4jbzxW8rpDs+4ksiu2y58aKHrZ roMTInt125xwozMBniSeKS0ZAsSJM0s15epupok5bEofboubuyHjc8T8AwsRzB3/xhWm zWGS1sqLiY53QgpUGFyYc4hSdOZBqRUAWT8N/y/KC4hQ9RSiWpQaqGNRwpGQbeitFhR/ /U7w== 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:dkim-signature; bh=rNOljyjoRS1iGiOoZaNcBHX8ZEMun8LKi+XwbheoP8c=; b=CDScaDdlMROWVOajBwPPwueg8xxHEqHNCRRTK2JTDk1eLwghl+vw9KIDPKNyFtMA07 xzKsjW0JWD56k3woTu2bNBy5FIB/5Ey/Q6gZ3tD7e0mDnKrNo42yVwnB9lvd+QxP5IgY JwJ+DT1o2EvrOb4j6CXJuEGFSne7PTJyCEc8WWam6lH4y3qBOKDPTOH3meYkjG3rPM8Q WoE2xTwzuFTjIqQJRE97YcqvnF+8yvP7jDrbWU1Lkk0PAwtYA4qsEX7vM40N1ios/7FZ ejp0Sdjd7zKp0dMXyVBMzgbm9kIIaPFuy4cy3FQ86mY58L18narOL+zAi2vZGlwcK3jP 22Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hk3qKBhy; 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=pass (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 k29-v6si3227608pgf.227.2018.09.05.15.08.25; Wed, 05 Sep 2018 15:08:40 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Hk3qKBhy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728654AbeIFCiv (ORCPT + 99 others); Wed, 5 Sep 2018 22:38:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:53438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728642AbeIFCiu (ORCPT ); Wed, 5 Sep 2018 22:38:50 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3CEAE20861; Wed, 5 Sep 2018 22:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185198; bh=hNDmhERvz/8+Q2ADUB8HU7s29rCUaWvFhg5Dl5aF64o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hk3qKBhyIWPJZ3eVhdODwjWHcpr244Vq1hbvclIdCD44jzRTT5vjC71jvz/OFPkrx NrxobDVVAxZ10VAFyReu2iodmz/zaV+Yr7+7s592xBYQ5/jerXysNpdfwW9AmzQUNF No1wfUDwQQXpg+SZx3PwczNhaRxI3I/EqR3o3g7k= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Jiri Olsa , Alexander Shishkin , Andi Kleen , David Ahern , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 39/77] perf stat: Move perf_stat_synthesize_config() to stat.c Date: Wed, 5 Sep 2018 19:04:02 -0300 Message-Id: <20180905220440.20256-40-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180905220440.20256-1-acme@kernel.org> References: <20180905220440.20256-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa So that it can be used globally. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20180830063252.23729-15-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 42 ------------------------------------------ tools/perf/util/stat.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/stat.h | 6 ++++++ 3 files changed, 48 insertions(+), 42 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 1171d4e00276..54768ec15dbc 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -402,48 +402,6 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf workload_exec_errno = info->si_value.sival_int; } -static int perf_stat_synthesize_config(struct perf_stat_config *config, - struct perf_tool *tool, - struct perf_evlist *evlist, - perf_event__handler_t process, - bool attrs) -{ - int err; - - if (attrs) { - err = perf_event__synthesize_attrs(tool, evlist, process); - if (err < 0) { - pr_err("Couldn't synthesize attrs.\n"); - return err; - } - } - - err = perf_event__synthesize_extra_attr(tool, evlist, process, - attrs); - - err = perf_event__synthesize_thread_map2(tool, evlist->threads, - process, NULL); - if (err < 0) { - pr_err("Couldn't synthesize thread map.\n"); - return err; - } - - err = perf_event__synthesize_cpu_map(tool, evlist->cpus, - process, NULL); - if (err < 0) { - pr_err("Couldn't synthesize thread map.\n"); - return err; - } - - err = perf_event__synthesize_stat_config(tool, config, process, NULL); - if (err < 0) { - pr_err("Couldn't synthesize config.\n"); - return err; - } - - return 0; -} - static bool perf_evsel__should_store_id(struct perf_evsel *counter) { return STAT_RECORD || counter->attr.read_format & PERF_FORMAT_ID; diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 3bd24255376a..5d3172bcc4ae 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -488,3 +488,45 @@ int create_perf_stat_counter(struct perf_evsel *evsel, return perf_evsel__open_per_thread(evsel, evsel->threads); } + +int perf_stat_synthesize_config(struct perf_stat_config *config, + struct perf_tool *tool, + struct perf_evlist *evlist, + perf_event__handler_t process, + bool attrs) +{ + int err; + + if (attrs) { + err = perf_event__synthesize_attrs(tool, evlist, process); + if (err < 0) { + pr_err("Couldn't synthesize attrs.\n"); + return err; + } + } + + err = perf_event__synthesize_extra_attr(tool, evlist, process, + attrs); + + err = perf_event__synthesize_thread_map2(tool, evlist->threads, + process, NULL); + if (err < 0) { + pr_err("Couldn't synthesize thread map.\n"); + return err; + } + + err = perf_event__synthesize_cpu_map(tool, evlist->cpus, + process, NULL); + if (err < 0) { + pr_err("Couldn't synthesize thread map.\n"); + return err; + } + + err = perf_event__synthesize_stat_config(tool, config, process, NULL); + if (err < 0) { + pr_err("Couldn't synthesize config.\n"); + return err; + } + + return 0; +} diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 8fb596641545..da6a706daecc 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -7,6 +7,7 @@ #include "xyarray.h" #include "rblist.h" #include "perf.h" +#include "event.h" struct stats { double n, mean, M2; @@ -179,4 +180,9 @@ size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp); int create_perf_stat_counter(struct perf_evsel *evsel, struct perf_stat_config *config, struct target *target); +int perf_stat_synthesize_config(struct perf_stat_config *config, + struct perf_tool *tool, + struct perf_evlist *evlist, + perf_event__handler_t process, + bool attrs); #endif -- 2.14.4