linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
To: Chen Yu <yu.c.chen@intel.com>
Cc: acme@kernel.org, peterz@infradead.org, mingo@redhat.com,
	namhyung@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	irogers@google.com, adrian.hunter@intel.com,
	kan.liang@linux.intel.com, acme@redhat.com,
	atrajeev@linux.vnet.ibm.com, kjain@linux.ibm.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Subject: Re: [PATCH] perf sched map: Add command-name option to filter the output map
Date: Fri, 7 Jun 2024 12:52:00 +0530	[thread overview]
Message-ID: <54073c0c-62b1-433a-85cc-06e412af44bf@linux.ibm.com> (raw)
In-Reply-To: <ZmKtlQdwk5uwha06@chenyu5-mobl2>

Hi Chen Yu,

On 07/06/24 12:19, Chen Yu wrote:
> On 2024-04-17 at 20:55:21 +0530, Madadi Vineeth Reddy wrote:
>> 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.
>>
>> 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.
>>
>> 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).
>>
>> 6.8.0
>> ======
>>   *A0                   213864.670142 secs A0 => migration/0:18
>>   *.                    213864.670148 secs .  => swapper:0
>>    .  *B0               213864.670217 secs B0 => migration/1:21
>>    .  *.                213864.670223 secs
>>    .   .  *C0           213864.670247 secs C0 => migration/2:26
>>    .   .  *.            213864.670252 secs
>>
>> 6.8.0 + patch (--command-name = schbench)
>> =============
>>    **  .   ** *A0       213864.671055 secs A0 => schbench:104834
>>   *B0  .   .   A0       213864.671156 secs B0 => schbench:104835
>>   *C0  .   .   A0       213864.671187 secs C0 => schbench:104836
>>   *D0  .   .   A0       213864.671219 secs D0 => schbench:104837
>>   *E0  .   .   A0       213864.671250 secs E0 => schbench:104838
>>    E0  .  *D0  A0
>>
>> 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.
>>
>> Signed-off-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
>> ---
>>  tools/perf/Documentation/perf-sched.txt |  4 ++++
>>  tools/perf/builtin-sched.c              | 17 ++++++++++++++---
>>  2 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/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.
>>  
>> +--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 *sched, struct evsel *evsel,
>>  
>>  	sched->curr_thread[this_cpu.cpu] = thread__get(sched_in);
>>  
>> -	printf("  ");
>> -
>>  	new_shortname = 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 *sched, struct evsel *evsel,
>>  			 */
>>  			tr->shortname[0] = '.';
>>  			tr->shortname[1] = ' ';
>> -		} else {
>> +		} else if (!sched->map.command || !strcmp(thread__comm_str(sched_in),
>> +								sched->map.command)) {
>>
> 
> I've tested on my machine and it looks good. One minor question, can we do
> fuzzy name matching? Say, there are many tasks 'a-taskname-b',
> and we can filter them via
> perf sched map --command-name=taskname

Yes, maybe I will try to find a way to do both fuzzy name matching and exact name matching.
Thanks for taking a look. I will implement it in v2.

Thanks and Regards
Madadi Vineeth Reddy

> 
> thanks,
> Chenyu


      reply	other threads:[~2024-06-07  7:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 15:25 [PATCH] perf sched map: Add command-name option to filter the output map Madadi Vineeth Reddy
2024-05-12 16:10 ` Madadi Vineeth Reddy
2024-06-06 10:21 ` Athira Rajeev
2024-06-07  0:50 ` Namhyung Kim
2024-06-07  5:49   ` Madadi Vineeth Reddy
2024-06-07  6:49 ` Chen Yu
2024-06-07  7:22   ` Madadi Vineeth Reddy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54073c0c-62b1-433a-85cc-06e412af44bf@linux.ibm.com \
    --to=vineethr@linux.ibm.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=kjain@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).