Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5010097ybi; Tue, 30 Jul 2019 12:06:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJxdBBRNlvIdCN08XTUeP4y/7NqUL3jPCNT9h/rave0HRRIwM4MOAflnEVoYM/BTg65CRx X-Received: by 2002:a63:5a4d:: with SMTP id k13mr107063366pgm.174.1564513615274; Tue, 30 Jul 2019 12:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564513615; cv=none; d=google.com; s=arc-20160816; b=xws4gd146bsVN4WV8Ttp2jG8rRgD02c3eCSItbpMuAtzS6t9lNvZ8DBNQjBWVYv8Y9 HDeU5LUSzNkTMcmE+XCFFpnemM6vI9fg7Sp20AywWTupwHMaioE9Xnvv4bt3/w6OLwxr Z/poY6LFhjzGoToBTAr/vPuxmzR6sVff83HmShYbljieY8M0xzqWLX2mMN/FU7hW6osU z5UiyVjh5VyWCK62Jlk4SlFnAFYbQGSHjjhO01749J9ngQGAG5Y7b2A0EraS4I/Zfjx2 EhIel54t1KVV9c6C8uXBji9lMt6z7gxmMdDOA+P9u+4JuRyemd1dbcxYHg2L1meSJBQN At4g== 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=ivKFStmr6RZz/xDcYVJLBUPOzyDgtvBh8VAWgv4Qdso=; b=o8Uw7T8GSSFI1mFP0QmGk0VxxnnBO4vMbIcoVgft/KXdvr/n8zqQPjKZPHDoiagNB3 eNIpETImc6r7BsYtqWZpO3ReuXHeAx/ZfR0ig4YOo2/RQen79HDzcJRcWVdSaD8GqrBz zFpby8zeY8BPpScvQVdg0FMvOMM56z4j/wahImNsLGZ3Ddr7xAsm7swywH79Pupc76ta otQk1WiZGtwQ4/IuNVtc4Ol3P4KcFpwmrhfNvd3sv2KVHz0aH6LJ+/nbgK8RfYaSCnYl wXFH07Ks/ErU07yeyJlyTAOUqzmk9Y5ORe8WgRaFx8PJ5a4OM19DBOYfPJOuEZhCACjM xs7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019071901 header.b=gJ2MeqS+; 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 r3si31298879pls.176.2019.07.30.12.06.39; Tue, 30 Jul 2019 12:06:55 -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=gJ2MeqS+; 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 S1727621AbfG3TFq (ORCPT + 99 others); Tue, 30 Jul 2019 15:05:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:52311 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfG3TFq (ORCPT ); Tue, 30 Jul 2019 15:05:46 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6UJ5Xpq3339946 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 30 Jul 2019 12:05:33 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6UJ5Xpq3339946 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019071901; t=1564513534; bh=ivKFStmr6RZz/xDcYVJLBUPOzyDgtvBh8VAWgv4Qdso=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=gJ2MeqS+CNcN8yIq6mBGm17wXv7ibjFdxNKgiD3lXZd7xJ71aBvM1SFtqeZ4517gV ApfkMtmBz5aQAiu8WZt1sGR040GYkM+RcnvaWbD6JlKcHxjx3f9lUFZZBw8RCoIxBP 2lt7Tki0+/+u9DpXrcgu3erjTDLgWNu14kReVC2yQfVxHCRuKO0kjV/N6WcA5TKcsf lfCMmd1LhrHaLsFmt9XeGkQ+FTt01EJBvPeMNd8q7loOVP2voWFUDYLdGbcuxdchd/ /C/R/utucHmf6FRmiE4jmo6xvbbrBW1ebtYeGW/5AISlKHDnOEfkSXtDFDVRFv7aMb 02HgpsvQ8YuNg== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6UJ5W3d3339942; Tue, 30 Jul 2019 12:05:32 -0700 Date: Tue, 30 Jul 2019 12:05:32 -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: tglx@linutronix.de, linux-kernel@vger.kernel.org, acme@redhat.com, mingo@kernel.org, mpetlan@redhat.com, jolsa@kernel.org, hpa@zytor.com, alexey.budankov@linux.intel.com, alexander.shishkin@linux.intel.com, peterz@infradead.org, ak@linux.intel.com, namhyung@kernel.org Reply-To: alexey.budankov@linux.intel.com, alexander.shishkin@linux.intel.com, peterz@infradead.org, ak@linux.intel.com, namhyung@kernel.org, mingo@kernel.org, tglx@linutronix.de, acme@redhat.com, linux-kernel@vger.kernel.org, mpetlan@redhat.com, jolsa@kernel.org, hpa@zytor.com In-Reply-To: <20190721112506.12306-78-jolsa@kernel.org> References: <20190721112506.12306-78-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] libperf: Add perf_evlist__enable/disable test Git-Commit-ID: 6bda376ff416cf713773d38b743953a1a9bc0603 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: 6bda376ff416cf713773d38b743953a1a9bc0603 Gitweb: https://git.kernel.org/tip/6bda376ff416cf713773d38b743953a1a9bc0603 Author: Jiri Olsa AuthorDate: Sun, 21 Jul 2019 13:25:04 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 29 Jul 2019 18:34:47 -0300 libperf: Add perf_evlist__enable/disable test Add simple perf_evlist enable/disable test together with evlist counter reading interface. Committer testing: # make -C tools/perf/lib tests make: Entering directory '/home/acme/git/perf/tools/perf/lib' LINK test-cpumap-a LINK test-threadmap-a LINK test-evlist-a LINK test-evsel-a LINK test-cpumap-so LINK test-threadmap-so LINK test-evlist-so LINK test-evsel-so running static: - running test-cpumap.c...OK - running test-threadmap.c...OK - running test-evlist.c...OK - running test-evsel.c...OK running dynamic: - running test-cpumap.c...OK - running test-threadmap.c...OK - running test-evlist.c...OK - running test-evsel.c...OK make: Leaving directory '/home/acme/git/perf/tools/perf/lib' # Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo 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-78-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/lib/tests/test-evlist.c | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tools/perf/lib/tests/test-evlist.c b/tools/perf/lib/tests/test-evlist.c index f24c531afcb6..4e1407f20ffd 100644 --- a/tools/perf/lib/tests/test-evlist.c +++ b/tools/perf/lib/tests/test-evlist.c @@ -111,12 +111,75 @@ static int test_stat_thread(void) return 0; } +static int test_stat_thread_enable(void) +{ + struct perf_counts_values counts = { .val = 0 }; + struct perf_thread_map *threads; + struct perf_evlist *evlist; + struct perf_evsel *evsel; + struct perf_event_attr attr1 = { + .type = PERF_TYPE_SOFTWARE, + .config = PERF_COUNT_SW_CPU_CLOCK, + .disabled = 1, + }; + struct perf_event_attr attr2 = { + .type = PERF_TYPE_SOFTWARE, + .config = PERF_COUNT_SW_TASK_CLOCK, + .disabled = 1, + }; + int err; + + threads = perf_thread_map__new_dummy(); + __T("failed to create threads", threads); + + perf_thread_map__set_pid(threads, 0, 0); + + evlist = perf_evlist__new(); + __T("failed to create evlist", evlist); + + evsel = perf_evsel__new(&attr1); + __T("failed to create evsel1", evsel); + + perf_evlist__add(evlist, evsel); + + evsel = perf_evsel__new(&attr2); + __T("failed to create evsel2", evsel); + + perf_evlist__add(evlist, evsel); + + perf_evlist__set_maps(evlist, NULL, threads); + + err = perf_evlist__open(evlist); + __T("failed to open evsel", err == 0); + + perf_evlist__for_each_evsel(evlist, evsel) { + perf_evsel__read(evsel, 0, 0, &counts); + __T("failed to read value for evsel", counts.val == 0); + } + + perf_evlist__enable(evlist); + + perf_evlist__for_each_evsel(evlist, evsel) { + perf_evsel__read(evsel, 0, 0, &counts); + __T("failed to read value for evsel", counts.val != 0); + } + + perf_evlist__disable(evlist); + + perf_evlist__close(evlist); + perf_evlist__delete(evlist); + + perf_thread_map__put(threads); + return 0; +} + int main(int argc, char **argv) { __T_START; test_stat_cpu(); test_stat_thread(); + test_stat_thread_enable(); __T_OK; return 0;