Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1465878rdg; Sat, 12 Aug 2023 02:20:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmBJdjDoNHdRZp8HBp3QJ31sfvx+0wXAPP5ggxbj7OSQRbqFWF8bgIdTcmb7HNt5fd1JgC X-Received: by 2002:a05:6a00:1943:b0:687:40d8:8869 with SMTP id s3-20020a056a00194300b0068740d88869mr5084879pfk.8.1691832003120; Sat, 12 Aug 2023 02:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691832003; cv=none; d=google.com; s=arc-20160816; b=UED1orOBfhheD3p2LvdqVBXUxvvB9yG1/C4K1EzffjAHwUtFNnS6xpIyMK/ZAjyh0r bPGoAkF/JVPVds2nZ0vf6+vWZmddy9nc2hSdmvcoSzOzcI/5nKo4cAlBPurWLodujQjY 3bMor9DJ9RPRIcLIf8fkMjzhoDxG0b99OiGuH27EpizBHsogMcGWQD/RvqT+cXFtamNO jdMLh/+8AZp2hWm/aarHOt31WRzoIdMCMaWh2RJLDULK0aJ9sgRSpr2bZg3Zi4a3kzcY INWJVD4PLp+FoC9fq/g+Ttl09GYr8lnYKcHzzCj++SL4z1/+kyNp+fpuzQSwwHFalYEh C9ug== 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=eVq6mIJORMU7lKNhIwABqacA+sXYEn5mK4EtYLw+/0c=; fh=yJzUIAXk3G9GFZhd7AEi53Yh6JaeRXiXWLsFmPRnLKo=; b=fvVxVp5cIoLjjz1HanrbBxEqhg6yHhoLOb6k8AwXHIu7aYgkQ11byeXlA0xQL18u8Y LtiHIbM/z8mxTioPVtMx7sVc5SLEjBtMnMjVbV5PItt+5qX1GopnSEdungOtsc1fHNUU AVra/BFBiRZnbAeaeyK0Y3eEuhi6NL1GRd+sAV9dwEwRdHxCv31g6lzG6oNbyWfcApDH wmjEWbDG73HfVMke5Fv7ststdYHjaqM2JQ4FristHqmfb1Um+kknMh+4WJ3saVoG03EX CsFhFrKyVFUFXBGbUbnslV/G7SkVDEw52ip1ATnZhYg1ES8whl3KsiNitxJZTixZTlai qv/w== 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 s186-20020a635ec3000000b00553851380besi4625036pgb.397.2023.08.12.02.19.45; Sat, 12 Aug 2023 02:20:03 -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 S236696AbjHLIwP (ORCPT + 99 others); Sat, 12 Aug 2023 04:52:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235796AbjHLIwD (ORCPT ); Sat, 12 Aug 2023 04:52:03 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAFF42D52; Sat, 12 Aug 2023 01:52:06 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RNDrF20D9zTlp3; Sat, 12 Aug 2023 16:50:05 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) 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.27; Sat, 12 Aug 2023 16:52:04 +0800 From: Yang Jihong To: , , , , , , , , , , , , , CC: Subject: [RFC v1 06/16] perf kwork: Set default events list if not specified in setup_event_list() Date: Sat, 12 Aug 2023 08:49:07 +0000 Message-ID: <20230812084917.169338-7-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230812084917.169338-1-yangjihong1@huawei.com> References: <20230812084917.169338-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.95] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 Currently when no kwork event is specified, all events are configured by default. Now set to default event list string, which is more flexible and supports subsequent function extension. Also put setup_event_list() into each subcommand for different settings. Signed-off-by: Yang Jihong --- tools/perf/builtin-kwork.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index f620911a26a2..e859c34b23f3 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -1623,8 +1623,11 @@ static void setup_event_list(struct perf_kwork *kwork, struct kwork_class *class; char *tmp, *tok, *str; + /* + * set default events list if not specified + */ if (kwork->event_list_str == NULL) - goto null_event_list_str; + kwork->event_list_str = "irq, softirq, workqueue"; str = strdup(kwork->event_list_str); for (tok = strtok_r(str, ", ", &tmp); @@ -1643,17 +1646,6 @@ static void setup_event_list(struct perf_kwork *kwork, } free(str); -null_event_list_str: - /* - * config all kwork events if not specified - */ - if (list_empty(&kwork->class_list)) { - for (i = 0; i < KWORK_CLASS_MAX; i++) { - list_add_tail(&kwork_class_supported_list[i]->list, - &kwork->class_list); - } - } - pr_debug("Config event list:"); list_for_each_entry(class, &kwork->class_list, list) pr_debug(" %s", class->name); @@ -1835,12 +1827,12 @@ int cmd_kwork(int argc, const char **argv) if (!argc) usage_with_options(kwork_usage, kwork_options); - setup_event_list(&kwork, kwork_options, kwork_usage); sort_dimension__add(&kwork, "id", &kwork.cmp_id); - if (strlen(argv[0]) > 2 && strstarts("record", argv[0])) + if (strlen(argv[0]) > 2 && strstarts("record", argv[0])) { + setup_event_list(&kwork, kwork_options, kwork_usage); return perf_kwork__record(&kwork, argc, argv); - else if (strlen(argv[0]) > 2 && strstarts("report", argv[0])) { + } else if (strlen(argv[0]) > 2 && strstarts("report", argv[0])) { kwork.sort_order = default_report_sort_order; if (argc > 1) { argc = parse_options(argc, argv, report_options, report_usage, 0); @@ -1849,6 +1841,7 @@ int cmd_kwork(int argc, const char **argv) } kwork.report = KWORK_REPORT_RUNTIME; setup_sorting(&kwork, report_options, report_usage); + setup_event_list(&kwork, kwork_options, kwork_usage); return perf_kwork__report(&kwork); } else if (strlen(argv[0]) > 2 && strstarts("latency", argv[0])) { kwork.sort_order = default_latency_sort_order; @@ -1859,6 +1852,7 @@ int cmd_kwork(int argc, const char **argv) } kwork.report = KWORK_REPORT_LATENCY; setup_sorting(&kwork, latency_options, latency_usage); + setup_event_list(&kwork, kwork_options, kwork_usage); return perf_kwork__report(&kwork); } else if (strlen(argv[0]) > 2 && strstarts("timehist", argv[0])) { if (argc > 1) { @@ -1867,6 +1861,7 @@ int cmd_kwork(int argc, const char **argv) usage_with_options(timehist_usage, timehist_options); } kwork.report = KWORK_REPORT_TIMEHIST; + setup_event_list(&kwork, kwork_options, kwork_usage); return perf_kwork__timehist(&kwork); } else usage_with_options(kwork_usage, kwork_options); -- 2.30.GIT