Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp424893lqt; Thu, 6 Jun 2024 07:38:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW6a78DLgbAf5uq9ZDhTZjmAXnIsTu16lCZfGAZSdQwXC1MMTBIrHivBPTKSOod4hcO33EfK7+vP+uPGUi4FCjLc/Rv1y8BLEt9u63p3g== X-Google-Smtp-Source: AGHT+IF6C84oWk5QwWycGieze7rsyD5/8vS8S/1LduFQUpXKTodVmbZV+XLSnmWhcg3iMWKxY8vz X-Received: by 2002:a05:620a:95c:b0:794:e1d2:e4e6 with SMTP id af79cd13be357-7952f1007b9mr456484585a.23.1717684685617; Thu, 06 Jun 2024 07:38:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717684685; cv=pass; d=google.com; s=arc-20160816; b=BOsabW93gjkHDxNA6A2OHk5/hi4mgzO9wFjHcafHdG7s1Spas7OEcd4X9jzjyIf+gy ptqu9J76f0IFy1V5QMTPCAknsTrKwOTyR57/3hoUyREOop9iY4EOO1JwP6k9f9tJMfvt mqSakBn0n9pF/SZIVVsicLZcSGgqa2P2chE/DnHDz7wi+kwIyLh1C6zlHYJcyS4Iw2bZ a+ZVdvaTwUMZAmM+Z4xieBDrVha6foOC1pRnb8s7JWhjaqJBYLKZFWxZRF5MXijwDfIx nI4cQ6U+mgLX/HrfZ93Fu6asBAzzZvHi9Rchz7TVwnHL3KRUacJEN/0qG05GfhCpIT59 UDHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:to:references:message-id:cc:date :in-reply-to:from:subject:dkim-signature; bh=379OOaBf5ORgK9NCimxk70AjpqXj00PeSO2vQUUoS+Y=; fh=unfsi5EDSPyaAS83LyMI6oBnozcAkDg8s/NvdGD13cI=; b=Y3q9MX50vOk3z67JIiCcWyOJLLN2QxZiSwcz0gXhgkUg+xSO5INaxUbWR4mmD0fG9V iVyzveVKLWP5inVnLEHRwUBaY+tHYLceYOmpc7FJiDbn30t5Ez+4mB51xI0ukJgiIMmh ghC6N2ozbR52t3lbSG390cuVGWQP1YwHFi/HM1RSHYJTjVaTFJ/FhdNvcKBG4IU7uhTw guP11IKtegCuqH4vfwVGCP2PWYuqwdEGkI0KQLc/Y7Z0IHrendZlEysc6jMt0Sfd6p5u dpIvA2ss1Ms4gj32jA3lLguNUF7j/tYq8Cqol2jPwqoBAInzswWVemjFKvVq4YgwCeFR ioMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lLROtpF9; arc=pass (i=1 dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.vnet.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-204102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204102-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-79532850f69si152004485a.115.2024.06.06.07.38.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 07:38:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lLROtpF9; arc=pass (i=1 dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.vnet.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-204102-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204102-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CC27A1C24978 for ; Thu, 6 Jun 2024 10:22:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB5DD194C8E; Thu, 6 Jun 2024 10:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lLROtpF9" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41F2D194AE1; Thu, 6 Jun 2024 10:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717669360; cv=none; b=J0/KkKBjSdixHd6QHTlJYVAGu05ABQU895H0QG3ZS9zoDOsiJXzeaJl7eZhK+f9bWghxwKUztOXeQTQuIxn/1Mv8/N6Du5q7lv/Sd8yz859FtV6MA5fmyE3pY/j7TSesgUzBMQeZKWIHpZ8FxU7ud5xjesNy3Ijus/uqqHKeJW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717669360; c=relaxed/simple; bh=zq7TxcJGz51RjT9nfUQibMh8LKejFtAFG5TFcvPutl4=; h=Content-Type:Subject:From:In-Reply-To:Date:Cc:Message-Id: References:To:MIME-Version; b=TofeMTa9O5tghM53rcsqtMqhqRrsNFW7yUuhguTSrKlfPU6vTZM5rrjD8jDlrn3eMQhIJUS+5gjrS0UKjcYbrDkOxl8sC1xXm8ShwIXltquyDgU61/E4autqd4Cw5QeQGXXPgfggEfA4Z1sKgCdxKuoscOS/F0cPSnYGodEIB7I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com; spf=none smtp.mailfrom=linux.vnet.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=lLROtpF9; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.vnet.ibm.com Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 456AKC7I027841; Thu, 6 Jun 2024 10:22:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : content-type : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=379OOaBf5ORgK9NCimxk70AjpqXj00PeSO2vQUUoS+Y=; b=lLROtpF9+jJbdt+vYqnSnYxIKrUncnDT4VkwG8wPBRyOw/GgYklro7aYK8eX1iBCYt3h btD/wrt7v9z1JANYyE0cF8m3Z/nw2G++9iJRMjtasI83GbEj+dCsqDnbk5EBFeFotvq2 SHbTN4Sgy2xoEUvr4t07f1OwsJZ0BQEWCZl8+/EI6uDnPLMlusE5qQnnZj4z35sshfn0 so3OeP9ATLdgYc0r7vBdPoEFU45aViDZaa1DKXc3YDOhH5d+7mE4GTlPE0BEWUroqZHb h2OXgEfiLVA205nFhb0z8BVTw09GkUL+4PQvhc+sIc5h2kkxeFPrfpts30rIyBBx8n80 Dg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ykav002fs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jun 2024 10:22:17 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 456AMHam032160; Thu, 6 Jun 2024 10:22:17 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ykav002fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jun 2024 10:22:17 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45689YXY008479; Thu, 6 Jun 2024 10:22:15 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec125us-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jun 2024 10:22:15 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 456AMAMk43712872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Jun 2024 10:22:12 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED68420125; Thu, 6 Jun 2024 10:22:09 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 899AA20122; Thu, 6 Jun 2024 10:22:07 +0000 (GMT) Received: from smtpclient.apple (unknown [9.109.215.84]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTPS; Thu, 6 Jun 2024 10:22:07 +0000 (GMT) Content-Type: text/plain; charset=utf-8 Subject: Re: [PATCH] perf sched map: Add command-name option to filter the output map From: Athira Rajeev In-Reply-To: <20240417152521.80340-1-vineethr@linux.ibm.com> Date: Thu, 6 Jun 2024 15:51:55 +0530 Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , acme@redhat.com, Kajol Jain , linux-perf-users , LKML Message-Id: <92D17E14-8565-4162-81C6-1ADA18AF48C2@linux.vnet.ibm.com> References: <20240417152521.80340-1-vineethr@linux.ibm.com> To: Madadi Vineeth Reddy , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers X-Mailer: Apple Mail (2.3774.500.171.1.1) X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 1CzpFPHbac3LN2eoW7yRzTdwR4b0QcJC X-Proofpoint-ORIG-GUID: wr1FQ0oHqnoIC5-SfUSB5e3ZuuZzg03O Content-Transfer-Encoding: quoted-printable X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-06_01,2024-06-06_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 malwarescore=0 spamscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406060076 > On 17 Apr 2024, at 8:55=E2=80=AFPM, Madadi Vineeth Reddy wrote: >=20 > By default, perf sched map prints sched-in events for all the tasks > which may not be required all the time as it prints lot of symbols > and rows to the terminal. >=20 > With --command-name option, one could specify the specific command > for which the map has to be shown. This would help in analyzing the > CPU usage patterns easier for that specific command. Since multiple > PID's might have the same command name, using command-name filter > would be more useful for debugging. >=20 > For other tasks, instead of printing the symbol, ** is printed and > the same . is used to represent idle. ** is used instead of symbol > for other tasks because it helps in clear visualization of command > of interest and secondly the symbol itself doesn't mean anything > because the sched-in of that symbol will not be printed(first sched-in > contains pid and the corresponding symbol). >=20 > 6.8.0 > =3D=3D=3D=3D=3D=3D > *A0 213864.670142 secs A0 =3D> migration/0:18 > *. 213864.670148 secs . =3D> swapper:0 > . *B0 213864.670217 secs B0 =3D> migration/1:21 > . *. 213864.670223 secs > . . *C0 213864.670247 secs C0 =3D> migration/2:26 > . . *. 213864.670252 secs >=20 > 6.8.0 + patch (--command-name =3D schbench) > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ** . ** *A0 213864.671055 secs A0 =3D> schbench:104834 > *B0 . . A0 213864.671156 secs B0 =3D> schbench:104835 > *C0 . . A0 213864.671187 secs C0 =3D> schbench:104836 > *D0 . . A0 213864.671219 secs D0 =3D> schbench:104837 > *E0 . . A0 213864.671250 secs E0 =3D> schbench:104838 > E0 . *D0 A0 >=20 > This helps in visualizing how a benchmark like schbench is spread over > the available cpus while also knowing which cpus are idle(.) and which > are not(**). This will be more useful as number of CPUs increase. >=20 > Signed-off-by: Madadi Vineeth Reddy Tested the patch and looks good to me Command to record: perf sched record sleep 5 With the patch, tested below and checked it filters and provides results fo= r =E2=80=9Csleep=E2=80=9D and =E2=80=9Cperf=E2=80=9D perf sched map --command-name sleep perf sched map --command-name perf Reviewed-and-tested-by: Athira Rajeev > Thanks Athira > --- > tools/perf/Documentation/perf-sched.txt | 4 ++++ > tools/perf/builtin-sched.c | 17 ++++++++++++++--- > 2 files changed, 18 insertions(+), 3 deletions(-) >=20 > diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documen= tation/perf-sched.txt > index 5fbe42bd599b..b04a37560935 100644 > --- a/tools/perf/Documentation/perf-sched.txt > +++ b/tools/perf/Documentation/perf-sched.txt > @@ -94,6 +94,10 @@ OPTIONS for 'perf sched map' > --color-pids:: > Highlight the given pids. >=20 > +--command-name:: > + Map output only for the given command name. > + (** indicates other tasks while . is idle). > + > OPTIONS for 'perf sched timehist' > --------------------------------- > -k:: > diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c > index 0fce7d8986c0..e60836da53e5 100644 > --- a/tools/perf/builtin-sched.c > +++ b/tools/perf/builtin-sched.c > @@ -156,6 +156,7 @@ struct perf_sched_map { > const char *color_pids_str; > struct perf_cpu_map *color_cpus; > const char *color_cpus_str; > + const char *command; > struct perf_cpu_map *cpus; > const char *cpus_str; > }; > @@ -1594,8 +1595,6 @@ static int map_switch_event(struct perf_sched *sche= d, struct evsel *evsel, >=20 > sched->curr_thread[this_cpu.cpu] =3D thread__get(sched_in); >=20 > - printf(" "); > - > new_shortname =3D 0; > if (!tr->shortname[0]) { > if (!strcmp(thread__comm_str(sched_in), "swapper")) { > @@ -1605,7 +1604,8 @@ static int map_switch_event(struct perf_sched *sche= d, struct evsel *evsel, > */ > tr->shortname[0] =3D '.'; > tr->shortname[1] =3D ' '; > - } else { > + } else if (!sched->map.command || !strcmp(thread__comm_str(sched_in), > + sched->map.command)) { > tr->shortname[0] =3D sched->next_shortname1; > tr->shortname[1] =3D sched->next_shortname2; >=20 > @@ -1618,10 +1618,18 @@ static int map_switch_event(struct perf_sched *sc= hed, struct evsel *evsel, > else > sched->next_shortname2 =3D '0'; > } > + } else { > + tr->shortname[0] =3D '*'; > + tr->shortname[1] =3D '*'; > } > new_shortname =3D 1; > } >=20 > + if (sched->map.command && strcmp(thread__comm_str(sched_in), sched->map= .command)) > + goto skip; > + > + printf(" "); > + > for (i =3D 0; i < cpus_nr; i++) { > struct perf_cpu cpu =3D { > .cpu =3D sched->map.comp ? sched->map.comp_cpus[i].cpu : i, > @@ -1678,6 +1686,7 @@ static int map_switch_event(struct perf_sched *sche= d, struct evsel *evsel, > out: > color_fprintf(stdout, color, "\n"); >=20 > +skip: > thread__put(sched_in); >=20 > return 0; > @@ -3560,6 +3569,8 @@ int cmd_sched(int argc, const char **argv) > "highlight given CPUs in map"), > OPT_STRING(0, "cpus", &sched.map.cpus_str, "cpus", > "display given CPUs in map"), > + OPT_STRING(0, "command-name", &sched.map.command, "command", > + "map output only for the given command name"), > OPT_PARENT(sched_options) > }; > const struct option timehist_options[] =3D { > --=20 > 2.39.1 >=20 >=20