Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2271962imm; Thu, 7 Jun 2018 08:02:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI32nSdhPofmddteW2/JwgKr/95iWVr1+fRH8cnNX9Dbe8qc28hfrpu8T7ismCQigCrHNzh X-Received: by 2002:a17:902:7685:: with SMTP id m5-v6mr2434565pll.76.1528383721110; Thu, 07 Jun 2018 08:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383721; cv=none; d=google.com; s=arc-20160816; b=s13HLz/neRhQwG6jDosNyXXP7KchgyUJl/vt28dsRR6kCpDZqwEZ6X00TEbk3DrTN/ lVp2ifao1UyZsegE+aj02bhb3jpqK/ktUQEOnZVdZXhzAvpO23kgJOXpUFr4xnAxdrUS XLcBuRXCWZ/dsbjELMMitjW1TmldVsv7xq7yko1LvkvlFCD/fssLco9kS7ccXN5RnldH 7/hn5KwfT/kR97cNRskHoya6cRpc32Diqplh47tpbe+HKsFp1VsaGZnFuZhbWOxeYpkq TbstFRf34O+resXPhg476ItOsS2njcX3jlfGUUgDaqXmYXXW0NEufzg7+eem0VNbEEW9 Cb1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=RMgqaj5YRRCL+fFaWP1EE40qeV+yB8V6nK5HQUFj4hc=; b=EgNoTNdR00oomIoJVtXpq7OdZpMjLZ6a4dcFzldTJO2sD1fzlyp95CWF1FuIDzOTVq k33bjC2D+jEWY+10Eeh1jUL3zQ+/mAspVVPcNJs+4ULT1JGSPgscetBRJF/xqFAWRBfa J1eOPoTw/GW/9KPlhE1O1xXewrVi2xQnnHOv8WENxYa3ameoNyZtDxtvenESdQx2fj66 v/mk7dYZwoOZKOgy/yvVpV1mf5vsy/0/D/klybI9JQd/oe6FcJtOeV6gcWb7Tjj5bTk9 IPgldGXsCC/8gzPNDqrOkvDyeu0mxv7GRGGBgl78St0Iqb19yU/iwgeRoo2XN7j1nshZ BjYg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay3-v6si53570157plb.361.2018.06.07.08.01.45; Thu, 07 Jun 2018 08:02:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935652AbeFGO7X (ORCPT + 99 others); Thu, 7 Jun 2018 10:59:23 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41259 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935646AbeFGO7S (ORCPT ); Thu, 7 Jun 2018 10:59:18 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbv-0005hK-Bx; Thu, 07 Jun 2018 15:09:55 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvaz-0002lL-Ot; Thu, 07 Jun 2018 15:08:57 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David Ahern" , "Namhyung Kim" , "Jiri Olsa" , "Wang Nan" , "Adrian Hunter" , "Arnaldo Carvalho de Melo" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 065/410] perf evlist: Introduce perf_evlist__new_dummy constructor In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Arnaldo Carvalho de Melo commit 5bae0250237f7a5ec4355f9920701de247b8db91 upstream. For case where all we need is an evlist with just an "dummy" evsel, like in some 'perf test' entries. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-q52le0pblm2k3ncvyilelr9z@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Ben Hutchings --- tools/perf/util/evlist.c | 28 ++++++++++++++++++++++++++++ tools/perf/util/evlist.h | 3 +++ 2 files changed, 31 insertions(+) --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -62,6 +62,18 @@ struct perf_evlist *perf_evlist__new_def return evlist; } +struct perf_evlist *perf_evlist__new_dummy(void) +{ + struct perf_evlist *evlist = perf_evlist__new(); + + if (evlist && perf_evlist__add_dummy(evlist)) { + perf_evlist__delete(evlist); + evlist = NULL; + } + + return evlist; +} + /** * perf_evlist__set_id_pos - set the positions of event ids. * @evlist: selected event list @@ -188,6 +200,22 @@ error: return -ENOMEM; } +int perf_evlist__add_dummy(struct perf_evlist *evlist) +{ + struct perf_event_attr attr = { + .type = PERF_TYPE_SOFTWARE, + .config = PERF_COUNT_SW_DUMMY, + .size = sizeof(attr), /* to capture ABI version */ + }; + struct perf_evsel *evsel = perf_evsel__new(&attr); + + if (evsel == NULL) + return -ENOMEM; + + perf_evlist__add(evlist, evsel); + return 0; +} + static int perf_evlist__add_attrs(struct perf_evlist *evlist, struct perf_event_attr *attrs, size_t nr_attrs) { --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -54,6 +54,7 @@ struct perf_evsel_str_handler { struct perf_evlist *perf_evlist__new(void); struct perf_evlist *perf_evlist__new_default(void); +struct perf_evlist *perf_evlist__new_dummy(void); void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus, struct thread_map *threads); void perf_evlist__exit(struct perf_evlist *evlist); @@ -67,6 +68,8 @@ int __perf_evlist__add_default_attrs(str #define perf_evlist__add_default_attrs(evlist, array) \ __perf_evlist__add_default_attrs(evlist, array, ARRAY_SIZE(array)) +int perf_evlist__add_dummy(struct perf_evlist *evlist); + int perf_evlist__add_newtp(struct perf_evlist *evlist, const char *sys, const char *name, void *handler);