Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2318086rdb; Mon, 5 Feb 2024 02:52:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkYuU7IBeGZ1cLnPAU8avTAFMay4fHB6obihvRXAFCfL5a7iI1w8hqGzz2DpzoQ/bA5wuU X-Received: by 2002:a9d:695a:0:b0:6d9:e3ad:a602 with SMTP id p26-20020a9d695a000000b006d9e3ada602mr14409316oto.5.1707130341168; Mon, 05 Feb 2024 02:52:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707130341; cv=pass; d=google.com; s=arc-20160816; b=YBdaFggHuDAFBFgxJAXkZBKl/9oGfkhQUWEGSyQvhkgRvhtoDMuCB5RyNIIZQmUj+F B1moKosmUCGXlBp6yzZEAzzxcxCCp6yp/qRKW+rG4UDXOG3UFRGhB0bqA4Lf86yRf3Iw vmpOg7sqkcwL70tnqRz9xhKAmn5e7mJaTz3teSHudGc9ZSaycjQpk+BGJcZOr31cdn6z rzJFOe/ECRrx3t+HQCa3Zm3MUsOXI+nbVgCTOkJFaOwl1sIQ5nTnh2xI89nZYldjLHrp wedXqmJ3DkFSmFa1uVl/9OyCHyH/ys9B9UcJwZPu2k7AUHULBQPdS/RapLalTv9tVpmr 2J2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=5F6kwwSq92wNsdgG2LjS93MZthXScS6y6HTKpW+tgHM=; fh=6I5AIKRTvNIYgK24DphQUU5P3vSFcYowolkzzFZFd4E=; b=FkH7XSD3hsSIKgMYhkEBMnrRniG10JP1poSZbFvXtNWs083jKaxj7RvDHZ75pno1hM AuYNPGkAl5cxTpeK5Qm7jerhikXg52r0nqxDciRSc30Xypx2rLJMRxNQAj0eJjRkjola dtlKLW352OU5T04SqiDAUKk6IEhuv0UWm6q8QxR9x/K2aPKjJalNjtg8aaElVNqnvjtl SQ2aS+Yo18shMXEB7HGbw9ezLN6nhM+IGqI2cVTg7/YBzHTkgJ8xYYD9/4KZNooUYwXy vil1Y9429JejkPrHbNe4f3KJlCxHxyF4m+8nbmOOjMXUEdue30sg4tuiXvnEr1I19Snq llxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-52436-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=1; AJvYcCX1LeEg2YtzZGbziEBOTD0AP7GE4VDCSEMuUfkn/lAnfk77Unxj5cgGgsLdqe+wDA++iWPC/1ikgSiIbzjCG1ewHeDWVtCN4hqQzcpwmA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d3-20020a63d643000000b005d8b547307bsi5902938pgj.575.2024.02.05.02.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 02:52:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52436-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-52436-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 651902842E6 for ; Mon, 5 Feb 2024 10:52:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56F9E1802E; Mon, 5 Feb 2024 10:51:20 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 632DC17582; Mon, 5 Feb 2024 10:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707130279; cv=none; b=Bzn37d7lkVog2T59am/Sml+M+fyLee5aBqIaJvzNouj7NI2SpWXBXS/DKeeBoHVlEZSF1083+uInD0DIuoE2o7R0RKFw9k+BfiMKugNTf7MVmgZz21yUoTVouyzmNcMvWhGKMTLa2IX/I1SCl0eWiQ8O9Fj7HmYYpz4f2SxPmfo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707130279; c=relaxed/simple; bh=x20H/xqFye1CUB/tnJpjcfP8jCPUoLwmX5KDeuLTrdI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ZrJcHylQkDdT0oPQRR8uKDcKm7CgPkVL/ehAA/ojbRb5VWaBaijxA+eKBki5E5x63WlBVEtPg6csvgiCyW3JgB9Lf2dZXsRPoOc+3gtED/l1fA+cIXcMyuT71d2i9EIyjpMLTE9C2CMfKWC8Qm5+wSSHkvTLhJ2UNYEEiD8TtQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TT373275Yz1xnFK; Mon, 5 Feb 2024 18:50:07 +0800 (CST) Received: from kwepemm600003.china.huawei.com (unknown [7.193.23.202]) by mail.maildlp.com (Postfix) with ESMTPS id A299C1A016B; Mon, 5 Feb 2024 18:51:12 +0800 (CST) Received: from ubuntu2204.huawei.com (10.67.174.22) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 5 Feb 2024 18:51:11 +0800 From: Yang Jihong To: , , , , , , , , , , CC: Subject: [PATCH 0/5] perf sched: Minor optimizations for resource initialization Date: Mon, 5 Feb 2024 10:46:11 +0000 Message-ID: <20240205104616.132417-1-yangjihong1@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600003.china.huawei.com (7.193.23.202) start_work_mutex, work_done_wait_mutex, curr_thread, curr_pid, and cpu_last_switched are initialized together in cmd_sched(), but for different perf sched subcommands, some actions are unnecessary, especially perf sched record. This series of patches initialize only required resources for different subcommands. Simple functional testing: # perf sched record perf bench sched messaging # Running 'sched/messaging' benchmark: # 20 sender and receiver processes per group # 10 groups == 400 processes run Total time: 0.204 [sec] [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 14.868 MB perf.data (133947 samples) ] # perf sched latency ------------------------------------------------------------------------------------------------------------------------------------------- Task | Runtime ms | Switches | Avg delay ms | Max delay ms | Max delay start | Max delay end | ------------------------------------------------------------------------------------------------------------------------------------------- qemu-system-x86:(3) | 2.753 ms | 10 | avg: 0.963 ms | max: 8.526 ms | max start: 457541.695704 s | max end: 457541.704230 s sched-messaging:(401) | 2995.481 ms | 36312 | avg: 0.944 ms | max: 111.551 ms | max start: 457541.645349 s | max end: 457541.756900 s rcu_sched:14 | 0.402 ms | 32 | avg: 0.266 ms | max: 7.996 ms | max start: 457541.581363 s | max end: 457541.589359 s sshd:48125 | 0.461 ms | 2 | avg: 0.033 ms | max: 0.036 ms | max start: 457541.584374 s | max end: 457541.584410 s perf:112408 | 2.321 ms | 2 | avg: 0.031 ms | max: 0.032 ms | max start: 457541.846874 s | max end: 457541.846906 s ksoftirqd/1:22 | 0.704 ms | 3 | avg: 0.005 ms | max: 0.005 ms | max start: 457541.845388 s | max end: 457541.845393 s kworker/15:0-mm:61886 | 0.227 ms | 21 | avg: 0.005 ms | max: 0.006 ms | max start: 457541.739187 s | max end: 457541.739193 s kworker/13:1-ev:92643 | 0.249 ms | 22 | avg: 0.005 ms | max: 0.006 ms | max start: 457541.768695 s | max end: 457541.768701 s kworker/12:1-ev:61202 | 0.418 ms | 40 | avg: 0.005 ms | max: 0.007 ms | max start: 457541.739679 s | max end: 457541.739687 s ----------------------------------------------------------------------------------------------------------------- TOTAL: | 3007.424 ms | 36776 | --------------------------------------------------- # echo $? 0 # perf sched map *A0 457541.580856 secs A0 => migration/0:15 *. 457541.580886 secs . => swapper:0 . *B0 457541.581018 secs B0 => migration/1:21 . *. 457541.581050 secs . . *C0 457541.581147 secs C0 => migration/2:27 . . *. 457541.581174 secs . . . *D0 457541.581259 secs D0 => migration/3:33 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 *E7 . . . . 457541.847783 secs E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 *E7 . . . 457541.847873 secs E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 *E7 . . 457541.847954 secs E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 *E7 . 457541.848034 secs E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 E7 *E7 457541.848108 secs # echo $? 0 # perf sched replay run measurement overhead: 108 nsecs sleep measurement overhead: 65244 nsecs the run test took 1000002 nsecs the sleep test took 1079677 nsecs nr_run_events: 40700 nr_sleep_events: 41415 nr_wakeup_events: 31601 target-less wakeups: 15 multi-target wakeups: 805 task 0 ( swapper: 0), nr_events: 7307 task 1 ( swapper: 1), nr_events: 1 task 2 ( swapper: 2), nr_events: 1 task 713 ( sched-messaging: 112809), nr_events: 987 task 714 ( sched-messaging: 112810), nr_events: 2706 ------------------------------------------------------------ #1 : 1298.443, ravg: 1298.44, cpu: 8281.74 / 8281.74 #2 : 1316.426, ravg: 1300.24, cpu: 7577.61 / 8211.32 #3 : 1323.864, ravg: 1302.60, cpu: 7932.48 / 8183.44 #4 : 1329.423, ravg: 1305.29, cpu: 7646.17 / 8129.71 #5 : 1321.419, ravg: 1306.90, cpu: 7669.90 / 8083.73 #6 : 1322.082, ravg: 1308.42, cpu: 7755.66 / 8050.92 #7 : 1324.330, ravg: 1310.01, cpu: 7361.51 / 7981.98 #8 : 1312.489, ravg: 1310.26, cpu: 7170.11 / 7900.80 #9 : 1312.002, ravg: 1310.43, cpu: 7176.40 / 7828.36 #10 : 1311.737, ravg: 1310.56, cpu: 7121.14 / 7757.63 # echo $? 0 # perf sched script perf 112408 [000] 457541.580826: sched:sched_stat_runtime: comm=perf pid=112408 runtime=53050 [ns] vruntime=621244222333 [ns] perf 112408 [000] 457541.580831: sched:sched_waking: comm=migration/0 pid=15 prio=0 target_cpu=000 perf 112408 [000] 457541.580853: sched:sched_stat_runtime: comm=perf pid=112408 runtime=24379 [ns] vruntime=621244246712 [ns] perf 112408 [000] 457541.580856: sched:sched_switch: prev_comm=perf prev_pid=112408 prev_prio=120 prev_state=R+ ==> next_comm=migration/0 next_pid=15 next_prio=0 swapper 0 [012] 457541.847873: sched:sched_switch: prev_comm=swapper/12 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=perf next_pid=112408 next_prio=120 swapper 0 [013] 457541.847954: sched:sched_switch: prev_comm=swapper/13 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=perf next_pid=112408 next_prio=120 swapper 0 [014] 457541.848034: sched:sched_switch: prev_comm=swapper/14 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=perf next_pid=112408 next_prio=120 swapper 0 [015] 457541.848108: sched:sched_switch: prev_comm=swapper/15 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=perf next_pid=112408 next_prio=120 # echo $? 0 # perf sched timehist Samples do not have callchains. time cpu task name wait time sch delay run time [tid/pid] (msec) (msec) (msec) --------------- ------ ------------------------------ --------- --------- --------- 457541.580856 [0000] perf[112408] 0.000 0.000 0.000 457541.580886 [0000] migration/0[15] 0.000 0.024 0.029 457541.581018 [0001] perf[112408] 0.000 0.000 0.000 457541.581050 [0001] migration/1[21] 0.000 0.006 0.032 457541.581147 [0002] perf[112408] 0.000 0.000 0.000 457541.581174 [0002] migration/2[27] 0.000 0.005 0.026 457541.847623 [0009] 0.010 0.000 1.489 457541.847704 [0010] 0.012 0.000 1.777 457541.847783 [0011] 0.233 0.000 1.213 457541.847873 [0012] 0.008 0.000 24.188 457541.847954 [0013] 0.009 0.000 1.734 457541.848034 [0014] 0.009 0.000 2.969 457541.848108 [0015] 0.220 0.000 1.205 # echo $? 0 Yang Jihong (5): perf sched: Move start_work_mutex and work_done_wait_mutex initialization to perf_sched__replay() perf sched: Fix memory leak in perf_sched__map() perf sched: Move curr_thread initialization to perf_sched__map() perf sched: Move curr_pid and cpu_last_switched initialization to perf_sched__{lat|map|replay}() perf thread_map: Free strlist on normal path in thread_map__new_by_tid_str() tools/perf/builtin-sched.c | 163 ++++++++++++++++++++++------------- tools/perf/util/thread_map.c | 2 +- 2 files changed, 105 insertions(+), 60 deletions(-) -- 2.34.1