From nobody Wed Dec 17 23:51:09 2025 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 E06DC4963A; Wed, 26 Jun 2024 09:17:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719393425; cv=none; b=ZdsIIWUktCTGH1oPcqudegg9ZV2EmDWRt7yBWt+JNPliHsB9CvA+9JJNzom83iUfq2OG+59zBrI0yqaygm0ho1tQhK2g5s1hX/idTyxmEH3H4/qX8pp9FQpfjKOARd8m9EH2UPPhOp/oOhzXvKBfWT9SdF4YOJPsZ4VjCG1xbw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719393425; c=relaxed/simple; bh=gl9FaoT4Nsc1NRNRJjSq5pz2WSIoaFFjk+4+0sLToCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i3ZlnFNATTrv3I/Z+q0ZFMhPWMaTXwVt2b77JHpTb6bZDmo9r7aoWRQbokoRXb+ZL9CzrxH/aGa/9zwwGOBQLNPHHBVNQu8g5oybgmsaIsd52nT86o+VSgkAQu0TzKOloolo2yWRrxOZXH4RWhDeKZibQw2h0Nr98OhCc5MUeIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=VOdiWjbG; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="VOdiWjbG" Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45Q8tZ9D032010; Wed, 26 Jun 2024 09:16:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=uhxlkrdHmac9i w8CkskN0WjrihHxrT5woBhPdszGwYs=; b=VOdiWjbGR/2iv8O/UF7Y2vyXLlWst 1dcYi5/MLxkgGSZB0GxcRLykJlPfkq1V1S8xvhc8DuTKWrz3GMdEQb10dLURbDbq +xpkqQ2pxqSPSgph5iY21GMo04PZy9l45d9nvgo9cOVpbOf/ip7gpOLghjEeDepX Ez73LI/QfwjgSMjFFZG7Sq35EYl5LsIDfT/RfAGwcQRUJ6zjx3YkJFwRWV+TvI3Q fP3lV42WpiItpPHKdTkq7G3fiy66ksLxmR3st9xm5aAJN2w9/XmKdqS/TMavGdgS WxMaEYV47s03UWLOposodDtS4+K3EN4tkDwOfAUEubvK1a/T7gNCSDTgA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 400f2k05tq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:16:48 +0000 (GMT) Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45Q9G30A001160; Wed, 26 Jun 2024 09:16:48 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 400f2k05tm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:16:48 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45Q7AUbJ020074; Wed, 26 Jun 2024 09:16:47 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxb5mk3rh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:16:47 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45Q9GhK655050582 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jun 2024 09:16:45 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7117920063; Wed, 26 Jun 2024 09:16:43 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B88BB20040; Wed, 26 Jun 2024 09:16:36 +0000 (GMT) Received: from li-fdfde5cc-27d0-11b2-a85c-e224154bf6d4.ibm.com.com (unknown [9.43.51.102]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 26 Jun 2024 09:16:36 +0000 (GMT) From: Madadi Vineeth Reddy To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Athira Rajeev , Chen Yu Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , acme@redhat.com, Fernand Sieber , linux-perf-users , LKML , Madadi Vineeth Reddy Subject: [PATCH v5 1/3] perf sched map: Add task-name option to filter the output map Date: Wed, 26 Jun 2024 14:45:48 +0530 Message-ID: <20240626091550.46707-2-vineethr@linux.ibm.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240626091550.46707-1-vineethr@linux.ibm.com> References: <20240626091550.46707-1-vineethr@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: l9V10FxlbzIIeFP47IPC9qVO2tdqDVvZ X-Proofpoint-ORIG-GUID: 63fw5X6NyJndQOSjy1C7iVhQ7Dgctcwq 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-26_03,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 suspectscore=0 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406260067 Content-Type: text/plain; charset="utf-8" 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 --task-name option, one could specify the specific task name for which the map has to be shown. This would help in analyzing the CPU usage patterns easier for that specific task. Since multiple PID's might have the same task name, using task-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 task 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). When using the --task-name option, the sched-out time is represented by a '*-'. Since not all task sched-in events are printed, the sched-out time of the relevant task might be lost. This representation ensures that the sched-out time of the interested task is not overlooked. 6.10.0-rc1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D *A0 131040.639793 secs A0 =3D> migration/0:19 *. 131040.639801 secs . =3D> swapper:0 . *B0 131040.639830 secs B0 =3D> migration/1:24 . *. 131040.639836 secs . . *C0 131040.640108 secs C0 =3D> migration/2:30 . . *. 131040.640163 secs . . . *D0 131040.640386 secs D0 =3D> migration/3:36 . . . *. 131040.640395 secs 6.10.0-rc1 + patch (--task-name wdavdaemon) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D . *A0 . . . . - . 131040.641346 secs A0 =3D> wdavdaemon:62509 . A0 *B0 . . . - . 131040.641378 secs B0 =3D> wdavdaemon:62274 - *- - - - - - - 131040.641379 secs *C0 . B0 . . . . . 131040.641572 secs C0 =3D> wdavdaemon:62283 C0 . B0 . *D0 . . . 131040.641572 secs D0 =3D> wdavdaemon:62277 C0 . B0 . D0 . *E0 . 131040.641578 secs E0 =3D> wdavdaemon:62270 *- - - - - - - - 131040.641581 secs - - - - - - *- - 131040.641583 secs Reviewed-and-tested-by: Athira Rajeev Signed-off-by: Madadi Vineeth Reddy --- tools/perf/Documentation/perf-sched.txt | 6 + tools/perf/builtin-sched.c | 161 ++++++++++++++++++------ 2 files changed, 131 insertions(+), 36 deletions(-) diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documenta= tion/perf-sched.txt index 74c812f7a4a4..3255e5b8e74b 100644 --- a/tools/perf/Documentation/perf-sched.txt +++ b/tools/perf/Documentation/perf-sched.txt @@ -130,6 +130,12 @@ OPTIONS for 'perf sched map' --color-pids:: Highlight the given pids. =20 +--task-name :: + Map output only for the given task name. The sched-out + time is printed and is represented by '*-' for the given + task 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 aa59f763ca46..57f166662d54 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 *task_name; struct perf_cpu_map *cpus; const char *cpus_str; }; @@ -177,6 +178,7 @@ struct perf_sched { struct perf_cpu max_cpu; u32 *curr_pid; struct thread **curr_thread; + struct thread **curr_out_thread; char next_shortname1; char next_shortname2; unsigned int replay_repeat; @@ -1538,23 +1540,89 @@ map__findnew_thread(struct perf_sched *sched, struc= t machine *machine, pid_t pid return thread; } =20 +static bool sched_match_task(const char *comm_str, const char *commands) +{ + char *commands_copy =3D NULL; + char *token =3D NULL; + bool match_found =3D false; + + commands_copy =3D strdup(commands); + if (commands_copy =3D=3D NULL) + return NULL; + + token =3D strtok(commands_copy, ","); + + while (token !=3D NULL && !match_found) { + match_found =3D !strcmp(comm_str, token); + token =3D strtok(NULL, ","); + } + + free(commands_copy); + return match_found; +} + +static void print_sched_map(struct perf_sched *sched, struct perf_cpu this= _cpu, int cpus_nr, + const char *color, bool sched_out) +{ + for (int i =3D 0; i < cpus_nr; i++) { + struct perf_cpu cpu =3D { + .cpu =3D sched->map.comp ? sched->map.comp_cpus[i].cpu : i, + }; + struct thread *curr_thread =3D sched->curr_thread[cpu.cpu]; + struct thread *curr_out_thread =3D sched->curr_out_thread[cpu.cpu]; + struct thread_runtime *curr_tr; + const char *pid_color =3D color; + const char *cpu_color =3D color; + char symbol =3D ' '; + struct thread *thread_to_check =3D sched_out ? curr_out_thread : curr_th= read; + + if (thread_to_check && thread__has_color(thread_to_check)) + pid_color =3D COLOR_PIDS; + + if (sched->map.color_cpus && perf_cpu_map__has(sched->map.color_cpus, cp= u)) + cpu_color =3D COLOR_CPUS; + + if (cpu.cpu =3D=3D this_cpu.cpu) + symbol =3D '*'; + + color_fprintf(stdout, cpu.cpu !=3D this_cpu.cpu ? color : cpu_color, "%c= ", symbol); + + thread_to_check =3D sched_out ? sched->curr_out_thread[cpu.cpu] : + sched->curr_thread[cpu.cpu]; + + if (thread_to_check) { + curr_tr =3D thread__get_runtime(thread_to_check); + if (curr_tr =3D=3D NULL) + return; + + if (sched_out) + color_fprintf(stdout, color, "- "); + else + color_fprintf(stdout, pid_color, "%2s ", curr_tr->shortname); + } else + color_fprintf(stdout, color, " "); + } +} + static int map_switch_event(struct perf_sched *sched, struct evsel *evsel, struct perf_sample *sample, struct machine *machine) { const u32 next_pid =3D evsel__intval(evsel, sample, "next_pid"); - struct thread *sched_in; + const u32 prev_pid =3D evsel__intval(evsel, sample, "prev_pid"); + struct thread *sched_in, *sched_out; struct thread_runtime *tr; int new_shortname; u64 timestamp0, timestamp =3D sample->time; s64 delta; - int i; struct perf_cpu this_cpu =3D { .cpu =3D sample->cpu, }; int cpus_nr; + int proceed; bool new_cpu =3D false; const char *color =3D PERF_COLOR_NORMAL; char stimestamp[32]; + const char *str; =20 BUG_ON(this_cpu.cpu >=3D MAX_CPUS || this_cpu.cpu < 0); =20 @@ -1583,7 +1651,8 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, } =20 sched_in =3D map__findnew_thread(sched, machine, -1, next_pid); - if (sched_in =3D=3D NULL) + sched_out =3D map__findnew_thread(sched, machine, -1, prev_pid); + if (sched_in =3D=3D NULL || sched_out =3D=3D NULL) return -1; =20 tr =3D thread__get_runtime(sched_in); @@ -1593,6 +1662,7 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, } =20 sched->curr_thread[this_cpu.cpu] =3D thread__get(sched_in); + sched->curr_out_thread[this_cpu.cpu] =3D thread__get(sched_out); =20 new_shortname =3D 0; if (!tr->shortname[0]) { @@ -1603,7 +1673,8 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, */ tr->shortname[0] =3D '.'; tr->shortname[1] =3D ' '; - } else { + } else if (!sched->map.task_name || sched_match_task(thread__comm_str(sc= hed_in), + sched->map.task_name)) { tr->shortname[0] =3D sched->next_shortname1; tr->shortname[1] =3D sched->next_shortname2; =20 @@ -1616,6 +1687,9 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, else sched->next_shortname2 =3D '0'; } + } else { + tr->shortname[0] =3D '-'; + tr->shortname[1] =3D ' '; } new_shortname =3D 1; } @@ -1623,42 +1697,28 @@ static int map_switch_event(struct perf_sched *sche= d, struct evsel *evsel, if (sched->map.cpus && !perf_cpu_map__has(sched->map.cpus, this_cpu)) goto out; =20 - 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, - }; - struct thread *curr_thread =3D sched->curr_thread[cpu.cpu]; - struct thread_runtime *curr_tr; - const char *pid_color =3D color; - const char *cpu_color =3D color; - - if (curr_thread && thread__has_color(curr_thread)) - pid_color =3D COLOR_PIDS; - - if (sched->map.cpus && !perf_cpu_map__has(sched->map.cpus, cpu)) - continue; - - if (sched->map.color_cpus && perf_cpu_map__has(sched->map.color_cpus, cp= u)) - cpu_color =3D COLOR_CPUS; - - if (cpu.cpu !=3D this_cpu.cpu) - color_fprintf(stdout, color, " "); + proceed =3D 0; + str =3D thread__comm_str(sched_in); + /* + * Check which of sched_in and sched_out matches the passed --task-name + * arguments and call the corresponding print_sched_map. + */ + if (sched->map.task_name && !sched_match_task(str, sched->map.task_name))= { + if (!sched_match_task(thread__comm_str(sched_out), sched->map.task_name)) + goto out; else - color_fprintf(stdout, cpu_color, "*"); + goto sched_out; =20 - if (sched->curr_thread[cpu.cpu]) { - curr_tr =3D thread__get_runtime(sched->curr_thread[cpu.cpu]); - if (curr_tr =3D=3D NULL) { - thread__put(sched_in); - return -1; - } - color_fprintf(stdout, pid_color, "%2s ", curr_tr->shortname); - } else - color_fprintf(stdout, color, " "); + } else { + str =3D thread__comm_str(sched_out); + if (!(sched->map.task_name && !sched_match_task(str, sched->map.task_nam= e))) + proceed =3D 1; } =20 + printf(" "); + + print_sched_map(sched, this_cpu, cpus_nr, color, false); + timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp)); color_fprintf(stdout, color, " %12s secs ", stimestamp); if (new_shortname || tr->comm_changed || (verbose > 0 && thread__tid(sche= d_in))) { @@ -1675,9 +1735,32 @@ static int map_switch_event(struct perf_sched *sched= , struct evsel *evsel, if (sched->map.comp && new_cpu) color_fprintf(stdout, color, " (CPU %d)", this_cpu); =20 + if (proceed !=3D 1) { + color_fprintf(stdout, color, "\n"); + goto out; + } + +sched_out: + if (sched->map.task_name) { + tr =3D thread__get_runtime(sched->curr_out_thread[this_cpu.cpu]); + if (strcmp(tr->shortname, "") =3D=3D 0) + goto out; + + if (proceed =3D=3D 1) + color_fprintf(stdout, color, "\n"); + + printf(" "); + print_sched_map(sched, this_cpu, cpus_nr, color, true); + timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp)); + color_fprintf(stdout, color, " %12s secs ", stimestamp); + } + color_fprintf(stdout, color, "\n"); =20 out: + if (sched->map.task_name) + thread__put(sched_out); + thread__put(sched_in); =20 return 0; @@ -3310,6 +3393,10 @@ static int perf_sched__map(struct perf_sched *sched) if (!sched->curr_thread) return rc; =20 + sched->curr_out_thread =3D calloc(MAX_CPUS, sizeof(*(sched->curr_out_thre= ad))); + if (!sched->curr_out_thread) + return rc; + if (setup_cpus_switch_event(sched)) goto out_free_curr_thread; =20 @@ -3563,6 +3650,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, "task-name", &sched.map.task_name, "task", + "map output only for the given task name"), OPT_PARENT(sched_options) }; const struct option timehist_options[] =3D { --=20 2.43.2 From nobody Wed Dec 17 23:51:09 2025 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 1C51F16CD1F; Wed, 26 Jun 2024 09:17:07 +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=1719393430; cv=none; b=Wl6fF3kiAuq14gAi5I8sVCGrhxpadb5M3J0EDxIlP8KruKJhtbPEaf3Cnoxnc0KQv8lWDeLr6Uodj9ZSgye61MMprLN4kjcYC8O826E24PW0aHLiJA+qZSarvrRsddfG14rzzGvrfOWR470GbDpqfsv8YUrAfkCds2/VL3gmGQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719393430; c=relaxed/simple; bh=pxU8wxwEchZg4usm9UkgJxhSfItDyauTPdyaxRAxViE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PigcqNDVUSzgP2nbQOsawk9JdTkLTM2bnoQa//weqMCsVM+/E20p3g3Ju30ktcjONyitIpRa9EcjGxw6kimzJJei4nblXkjmY+KXkEowj2x01mecZnh50z0UcZlJF6tYVKB7S1MYd8Mp8aT2aNXU4KNG+mKU2zQqyWnNh9fHNwo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Sf8fPtCs; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Sf8fPtCs" Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45Q8ur27017759; Wed, 26 Jun 2024 09:16:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=VGQ+NVZnPbtDn Sezx+FmAuKkRAciQsN6HL8sSUrN0zM=; b=Sf8fPtCsPMmVhhfOpCx6TRIuuB6sx 2clOealZMqvotwhsszRg7l1ZgJIkRVZuGQWRqBOCMlbk+IzRj2n/cIgOmvM8I1KC H6/MCamUkcygbVKhefrw1A96T5NMI9FnfNxarGHX2n/GHItv4Eq4tgqZ3VSeU8iK iRqXw/PG0GwS/0g04LMuaniWEEnku4kkT51AwaKjo4g2fqv85jQeY5pLPKslYxlc 8BaYPcqltxqxt2ODOSjHw7Ltk1P1R1rlEWkx0oUTaUls+dIdF7Cg7nYtBlByASVC Q9GQQPtp807C5akziJASczBe5p4iV5a5vhykzfqn5r7maFFmVeYSYWbKQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 400e6frb9t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:16:58 +0000 (GMT) Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45Q9DCFm011618; Wed, 26 Jun 2024 09:16:58 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 400e6frb9p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:16:58 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45Q8MXQN018096; Wed, 26 Jun 2024 09:16:57 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yx8xubkx8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:16:57 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45Q9GrA950201000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jun 2024 09:16:55 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F9902005A; Wed, 26 Jun 2024 09:16:53 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C9B82004E; Wed, 26 Jun 2024 09:16:46 +0000 (GMT) Received: from li-fdfde5cc-27d0-11b2-a85c-e224154bf6d4.ibm.com.com (unknown [9.43.51.102]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 26 Jun 2024 09:16:46 +0000 (GMT) From: Madadi Vineeth Reddy To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Athira Rajeev , Chen Yu Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , acme@redhat.com, Fernand Sieber , linux-perf-users , LKML , Madadi Vineeth Reddy Subject: [PATCH v5 2/3] perf sched map: Add support for multiple task names using CSV Date: Wed, 26 Jun 2024 14:45:49 +0530 Message-ID: <20240626091550.46707-3-vineethr@linux.ibm.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240626091550.46707-1-vineethr@linux.ibm.com> References: <20240626091550.46707-1-vineethr@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: -l80oSjXWfHLwiI0ryA9Fu4h-GjQF6dp X-Proofpoint-GUID: Mz-WoBvURYLuPR6VM1yTGBB8Z1fHgCoK 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-26_03,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406260067 Content-Type: text/plain; charset="utf-8" To track the scheduling patterns of multiple tasks simultaneously, multiple task names can be specified using a comma separator without any whitespace. Sample output for --task-name perf,wdavdaemon =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D . *A0 . . . . - . 131040.641346 secs A0 =3D> wdavdaemon:62509 . A0 *B0 . . . - . 131040.641378 secs B0 =3D> wdavdaemon:62274 - *- - - - - - - 131040.641379 secs *C0 . B0 . . . . . 131040.641572 secs C0 =3D> wdavdaemon:62283 ... - *- - - - - - - 131041.395649 secs . . . . . . . *X2 131041.403969 secs X2 =3D> perf:70211 - - - - - - - *- 131041.404006 secs Suggested-by: Namhyung Kim Reviewed-and-tested-by: Athira Rajeev Signed-off-by: Madadi Vineeth Reddy --- tools/perf/Documentation/perf-sched.txt | 5 +- tools/perf/builtin-sched.c | 77 +++++++++++++++++++++---- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documenta= tion/perf-sched.txt index 3255e5b8e74b..3095e280eb92 100644 --- a/tools/perf/Documentation/perf-sched.txt +++ b/tools/perf/Documentation/perf-sched.txt @@ -131,9 +131,10 @@ OPTIONS for 'perf sched map' Highlight the given pids. =20 --task-name :: - Map output only for the given task name. The sched-out + Map output only for the given task name(s). Separate the + task names with a comma (without whitespace). The sched-out time is printed and is represented by '*-' for the given - task name + task name(s). ('-' indicates other tasks while '.' is idle). =20 OPTIONS for 'perf sched timehist' diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 57f166662d54..ecb43deb9d74 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1540,24 +1540,72 @@ map__findnew_thread(struct perf_sched *sched, struc= t machine *machine, pid_t pid return thread; } =20 -static bool sched_match_task(const char *comm_str, const char *commands) +struct CommandList { + char **command_list; + int command_count; +}; + +static void free_command_list(struct CommandList *cmd_list) +{ + if (cmd_list) { + for (int i =3D 0; i < cmd_list->command_count; i++) + free(cmd_list->command_list[i]); + free(cmd_list->command_list); + free(cmd_list); + } +} + +static struct CommandList *parse_commands(const char *commands) { char *commands_copy =3D NULL; + struct CommandList *cmd_list =3D NULL; char *token =3D NULL; - bool match_found =3D false; =20 commands_copy =3D strdup(commands); if (commands_copy =3D=3D NULL) return NULL; =20 + cmd_list =3D malloc(sizeof(struct CommandList)); + if (cmd_list =3D=3D NULL) { + free(commands_copy); + return NULL; + } + + cmd_list->command_count =3D 0; + cmd_list->command_list =3D NULL; + token =3D strtok(commands_copy, ","); + while (token !=3D NULL) { + cmd_list->command_list =3D realloc(cmd_list->command_list, sizeof(char *) + *(cmd_list->command_count + 1)); + if (cmd_list->command_list =3D=3D NULL) { + free_command_list(cmd_list); + free(commands_copy); + return NULL; + } =20 - while (token !=3D NULL && !match_found) { - match_found =3D !strcmp(comm_str, token); + cmd_list->command_list[cmd_list->command_count] =3D strdup(token); + if (cmd_list->command_list[cmd_list->command_count] =3D=3D NULL) { + free_command_list(cmd_list); + free(commands_copy); + return NULL; + } + + cmd_list->command_count++; token =3D strtok(NULL, ","); } =20 free(commands_copy); + return cmd_list; +} + +static bool sched_match_task(const char *comm_str, struct CommandList *cmd= _list) +{ + bool match_found =3D false; + + for (int i =3D 0; i < cmd_list->command_count && !match_found; i++) + match_found =3D !strcmp(comm_str, cmd_list->command_list[i]); + return match_found; } =20 @@ -1624,6 +1672,8 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, char stimestamp[32]; const char *str; =20 + struct CommandList *cmd_list =3D NULL; + BUG_ON(this_cpu.cpu >=3D MAX_CPUS || this_cpu.cpu < 0); =20 if (this_cpu.cpu > sched->max_cpu.cpu) @@ -1664,7 +1714,11 @@ static int map_switch_event(struct perf_sched *sched= , struct evsel *evsel, sched->curr_thread[this_cpu.cpu] =3D thread__get(sched_in); sched->curr_out_thread[this_cpu.cpu] =3D thread__get(sched_out); =20 + if (sched->map.task_name) + cmd_list =3D parse_commands(sched->map.task_name); + new_shortname =3D 0; + str =3D thread__comm_str(sched_in); if (!tr->shortname[0]) { if (!strcmp(thread__comm_str(sched_in), "swapper")) { /* @@ -1673,8 +1727,7 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, */ tr->shortname[0] =3D '.'; tr->shortname[1] =3D ' '; - } else if (!sched->map.task_name || sched_match_task(thread__comm_str(sc= hed_in), - sched->map.task_name)) { + } else if (!sched->map.task_name || sched_match_task(str, cmd_list)) { tr->shortname[0] =3D sched->next_shortname1; tr->shortname[1] =3D sched->next_shortname2; =20 @@ -1703,15 +1756,15 @@ static int map_switch_event(struct perf_sched *sche= d, struct evsel *evsel, * Check which of sched_in and sched_out matches the passed --task-name * arguments and call the corresponding print_sched_map. */ - if (sched->map.task_name && !sched_match_task(str, sched->map.task_name))= { - if (!sched_match_task(thread__comm_str(sched_out), sched->map.task_name)) + if (sched->map.task_name && !sched_match_task(str, cmd_list)) { + if (!sched_match_task(thread__comm_str(sched_out), cmd_list)) goto out; else goto sched_out; =20 } else { str =3D thread__comm_str(sched_out); - if (!(sched->map.task_name && !sched_match_task(str, sched->map.task_nam= e))) + if (!(sched->map.task_name && !sched_match_task(str, cmd_list))) proceed =3D 1; } =20 @@ -1758,8 +1811,10 @@ static int map_switch_event(struct perf_sched *sched= , struct evsel *evsel, color_fprintf(stdout, color, "\n"); =20 out: - if (sched->map.task_name) + if (sched->map.task_name) { + free_command_list(cmd_list); thread__put(sched_out); + } =20 thread__put(sched_in); =20 @@ -3651,7 +3706,7 @@ int cmd_sched(int argc, const char **argv) OPT_STRING(0, "cpus", &sched.map.cpus_str, "cpus", "display given CPUs in map"), OPT_STRING(0, "task-name", &sched.map.task_name, "task", - "map output only for the given task name"), + "map output only for the given task name(s)."), OPT_PARENT(sched_options) }; const struct option timehist_options[] =3D { --=20 2.43.2 From nobody Wed Dec 17 23:51:09 2025 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 E7248168486; Wed, 26 Jun 2024 09:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719393442; cv=none; b=YTaZw0+taiulPkQInH4p0gnS31ysykLtaakIzAf/PzejlrAjIo9WiwLI6e+fhUbAZO5QnKstua/Yj6U5qP2YfOcb73OIxLutp0gLoovWe/tWX68y2dUTRrh62+O1+yGYtzNtdIiYOgxW3tNL9kSQks5weyzgQft/pLMNMBXAWL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719393442; c=relaxed/simple; bh=tYPyX6886SAJdc9m6hgCgPEn28NWpQzFqWmfB546fS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TXlhGu2F0BCrCEgOvP22UEagijm8o4btdDQyk8vmdtUYGE0K8ZQfVHpNr4jIKApWv9MJ1fBduSP8sQvWXST823y+3XdmLPoiDf+vFsg+/ThpzVqvuS2WPwCQVGvaNVQTA1eed/am6KUzrgFytbiw+vR6iuEY3NmgD2j2ULE+HDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=a39n9O97; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="a39n9O97" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45Q8SXeH006364; Wed, 26 Jun 2024 09:17:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=YTbEobxX0rS76 TFeDHHtgoJ3WXZMfYodjrAvpvqJhJE=; b=a39n9O97KESMHoqrEfcY8d2K0UyRJ HbtDnngVCwFDudbc/7MBwtouaMcemNSyGoGOyiQ0F06/sXNh32AlOw/FHy2OTcIq /bacGFLuc10ti7DRkgKTZsfMnahqXXSend4zkZ3wXOsK0rx8C6QrDSKqSDtbK5T2 9lKWLzIxiabv5gq07HfGY45ZtLykkT6HlOzsDcxs29Voq3jigeSMOo5woOfnS7ow bqZtB8aIPVIkNHIY1j2WmKj8JVDP506bN4gr20pjQc3njoF11S1vW7ncywn6NOdM kzWQiilQtmPBegLBw+o0foLG+tvJrDAvsQMYgvT2lJrZAHdLKF0Favi1Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 400fgng3nc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:17:08 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45Q9H7JC014220; Wed, 26 Jun 2024 09:17:07 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 400fgng3n7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:17:07 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45Q7UlDf000402; Wed, 26 Jun 2024 09:17:06 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxbn3ayt7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jun 2024 09:17:06 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45Q9H3dx49479998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jun 2024 09:17:05 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8A082005A; Wed, 26 Jun 2024 09:17:02 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E70E2004B; Wed, 26 Jun 2024 09:16:56 +0000 (GMT) Received: from li-fdfde5cc-27d0-11b2-a85c-e224154bf6d4.ibm.com.com (unknown [9.43.51.102]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 26 Jun 2024 09:16:55 +0000 (GMT) From: Madadi Vineeth Reddy To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Athira Rajeev , Chen Yu Cc: Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , acme@redhat.com, Fernand Sieber , linux-perf-users , LKML , Madadi Vineeth Reddy Subject: [PATCH v5 3/3] perf sched map: Add --fuzzy-name option for fuzzy matching in task names Date: Wed, 26 Jun 2024 14:45:50 +0530 Message-ID: <20240626091550.46707-4-vineethr@linux.ibm.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240626091550.46707-1-vineethr@linux.ibm.com> References: <20240626091550.46707-1-vineethr@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: eLGAuKoBOWZ16HksXPOGGGszb8clGvKc X-Proofpoint-GUID: _NnUdIRmtGhsYSwgeFaeFf_tsdxUrRMZ 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-26_03,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406260067 Content-Type: text/plain; charset="utf-8" The --fuzzy-name option can be used if fuzzy name matching is required. For example, "taskname" can be matched to any string that contains "taskname" as its substring. Sample output for --task-name wdav --fuzzy-name =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D . *A0 . . . . - . 131040.641346 secs A0 =3D> wdavdaemon:62509 . A0 *B0 . . . - . 131040.641378 secs B0 =3D> wdavdaemon:62274 - *- - - - - - - 131040.641379 secs *C0 . B0 . . . . . 131040.641572 secs C0 =3D> wdavdaemon:62283 C0 . B0 . *D0 . . . 131040.641572 secs D0 =3D> wdavdaemon:62277 C0 . B0 . D0 . *E0 . 131040.641578 secs E0 =3D> wdavdaemon:62270 *- - - - - - - - 131040.641581 secs Suggested-by: Chen Yu Reviewed-and-tested-by: Athira Rajeev Signed-off-by: Madadi Vineeth Reddy --- tools/perf/Documentation/perf-sched.txt | 3 +++ tools/perf/builtin-sched.c | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documenta= tion/perf-sched.txt index 3095e280eb92..938b41a3befa 100644 --- a/tools/perf/Documentation/perf-sched.txt +++ b/tools/perf/Documentation/perf-sched.txt @@ -137,6 +137,9 @@ OPTIONS for 'perf sched map' task name(s). ('-' indicates other tasks while '.' is idle). =20 +--fuzzy-name:: + Given task name(s) can be partially matched (fuzzy matching). + OPTIONS for 'perf sched timehist' --------------------------------- -k:: diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index ecb43deb9d74..c801c38e8b9a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -157,6 +157,7 @@ struct perf_sched_map { struct perf_cpu_map *color_cpus; const char *color_cpus_str; const char *task_name; + bool fuzzy; struct perf_cpu_map *cpus; const char *cpus_str; }; @@ -1599,12 +1600,16 @@ static struct CommandList *parse_commands(const cha= r *commands) return cmd_list; } =20 -static bool sched_match_task(const char *comm_str, struct CommandList *cmd= _list) +static bool sched_match_task(const char *comm_str, struct CommandList *cmd= _list, bool fuzzy_match) { bool match_found =3D false; =20 - for (int i =3D 0; i < cmd_list->command_count && !match_found; i++) - match_found =3D !strcmp(comm_str, cmd_list->command_list[i]); + for (int i =3D 0; i < cmd_list->command_count && !match_found; i++) { + if (fuzzy_match) + match_found =3D !!strstr(comm_str, cmd_list->command_list[i]); + else + match_found =3D !strcmp(comm_str, cmd_list->command_list[i]); + } =20 return match_found; } @@ -1727,7 +1732,8 @@ static int map_switch_event(struct perf_sched *sched,= struct evsel *evsel, */ tr->shortname[0] =3D '.'; tr->shortname[1] =3D ' '; - } else if (!sched->map.task_name || sched_match_task(str, cmd_list)) { + } else if (!sched->map.task_name || sched_match_task(str, cmd_list, + sched->map.fuzzy)) { tr->shortname[0] =3D sched->next_shortname1; tr->shortname[1] =3D sched->next_shortname2; =20 @@ -1756,15 +1762,15 @@ static int map_switch_event(struct perf_sched *sche= d, struct evsel *evsel, * Check which of sched_in and sched_out matches the passed --task-name * arguments and call the corresponding print_sched_map. */ - if (sched->map.task_name && !sched_match_task(str, cmd_list)) { - if (!sched_match_task(thread__comm_str(sched_out), cmd_list)) + if (sched->map.task_name && !sched_match_task(str, cmd_list, sched->map.f= uzzy)) { + if (!sched_match_task(thread__comm_str(sched_out), cmd_list, sched->map.= fuzzy)) goto out; else goto sched_out; =20 } else { str =3D thread__comm_str(sched_out); - if (!(sched->map.task_name && !sched_match_task(str, cmd_list))) + if (!(sched->map.task_name && !sched_match_task(str, cmd_list, sched->ma= p.fuzzy))) proceed =3D 1; } =20 @@ -3707,6 +3713,8 @@ int cmd_sched(int argc, const char **argv) "display given CPUs in map"), OPT_STRING(0, "task-name", &sched.map.task_name, "task", "map output only for the given task name(s)."), + OPT_BOOLEAN(0, "fuzzy-name", &sched.map.fuzzy, + "given command name can be partially matched (fuzzy matching)"), OPT_PARENT(sched_options) }; const struct option timehist_options[] =3D { --=20 2.43.2