Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5123160ybi; Tue, 30 Jul 2019 14:16:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQQgvdP+rfH1EfpD5HJLIZKUJRfFSFWo47zSlgf0EubUfDfj3ZwfpYwodZpODunTtzpaf0 X-Received: by 2002:a17:90a:26ef:: with SMTP id m102mr117298887pje.50.1564521370447; Tue, 30 Jul 2019 14:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564521370; cv=none; d=google.com; s=arc-20160816; b=HRu7gdcrYlfb1rZSJb6aa9YLz5hKzPk1SwDtmrztYGoeqeIzzWNTnGbTObEsXBvxo+ fpkxVJlHNFT2YvnPsKHVTtx0qtVNeDqMc30pIrH9wyg5CugO2JEzTubUdmSgSK+v1is+ iOTIq+k8jTke74vhHsJwCeM5HfIMdBqT9LqJtPiaPfN2U4BPEYi2p+GiW6mXNRv3IdWp WmEccwBJxBmmCVvBuJNvaZ2yjxbDiVLxxr0YuykNeaPS15tQhslsREYwJBJDP+FiHjKy 8ht6H+74LgIqaqfbWJTKu/lMaUFuGl0K0mRt2/DjNrag4uJe1RmIzWzKcXspKSObNyE7 EpAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=0rdS9t2ruUTTjNMLZBRqXP40Hz26l8NmxiTNHfzXIgI=; b=n29FgWXVePCDzNrUBYwVB4BWS641buAuAQhRnoyu4I7KHFVxvr0s01RC5GGCmlHnTu 3vnAXSy/3Qbh8tlPz66sPg6LEUj4Q65fa2NeCDi4zvzoczDEnoUmFpqIUrcyiKOT4/IT dynQ4u4WWm/5lQIU7+SQm2h4jpXWnnLmnFdw4HZ1Az/j+XxOV+ajQu2irQTUNQ2MTz1I hMJXtCkG/XnaGY3oCJMvQXosX1WFmx5It9jCIoGgOsgHzoXoNGC3H5WI5uOstzB4Ppwy 9VqabN1K6+TeQi/iGfvZsbvH1+1amUgSvOpOeIUeNovfjSKKeMQklrn135Hd1lH8R4G6 g0rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019071901 header.b=GCPvlON+; 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=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i21si19818879pgj.37.2019.07.30.14.15.51; Tue, 30 Jul 2019 14:16:10 -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=@zytor.com header.s=2019071901 header.b=GCPvlON+; 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=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730111AbfG3Sl7 (ORCPT + 99 others); Tue, 30 Jul 2019 14:41:59 -0400 Received: from terminus.zytor.com ([198.137.202.136]:34373 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbfG3Sl7 (ORCPT ); Tue, 30 Jul 2019 14:41:59 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6UIflnr3332410 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 30 Jul 2019 11:41:48 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6UIflnr3332410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019071901; t=1564512108; bh=0rdS9t2ruUTTjNMLZBRqXP40Hz26l8NmxiTNHfzXIgI=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=GCPvlON+FxqdoEOXTG4dsbkdtWLBauS2AOQCUxPuuCvYH84X6tS56eO4tSJYWQF9U kkwElHBkkwkIyp8PwNRFxyZ0ads7dhB7gmAX5DkyCcbW85S3jGbFRVAsK/Q7lGQPNG NNFDDHg9H8/DBmYfNFldzvfOJN7+ArB5lMTQkgjrws9XIjhHOaJP2jo7vtYGqMxvHI bpOaEQpy6mUtBYnHjt53wnBNru6UTJNOdD//b5L/yMkB7WIAMG2MnFk6N3VKbwZnbv vY7nLYxZ2cJ1HZwCX24F4NIUxtybeC+pdHDZbrxvyohu4V5IfXRSIzx2whOhClVPjP xMSKEA5iYWsQA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6UIflnY3332407; Tue, 30 Jul 2019 11:41:47 -0700 Date: Tue, 30 Jul 2019 11:41:47 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jiri Olsa Message-ID: Cc: alexander.shishkin@linux.intel.com, mingo@kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, hpa@zytor.com, alexey.budankov@linux.intel.com, ak@linux.intel.com, namhyung@kernel.org, acme@redhat.com, jolsa@kernel.org, mpetlan@redhat.com, tglx@linutronix.de Reply-To: acme@redhat.com, namhyung@kernel.org, jolsa@kernel.org, mpetlan@redhat.com, tglx@linutronix.de, mingo@kernel.org, alexander.shishkin@linux.intel.com, ak@linux.intel.com, alexey.budankov@linux.intel.com, hpa@zytor.com, peterz@infradead.org, linux-kernel@vger.kernel.org In-Reply-To: <20190721112506.12306-47-jolsa@kernel.org> References: <20190721112506.12306-47-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] libperf: Add perf_evsel__new() function Git-Commit-ID: 63bd5dfa69658c459d08a6ee6bfebbd4a91cf24d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 63bd5dfa69658c459d08a6ee6bfebbd4a91cf24d Gitweb: https://git.kernel.org/tip/63bd5dfa69658c459d08a6ee6bfebbd4a91cf24d Author: Jiri Olsa AuthorDate: Sun, 21 Jul 2019 13:24:33 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 29 Jul 2019 18:34:45 -0300 libperf: Add perf_evsel__new() function Add a perf_evsel__new() function to create and init a perf_evsel struct dynamicaly. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Andi Kleen Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190721112506.12306-47-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/evsel.c | 11 +++++++++++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 13 insertions(+) diff --git a/tools/perf/lib/evsel.c b/tools/perf/lib/evsel.c index 17cba35becc7..8e91738c5c38 100644 --- a/tools/perf/lib/evsel.c +++ b/tools/perf/lib/evsel.c @@ -2,9 +2,20 @@ #include #include #include +#include void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr) { INIT_LIST_HEAD(&evsel->node); evsel->attr = *attr; } + +struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr) +{ + struct perf_evsel *evsel = zalloc(sizeof(*evsel)); + + if (evsel != NULL) + perf_evsel__init(evsel, attr); + + return evsel; +} diff --git a/tools/perf/lib/include/perf/evsel.h b/tools/perf/lib/include/perf/evsel.h index 295583b89f46..21b66fc1937f 100644 --- a/tools/perf/lib/include/perf/evsel.h +++ b/tools/perf/lib/include/perf/evsel.h @@ -9,5 +9,6 @@ struct perf_event_attr; LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr); +LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr); #endif /* __LIBPERF_EVSEL_H */ diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index 5e685d6c7a95..e3eac9b60726 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map @@ -11,6 +11,7 @@ LIBPERF_0.0.1 { perf_thread_map__comm; perf_thread_map__get; perf_thread_map__put; + perf_evsel__new; perf_evsel__init; perf_evlist__new; perf_evlist__init;