From patchwork Fri Jun 24 14:03:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 12894539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D6BECCA473 for ; Fri, 24 Jun 2022 14:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232290AbiFXOGM (ORCPT ); Fri, 24 Jun 2022 10:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbiFXOGJ (ORCPT ); Fri, 24 Jun 2022 10:06:09 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47C6F4EDD8; Fri, 24 Jun 2022 07:06:04 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LTzPN1Z3jz1KCBf; Fri, 24 Jun 2022 22:03:52 +0800 (CST) Received: from kwepemm600003.china.huawei.com (7.193.23.202) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 22:06:02 +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; Fri, 24 Jun 2022 22:06:01 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [RFC v2 03/17] perf kwork: Add softirq kwork record support Date: Fri, 24 Jun 2022 22:03:35 +0800 Message-ID: <20220624140349.16964-4-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20220624140349.16964-1-yangjihong1@huawei.com> References: <20220624140349.16964-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.61] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC Record softirq events irq:softirq_raise, irq:softirq_entry & irq:softirq_exit. Test 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.897 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 dummy:HG # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events Record softirq events: # perf kwork -k softirq record -o perf_kwork.date -- sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.141 MB perf_kwork.date ] # # perf evlist -i perf_kwork.date irq:softirq_raise irq:softirq_entry irq:softirq_exit 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 57bd5fa7d5c9..abfdeca2ad39 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, etc) + List of kwork to profile (irq, softirq, etc) -v:: --verbose:: diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index a26b7fde1e38..2c492c8fd019 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -37,8 +37,22 @@ static struct kwork_class kwork_irq = { .tp_handlers = irq_tp_handlers, }; +const struct evsel_str_handler softirq_tp_handlers[] = { + { "irq:softirq_raise", NULL, }, + { "irq:softirq_entry", NULL, }, + { "irq:softirq_exit", NULL, }, +}; + +static struct kwork_class kwork_softirq = { + .name = "softirq", + .type = KWORK_CLASS_SOFTIRQ, + .nr_tracepoints = 3, + .tp_handlers = softirq_tp_handlers, +}; + static struct kwork_class *kwork_class_supported_list[KWORK_CLASS_MAX] = { [KWORK_CLASS_IRQ] = &kwork_irq, + [KWORK_CLASS_SOFTIRQ] = &kwork_softirq, }; static void setup_event_list(struct perf_kwork *kwork, @@ -145,7 +159,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, etc)"), + "list of kwork to profile (irq, softirq, 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 f1d89cb058fc..669a81626cb4 100644 --- a/tools/perf/util/kwork.h +++ b/tools/perf/util/kwork.h @@ -14,6 +14,7 @@ enum kwork_class_type { KWORK_CLASS_IRQ, + KWORK_CLASS_SOFTIRQ, KWORK_CLASS_MAX, };