Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1115067imw; Fri, 8 Jul 2022 19:32:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uRB/qNqN3HWW3SIDQcDYS0FnDBgUFYlwV5EjIjbnQaHm1uq6/YQ+YwSeKEBEzCBMHzYRUj X-Received: by 2002:aa7:d143:0:b0:43a:88f4:4ec1 with SMTP id r3-20020aa7d143000000b0043a88f44ec1mr8803268edo.141.1657333941741; Fri, 08 Jul 2022 19:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657333941; cv=none; d=google.com; s=arc-20160816; b=V+vrA1vU8XF2SWSSULKSZXFxQrXdzEG8Lry7DEuQ7hm6DLQXCSrvP2AgESZ0xwtdkZ 278abuWFmMI7K5o8eYtMp4IWO3xVhuk0p8H3g+YE4+1dnQ2ic1qUVq7z0P2QlzUBC8xy HpChOVmCh0Lnyot/bqFGhWOGt82H15IcuTwgp8fqUjjtOu7dZYJnHk1TBaY1aAnuDL0i pLVFl5NjOrgK/yEhLT23GMrbdj7XKr1ahj8VmTbxzOLrILPIQLs/gly/hWLT93F1Own9 tBzKb8pwvN2EB8/o3vqZRSqb924CJk7F3FsmbZYT3f/94ufnePJQl49TzjmOvIaDz0ah y5rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=S5XWdozgmI33h35qcfq7HfqYPGFRRTbCf/rrV3UBCto=; b=OfKa1T5omfNmKMDZnagLX0AwEqQbNGc1QRCLC62UrnttpzvOtr5iSO16fazUgkEkGH Qem8SpZdmDso1qRrpkozDAkldnJGefm++12c6Yp4CgwtP1sNBpDrBFxcSru0Eh/y8BlI 9JfqjeeFGfQKLH6m29p4QKrbeFOEYeFFA0ugUXYC9wuC0av2yboW6nmVD5XwVEm/ptRs BQbTeTAXE0xDX7Ay0JHefFKpn5r9Jaa7GhATXgRlpm0ukrAqpCIxeEwci5z17xMmdI9f X0082FBtiAjvOti6DROZfzA3g5dq8jh4Znl2O9mehmP1xNe4kbtPauMQBNxAtb/z1dPE 41WA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a056402191000b0043a50590dabsi717745edz.87.2022.07.08.19.31.53; Fri, 08 Jul 2022 19:32:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbiGIBxL (ORCPT + 99 others); Fri, 8 Jul 2022 21:53:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbiGIBxD (ORCPT ); Fri, 8 Jul 2022 21:53:03 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B3D78222; Fri, 8 Jul 2022 18:53:02 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LftQG31YfzhYyb; Sat, 9 Jul 2022 09:50:30 +0800 (CST) Received: from kwepemm600003.china.huawei.com (7.193.23.202) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 9 Jul 2022 09:52:59 +0800 Received: from ubuntu1804.huawei.com (10.67.174.61) 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.2375.24; Sat, 9 Jul 2022 09:52:59 +0800 From: Yang Jihong To: , , , , , , , , , CC: Subject: [RFC v3 04/17] perf kwork: Add workqueue kwork record support Date: Sat, 9 Jul 2022 09:50:20 +0800 Message-ID: <20220709015033.38326-5-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20220709015033.38326-1-yangjihong1@huawei.com> References: <20220709015033.38326-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.61] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Record workqueue events workqueue:workqueue_activate_work, workqueue:workqueue_execute_start & workqueue:workqueue_execute_end Tese cases: Record all events: # perf kwork record -o perf_kwork.date -- sleep 1 [ perf record: Woken up 0 times to write data ] [ perf record: Captured and wrote 0.857 MB perf_kwork.date ] # # perf evlist -i perf_kwork.date irq:irq_handler_entry irq:irq_handler_exit irq:softirq_raise irq:softirq_entry irq:softirq_exit workqueue:workqueue_activate_work workqueue:workqueue_execute_start workqueue:workqueue_execute_end dummy:HG # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events Record workqueue events: # perf kwork -k workqueue record -o perf_kwork.date -- sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.081 MB perf_kwork.date ] # # perf evlist -i perf_kwork.date workqueue:workqueue_activate_work workqueue:workqueue_execute_start workqueue:workqueue_execute_end dummy:HG # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events Signed-off-by: Yang Jihong --- tools/perf/Documentation/perf-kwork.txt | 2 +- tools/perf/builtin-kwork.c | 16 +++++++++++++++- tools/perf/util/kwork.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-kwork.txt b/tools/perf/Documentation/perf-kwork.txt index abfdeca2ad39..c5b52f61da99 100644 --- a/tools/perf/Documentation/perf-kwork.txt +++ b/tools/perf/Documentation/perf-kwork.txt @@ -32,7 +32,7 @@ OPTIONS -k:: --kwork:: - List of kwork to profile (irq, softirq, etc) + List of kwork to profile (irq, softirq, workqueue, etc) -v:: --verbose:: diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 2c492c8fd019..8086236b7513 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -50,9 +50,23 @@ static struct kwork_class kwork_softirq = { .tp_handlers = softirq_tp_handlers, }; +const struct evsel_str_handler workqueue_tp_handlers[] = { + { "workqueue:workqueue_activate_work", NULL, }, + { "workqueue:workqueue_execute_start", NULL, }, + { "workqueue:workqueue_execute_end", NULL, }, +}; + +static struct kwork_class kwork_workqueue = { + .name = "workqueue", + .type = KWORK_CLASS_WORKQUEUE, + .nr_tracepoints = 3, + .tp_handlers = workqueue_tp_handlers, +}; + static struct kwork_class *kwork_class_supported_list[KWORK_CLASS_MAX] = { [KWORK_CLASS_IRQ] = &kwork_irq, [KWORK_CLASS_SOFTIRQ] = &kwork_softirq, + [KWORK_CLASS_WORKQUEUE] = &kwork_workqueue, }; static void setup_event_list(struct perf_kwork *kwork, @@ -159,7 +173,7 @@ int cmd_kwork(int argc, const char **argv) OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in ASCII"), OPT_STRING('k', "kwork", &kwork.event_list_str, "kwork", - "list of kwork to profile (irq, softirq, etc)"), + "list of kwork to profile (irq, softirq, workqueue, etc)"), OPT_BOOLEAN('f', "force", &kwork.force, "don't complain, do it"), OPT_END() }; diff --git a/tools/perf/util/kwork.h b/tools/perf/util/kwork.h index 669a81626cb4..03203c4deb34 100644 --- a/tools/perf/util/kwork.h +++ b/tools/perf/util/kwork.h @@ -15,6 +15,7 @@ enum kwork_class_type { KWORK_CLASS_IRQ, KWORK_CLASS_SOFTIRQ, + KWORK_CLASS_WORKQUEUE, KWORK_CLASS_MAX, }; -- 2.30.GIT