Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp979081ybl; Fri, 10 Jan 2020 09:55:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwun+ACAUkVeu0Ax5Kmm10BVkISI5zwN5BQa1Ua4w+vYPye6J9oaDJyaPN0JELbKatef13W X-Received: by 2002:a05:6830:1755:: with SMTP id 21mr3754492otz.323.1578678940034; Fri, 10 Jan 2020 09:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578678940; cv=none; d=google.com; s=arc-20160816; b=nNsx5tgAVnFSxpWyzhKXvu7DXieHRYI/HPXsbyzwTk01LsvW4H7ylIf+6loqogdr2r CHbmglhb2Dlw4vwFXDgBiiyT2kpRQqGX1nN8jPOgY8tEd6BmQkqZsweLpDqrltE25bFK 0+So2YRX/ZstDZiE0KiHy4WpmfWkYqLw6xvq2Gq91BiNc2bUCNO1M2aUm3HU3VlzVOpe Whyuxh3obkBVuWlhuP7TvpIeD4dC7CvezBzy4X8UwqUz4n+bxjwh2i55pNkJwVR2T7SN PPbVqRKZN0VTP7HaGo6tBhLLtldzxm09Z9pcWyQrzUsLEdyBnJXRYtNg1mzc44hiwsIi +t6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=hQ7/G8PMkrxkTLaJhDmICU8RfTdKUab+3JlQSyEBqks=; b=wAOnMFC9jFaBwpH8AdyrwyZv1vOuCcE7f350O/MpSRDn938vEozYUbWE9UCM5RQiii 6bIKcz5XnnEWkRwNi7utScxWpABrtcCVWzxoCt1ld8axbAwDpz9SofjGyjM6J8BZWmHf RsDi6yPP0CFYZv5aOLmkOHVvTY/E2cEWUzN3ctrM232NieyRbbc9Nd9mPJHO7K2Q7qJ1 BZQvY+Dn/IEzY2B6wl51V+yLLhtIE/jUxRDpRKgonX+KXp6kyuasOK5HfFmJpjOXH+kR B3UMqtzA0ljvjG7FKu7O2iEPh8uygJLmi7tXalBfRFy6farRMbtKGh0ZWUxn5faSG7uv 0C3Q== 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 c22si1984218oth.167.2020.01.10.09.55.28; Fri, 10 Jan 2020 09:55:40 -0800 (PST) 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 S1728996AbgAJRyL (ORCPT + 99 others); Fri, 10 Jan 2020 12:54:11 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:59193 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728754AbgAJRxa (ORCPT ); Fri, 10 Jan 2020 12:53:30 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ipyTN-0001m9-8v; Fri, 10 Jan 2020 18:53:25 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id EC8971C2D5E; Fri, 10 Jan 2020 18:53:17 +0100 (CET) Date: Fri, 10 Jan 2020 17:53:17 -0000 From: "tip-bot2 for David Ahern" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf sched timehist: Add support for filtering on CPU Cc: David Ahern , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , x86 , LKML In-Reply-To: <20191204173925.66976-1-dsahern@kernel.org> References: <20191204173925.66976-1-dsahern@kernel.org> MIME-Version: 1.0 Message-ID: <157867879783.30329.14601250233681313833.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: c30d630d1bcfad8d2f70ff0cbb2a86d5a43bc152 Gitweb: https://git.kernel.org/tip/c30d630d1bcfad8d2f70ff0cbb2a86d5a43bc152 Author: David Ahern AuthorDate: Wed, 04 Dec 2019 10:39:25 -07:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Mon, 06 Jan 2020 11:46:09 -03:00 perf sched timehist: Add support for filtering on CPU Allow user to limit output to one or more CPUs. Really helpful on systems with a large number of cpus. Committer testing: # perf sched record -a sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 1.765 MB perf.data (1412 samples) ] [root@quaco ~]# perf sched timehist | head Samples do not have callchains. time cpu task name wait time sch delay run time [tid/pid] (msec) (msec) (msec) --------------- ------ ------------------------------ --------- --------- --------- 66307.802686 [0000] perf[13086] 0.000 0.000 0.000 66307.802700 [0000] migration/0[12] 0.000 0.001 0.014 66307.802766 [0001] perf[13086] 0.000 0.000 0.000 66307.802774 [0001] migration/1[15] 0.000 0.001 0.007 66307.802841 [0002] perf[13086] 0.000 0.000 0.000 66307.802849 [0002] migration/2[20] 0.000 0.001 0.008 66307.802913 [0003] perf[13086] 0.000 0.000 0.000 # # perf sched timehist --cpu 2 | head Samples do not have callchains. time cpu task name wait time sch delay run time [tid/pid] (msec) (msec) (msec) --------------- ------ ------------------------------ --------- --------- --------- 66307.802841 [0002] perf[13086] 0.000 0.000 0.000 66307.802849 [0002] migration/2[20] 0.000 0.001 0.008 66307.964485 [0002] 0.000 0.000 161.635 66307.964811 [0002] CPU 0/KVM[3589/3561] 0.000 0.056 0.325 66307.965477 [0002] 0.325 0.000 0.666 66307.965553 [0002] CPU 0/KVM[3589/3561] 0.666 0.024 0.076 66307.966456 [0002] 0.076 0.000 0.903 # Signed-off-by: David Ahern Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lore.kernel.org/lkml/20191204173925.66976-1-dsahern@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-sched.txt | 4 ++++ tools/perf/builtin-sched.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt index 63f938b..5fbe42b 100644 --- a/tools/perf/Documentation/perf-sched.txt +++ b/tools/perf/Documentation/perf-sched.txt @@ -110,6 +110,10 @@ OPTIONS for 'perf sched timehist' --max-stack:: Maximum number of functions to display in backtrace, default 5. +-C=:: +--cpu=:: + Only show events for the given CPU(s) (comma separated list). + -p=:: --pid=:: Only show events for given process ID (comma separated list). diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 8a12d71..82fcc2c 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -51,6 +51,9 @@ #define SYM_LEN 129 #define MAX_PID 1024000 +static const char *cpu_list; +static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); + struct sched_atom; struct task_desc { @@ -2008,6 +2011,9 @@ static void timehist_print_sample(struct perf_sched *sched, char nstr[30]; u64 wait_time; + if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) + return; + timestamp__scnprintf_usec(t, tstr, sizeof(tstr)); printf("%15s [%04d] ", tstr, sample->cpu); @@ -2994,6 +3000,12 @@ static int perf_sched__timehist(struct perf_sched *sched) if (IS_ERR(session)) return PTR_ERR(session); + if (cpu_list) { + err = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap); + if (err < 0) + goto out; + } + evlist = session->evlist; symbol__init(&session->header.env); @@ -3429,6 +3441,7 @@ int cmd_sched(int argc, const char **argv) "analyze events only for given process id(s)"), OPT_STRING('t', "tid", &symbol_conf.tid_list_str, "tid[,tid...]", "analyze events only for given thread id(s)"), + OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"), OPT_PARENT(sched_options) };