From patchwork Mon Aug 21 01:27:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 136363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2895963vqi; Mon, 21 Aug 2023 03:03:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMnIOy0pYAi5ZXU/AJC4LSM/0skz2Sfv2hsJ5PmY4VBHw+Ozh1P7xb7XytRNzA/4iwakkb X-Received: by 2002:a05:6a00:24d2:b0:687:5c3f:d834 with SMTP id d18-20020a056a0024d200b006875c3fd834mr9207255pfv.11.1692612192117; Mon, 21 Aug 2023 03:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692612192; cv=none; d=google.com; s=arc-20160816; b=ZCvCd4FnDw+Oy9hdCVX+ulG2BUQsh4PRhZT/Y6Tfav73JEX8TihIb3oQgPqXwS34Lx buF3nIzy6gvb+/cYkx+QU/z4RLE8gFVlp3aIm5jL/zWrJnZOoLQc5qAPUxXvMdXiKKkH o7UeyGhmVjrVsv9GD33O+XxITF09u3kstH8kf4LOaRFDcyEu3t0xXU0SIovjwi4YtJGS WysHc4Ql8586VgmXQUuMwhEYhvEArSiudMSaYU5w9wJuOFi7LYo1qT18c93gAGPDPUi6 oGDw4m9fM8ShDmiHJf0WRHg8gVnI4/rrD5L/ZAIDiERQ9pwBKXaWJw2iQAHctF3sqK4h kBTw== 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=9Se4/dGwdsQhvMNvWBEpdaqokTWImU5HRVnAbb5q1LQ=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=NAKZtnGoQwWyYKKjYq0dQ3c6cO11KFmV/qmuy1mMLq+Ph1Rbt7DqQ3iOtVFDqojG0g pXlmWSKiLMeQEK6AMwN8v4vYtmB1O1bKkrcWv2lzlz66ZJ+QgYlABFefy9a6qAiPBL6J 6KjLROtX/cf7KWQ1EfnFSTLxfs9Ll4K/JZ3ryfZxQ3GMJoHA6LyKF0cF4wxU8Yoh5dKO qXY0RQ5Q0tNPJKExyNARDTbuVqKlAKrhiqM/IQ4qdVHjCvXmTnFVjYLaiFYozELZdsry SPlNShBtio42/fgJpuKb+2eVsvUzHPONK9Ylzda4CcEJ4F7cKS9G9+55vDFyfG+zV2lO NdTg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by11-20020a056a00400b00b0067bf9a05b45si6682008pfb.110.2023.08.21.03.02.58; Mon, 21 Aug 2023 03:03:12 -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 S232378AbjHUBaf (ORCPT + 99 others); Sun, 20 Aug 2023 21:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232356AbjHUBad (ORCPT ); Sun, 20 Aug 2023 21:30:33 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C1C5AB; Sun, 20 Aug 2023 18:30:30 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTZZk2P1XzNmp5; Mon, 21 Aug 2023 09:26:54 +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.31; Mon, 21 Aug 2023 09:30:27 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v6 1/7] perf evlist: Add perf_evlist__go_system_wide() helper Date: Mon, 21 Aug 2023 01:27:28 +0000 Message-ID: <20230821012734.18241-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230821012734.18241-1-yangjihong1@huawei.com> References: <20230821012734.18241-1-yangjihong1@huawei.com> MIME-Version: 1.0 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=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774832521796350094 X-GMAIL-MSGID: 1774832521796350094 For dummy events that keep tracking, we may need to modify its cpu_maps. For example, change the cpu_maps to record sideband events for all CPUS. Add perf_evlist__go_system_wide() helper to support this scenario. Signed-off-by: Yang Jihong Acked-by: Adrian Hunter --- tools/lib/perf/evlist.c | 9 +++++++++ tools/lib/perf/include/internal/evlist.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index b8b066d0dc5e..3acbbccc1901 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -738,3 +738,12 @@ int perf_evlist__nr_groups(struct perf_evlist *evlist) } return nr_groups; } + +void perf_evlist__go_system_wide(struct perf_evlist *evlist, struct perf_evsel *evsel) +{ + if (!evsel->system_wide) { + evsel->system_wide = true; + if (evlist->needs_map_propagation) + __perf_evlist__propagate_maps(evlist, evsel); + } +} diff --git a/tools/lib/perf/include/internal/evlist.h b/tools/lib/perf/include/internal/evlist.h index 3339bc2f1765..d86ffe8ed483 100644 --- a/tools/lib/perf/include/internal/evlist.h +++ b/tools/lib/perf/include/internal/evlist.h @@ -135,4 +135,6 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist, void perf_evlist__reset_id_hash(struct perf_evlist *evlist); void __perf_evlist__set_leader(struct list_head *list, struct perf_evsel *leader); + +void perf_evlist__go_system_wide(struct perf_evlist *evlist, struct perf_evsel *evsel); #endif /* __LIBPERF_INTERNAL_EVLIST_H */ From patchwork Mon Aug 21 01:27:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 136354 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2876870vqi; Mon, 21 Aug 2023 02:12:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGywEzgTc01fwods5rpjGNnB1Oagj7tYy8tHuCtLk8K5hTmdJh9PV5+9w0r77he2FEbkZIE X-Received: by 2002:a17:907:2bec:b0:99b:6687:6107 with SMTP id gv44-20020a1709072bec00b0099b66876107mr4466834ejc.5.1692609158683; Mon, 21 Aug 2023 02:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692609158; cv=none; d=google.com; s=arc-20160816; b=TJnCYba/owDotvzL2N3yIPKw5Ew1uICCkJZOaq74W3JrYFyZZ9Wz6SIVldjipNhioN 2zPf/0ri+yOkL/hrAsuCQslapvQhm/qabaLYEO0jbI6m8ecWdrUQ0h66H1gJMon2VuQ7 m2E15eWTyRzcg52yykt69mMIRc7rO9dh0gZ99eRFmwNJLyQ+F6bakCBOnx0Bjfh0unee e61lDHpYI9yTc9FvnmyKXt1fwmt3fZdbQ8A0Brg9re9X40bEGUpP6J5M80qef38xm7Ci cKVJEAyOq7StmNcz9ICVIA+HG1qjCmgPinHS3A/YZUG/Ls+RevIu4UNHady1GYZ+NBvc IgEw== 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=nMSTfxhFgTBueV4KmmxTm1dfLVOIgFeFUynLJzHV0UA=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=vKkSqmp6C7xyy5SlAkU/KHxARsCogTVhtOLgYcuSKdsEsovoBibF1qItAUg4KTjlhw 4FQg7UGQH/wbz0F/kJV52L1Iftdjcu9Wih4yCwa94YQsIp8tWwfa7TM0x3q5XdAncgdQ 5LpvEhVvOG9xmATycFkOQKQk2A8cG+vY8/eDA6TCaouQIZqPiohudHwj2aiAs/ymNOoh kEi3U+h5KteDPTZ7XSiNWf8m88Uey3Q1nuS9LESAImIWhvPf+u9fGWGz/0WYjlA9ZZGl Pit5eN90113XdHhdrAz8xTPXpIeCP3qk5eNatTod61HkW96ul3w6z6HQDlCKHMq5gJG4 sTnQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ec9-20020a170906b6c900b00993150e5327si4996165ejb.341.2023.08.21.02.12.13; Mon, 21 Aug 2023 02:12:38 -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 S232412AbjHUBah (ORCPT + 99 others); Sun, 20 Aug 2023 21:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232363AbjHUBad (ORCPT ); Sun, 20 Aug 2023 21:30:33 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B784AC; Sun, 20 Aug 2023 18:30:30 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RTZd93T6wzrSTp; Mon, 21 Aug 2023 09:29:01 +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.31; Mon, 21 Aug 2023 09:30:27 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v6 2/7] perf evlist: Add evlist__findnew_tracking_event() helper Date: Mon, 21 Aug 2023 01:27:29 +0000 Message-ID: <20230821012734.18241-3-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230821012734.18241-1-yangjihong1@huawei.com> References: <20230821012734.18241-1-yangjihong1@huawei.com> MIME-Version: 1.0 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=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774829341481323732 X-GMAIL-MSGID: 1774829341481323732 Currently, intel-bts, intel-pt, and arm-spe may add a dummy event for tracking to the evlist. We may need to search for the dummy event for some settings. Therefore, add evlist__findnew_tracking_event() helper. evlist__findnew_tracking_event() also deal with system_wide maps if system_wide is true. Signed-off-by: Yang Jihong Acked-by: Adrian Hunter --- tools/perf/builtin-record.c | 11 +++-------- tools/perf/util/evlist.c | 18 ++++++++++++++++++ tools/perf/util/evlist.h | 1 + 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 34bb31f08bb5..12edad8392cc 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1293,14 +1293,9 @@ static int record__open(struct record *rec) */ if (opts->target.initial_delay || target__has_cpu(&opts->target) || perf_pmus__num_core_pmus() > 1) { - pos = evlist__get_tracking_event(evlist); - if (!evsel__is_dummy_event(pos)) { - /* Set up dummy event. */ - if (evlist__add_dummy(evlist)) - return -ENOMEM; - pos = evlist__last(evlist); - evlist__set_tracking_event(evlist, pos); - } + pos = evlist__findnew_tracking_event(evlist, false); + if (!pos) + return -ENOMEM; /* * Enable the dummy event when the process is forked for diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 7ef43f72098e..25c3ebe2c2f5 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1694,6 +1694,24 @@ void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_ev tracking_evsel->tracking = true; } +struct evsel *evlist__findnew_tracking_event(struct evlist *evlist, bool system_wide) +{ + struct evsel *evsel; + + evsel = evlist__get_tracking_event(evlist); + if (!evsel__is_dummy_event(evsel)) { + evsel = evlist__add_aux_dummy(evlist, system_wide); + if (!evsel) + return NULL; + + evlist__set_tracking_event(evlist, evsel); + } else if (system_wide) { + perf_evlist__go_system_wide(&evlist->core, &evsel->core); + } + + return evsel; +} + struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str) { struct evsel *evsel; diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 664c6bf7b3e0..98e7ddb2bd30 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -387,6 +387,7 @@ bool evlist_cpu_iterator__end(const struct evlist_cpu_iterator *evlist_cpu_itr); struct evsel *evlist__get_tracking_event(struct evlist *evlist); void evlist__set_tracking_event(struct evlist *evlist, struct evsel *tracking_evsel); +struct evsel *evlist__findnew_tracking_event(struct evlist *evlist, bool system_wide); struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str); From patchwork Mon Aug 21 01:27:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 136308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2732995vqi; Sun, 20 Aug 2023 18:40:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBCwrfGHEbVZs0P3zgn95dtacQvgGERW/67ruVuboAxKeDEX3X9V1k+jAt4IIoQPV9iRls X-Received: by 2002:a05:6a20:4305:b0:134:3a9b:4cd7 with SMTP id h5-20020a056a20430500b001343a9b4cd7mr7362551pzk.23.1692582032688; Sun, 20 Aug 2023 18:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692582032; cv=none; d=google.com; s=arc-20160816; b=KfshROym0luRWKi+KSqOwuE/sjPXTEQOXMV7zlv/dzewk/8bCmbcbOrGvZxsltaTv7 /azss/hMbyzUgkqmy5xFLCtV5B6iIJHHY3TEtY+Sh4cXCBs4DRs9909G444pEUonOHB2 TyX7x6f1yljfJItyT3zJQTXxta/pRohnltuBQkDeOvyKZZqP1f+/tcI0NocadETVsPVW mPC2pjm91zcpkxJgEn+oB4CBcE9qNnns/nWAIquYsdfWUGlFkKYNM+1V62I5qQKNkKlm vgsPSsFUyoFMKQ5ivFWV7M3jVzfwr4O3Poi+6hQ2ErAzwnNC7VPpKex0xFgCNmM8z2DB UFaQ== 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=NnpGKMcNnXzSD/EaMFI9RyfyyTgTGML/1Kg4KF/Jay8=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=BaseCfA8J0fTvRTPsn499hJArjn73l0MY5V99HPUiL7MKTOnk4mrsNUM7hVYAavIY5 X+uaG2Kht8kyhSadB79/aZsUYUYC4WeTFjm7xqERF7sBlaXvXp1R5tVyIVjrj8xqVCPF fPlxiqfM+pC5ld7zGTKWiXLiDmP9Z8827czHkT4Wrbr/kyQ4k7t3j5p3MAj0D0ZWUgDc z/2ozSnZe3IaYmcVwQSGARIEHzhTg2ew2Fuw8J5wQihQ/oOgYpQzmWQOWgVTldnCH1eP ErQGcTak7jBR/nWeMisZnWrWYOF+qNzCIVysQ39KjLnFlrpjCTxIqPs8phiUgHbRAIKE uXEw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u62-20020a638541000000b0056482047ae0si4315716pgd.723.2023.08.20.18.40.18; Sun, 20 Aug 2023 18:40:32 -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 S232430AbjHUBai (ORCPT + 99 others); Sun, 20 Aug 2023 21:30:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232385AbjHUBae (ORCPT ); Sun, 20 Aug 2023 21:30:34 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 111D1A2; Sun, 20 Aug 2023 18:30:31 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTZZl3vw5zNn2X; Mon, 21 Aug 2023 09:26:55 +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.31; Mon, 21 Aug 2023 09:30:28 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v6 3/7] perf record: Move setting dummy tracking before record__init_thread_masks() Date: Mon, 21 Aug 2023 01:27:30 +0000 Message-ID: <20230821012734.18241-4-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230821012734.18241-1-yangjihong1@huawei.com> References: <20230821012734.18241-1-yangjihong1@huawei.com> MIME-Version: 1.0 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=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774800897519349279 X-GMAIL-MSGID: 1774800897519349279 User space tasks can migrate between CPUs, so when tracing selected CPUs, sideband for all CPUs is needed. In this case set the cpu map of the evsel to all online CPUs. This may modify the original cpu map of the evlist. Therefore, need to check whether the preceding scenario exists before record__init_thread_masks(). Dummy tracking has been set in record__open(), move it before record__init_thread_masks() and add a helper for unified processing. The sys_perf_event_open invoked is as follows: # perf --debug verbose=3 record -e cpu-clock -D 100 true Opening: cpu-clock ------------------------------------------------------------ perf_event_attr: type 1 (PERF_TYPE_SOFTWARE) size 136 config 0 (PERF_COUNT_SW_CPU_CLOCK) { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|PERIOD|IDENTIFIER read_format ID|LOST disabled 1 inherit 1 freq 1 sample_id_all 1 exclude_guest 1 ------------------------------------------------------------ sys_perf_event_open: pid 10318 cpu 0 group_fd -1 flags 0x8 = 5 sys_perf_event_open: pid 10318 cpu 1 group_fd -1 flags 0x8 = 6 sys_perf_event_open: pid 10318 cpu 2 group_fd -1 flags 0x8 = 7 sys_perf_event_open: pid 10318 cpu 3 group_fd -1 flags 0x8 = 9 sys_perf_event_open: pid 10318 cpu 4 group_fd -1 flags 0x8 = 10 sys_perf_event_open: pid 10318 cpu 5 group_fd -1 flags 0x8 = 11 sys_perf_event_open: pid 10318 cpu 6 group_fd -1 flags 0x8 = 12 sys_perf_event_open: pid 10318 cpu 7 group_fd -1 flags 0x8 = 13 Opening: dummy:u ------------------------------------------------------------ perf_event_attr: type 1 (PERF_TYPE_SOFTWARE) size 136 config 0x9 (PERF_COUNT_SW_DUMMY) { sample_period, sample_freq } 1 sample_type IP|TID|TIME|IDENTIFIER read_format ID|LOST disabled 1 inherit 1 exclude_kernel 1 exclude_hv 1 mmap 1 comm 1 enable_on_exec 1 task 1 sample_id_all 1 exclude_guest 1 mmap2 1 comm_exec 1 ksymbol 1 bpf_event 1 ------------------------------------------------------------ sys_perf_event_open: pid 10318 cpu 0 group_fd -1 flags 0x8 = 14 sys_perf_event_open: pid 10318 cpu 1 group_fd -1 flags 0x8 = 15 sys_perf_event_open: pid 10318 cpu 2 group_fd -1 flags 0x8 = 16 sys_perf_event_open: pid 10318 cpu 3 group_fd -1 flags 0x8 = 17 sys_perf_event_open: pid 10318 cpu 4 group_fd -1 flags 0x8 = 18 sys_perf_event_open: pid 10318 cpu 5 group_fd -1 flags 0x8 = 19 sys_perf_event_open: pid 10318 cpu 6 group_fd -1 flags 0x8 = 20 sys_perf_event_open: pid 10318 cpu 7 group_fd -1 flags 0x8 = 21 Signed-off-by: Yang Jihong Acked-by: Adrian Hunter --- tools/perf/builtin-record.c | 59 +++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 12edad8392cc..4ee94058028f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -906,6 +906,37 @@ static int record__config_off_cpu(struct record *rec) return off_cpu_prepare(rec->evlist, &rec->opts.target, &rec->opts); } +static int record__config_tracking_events(struct record *rec) +{ + struct record_opts *opts = &rec->opts; + struct evlist *evlist = rec->evlist; + struct evsel *evsel; + + /* + * For initial_delay, system wide or a hybrid system, we need to add a + * dummy event so that we can track PERF_RECORD_MMAP to cover the delay + * of waiting or event synthesis. + */ + if (opts->target.initial_delay || target__has_cpu(&opts->target) || + perf_pmus__num_core_pmus() > 1) { + evsel = evlist__findnew_tracking_event(evlist, false); + if (!evsel) + return -ENOMEM; + + /* + * Enable the dummy event when the process is forked for + * initial_delay, immediately for system wide. + */ + if (opts->target.initial_delay && !evsel->immediate && + !target__has_cpu(&opts->target)) + evsel->core.attr.enable_on_exec = 1; + else + evsel->immediate = 1; + } + + return 0; +} + static bool record__kcore_readable(struct machine *machine) { char kcore[PATH_MAX]; @@ -1286,28 +1317,6 @@ static int record__open(struct record *rec) struct record_opts *opts = &rec->opts; int rc = 0; - /* - * For initial_delay, system wide or a hybrid system, we need to add a - * dummy event so that we can track PERF_RECORD_MMAP to cover the delay - * of waiting or event synthesis. - */ - if (opts->target.initial_delay || target__has_cpu(&opts->target) || - perf_pmus__num_core_pmus() > 1) { - pos = evlist__findnew_tracking_event(evlist, false); - if (!pos) - return -ENOMEM; - - /* - * Enable the dummy event when the process is forked for - * initial_delay, immediately for system wide. - */ - if (opts->target.initial_delay && !pos->immediate && - !target__has_cpu(&opts->target)) - pos->core.attr.enable_on_exec = 1; - else - pos->immediate = 1; - } - evlist__config(evlist, opts, &callchain_param); evlist__for_each_entry(evlist, pos) { @@ -4190,6 +4199,12 @@ int cmd_record(int argc, const char **argv) goto out; } + err = record__config_tracking_events(rec); + if (err) { + pr_err("record__config_tracking_events failed, error %d\n", err); + goto out; + } + err = record__init_thread_masks(rec); if (err) { pr_err("Failed to initialize parallel data streaming masks\n"); From patchwork Mon Aug 21 01:27:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 136415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3150854vqi; Mon, 21 Aug 2023 10:18:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmrb8dzF3tpChjNY4gsCVaLl5hwSL3vQCJ+pU4ZpZl5BeuqVMD5LXau68FMpVOmVOUku2r X-Received: by 2002:a17:902:f681:b0:1bc:56c3:ebb6 with SMTP id l1-20020a170902f68100b001bc56c3ebb6mr11338384plg.8.1692638289788; Mon, 21 Aug 2023 10:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692638289; cv=none; d=google.com; s=arc-20160816; b=j5o7+JJ0gJr458UTzCWmNzabMHjDH/L8Q6NukKEXjfuli3YHKHler3zwf/fSA6iqNL HbQ1vJmQ5Qynmh9ihF6nsZZ2xhIWCA3Ri45L2ik4simfZ1zg0rNQQrRzCMxg0HYY5HPZ XHm2lcsqc79UnvR5sk9dq7NUmwU0FMUEo9vfEshbyGVUSc5VMcLmlpDE/YJvqOwOwo0q SQRdYfDpq/oMesCxlxh1n5VFGxZrk5kjN9ELt9H2OXShQNFBR2jVddxcZunI1MecaK0j eFcyhBzN7LIWgU235CYGm37xPJ6KVIzL/RbIdn//Pf4yvCPtbkzH6XqiUz038UmChtvf Ruwg== 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=9+5niE0zVSvITtB+ESQwvuRIrye14zahF4rA4Z9v9Bs=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=qH7HnSIQ9YRp1LXxCHOEUMCDceTdVl+xZnpmkhYMND33PGSLfb29SmG/AltJZ/JuEV qKf9LYZ2ce1SDo2ed/zC46SBpSPgg5OBLA/4jK3JQor9f9DAlNG19TCu8O4ClSXLWU4B iFm+7WSxRrVvw123K1t0NcbC2fCyqq8E5Joxbad9IGPsZASAOsiw10tubVva70C4+IzB 3ge8yx1rxO6aSujuivaZ8Lq6tfjPMoR9v/Jz4CnFjhZYdqhpGR91O0cKip2PX9Ly1RvO /QHAgohHLs76uOrHHtJ6SIUKaernk3rCO3YdY6vTNfiQSyrpxIuthMu+aWWmeHDF5A3t saSg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a170903208b00b001b8c4021be9si7270418plc.397.2023.08.21.10.17.55; Mon, 21 Aug 2023 10:18:09 -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 S232446AbjHUBak (ORCPT + 99 others); Sun, 20 Aug 2023 21:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232328AbjHUBae (ORCPT ); Sun, 20 Aug 2023 21:30:34 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C42EA0; Sun, 20 Aug 2023 18:30:31 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RTZdC3CWZz1L90b; Mon, 21 Aug 2023 09:29:03 +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.31; Mon, 21 Aug 2023 09:30:29 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v6 4/7] perf record: Track sideband events for all CPUs when tracing selected CPUs Date: Mon, 21 Aug 2023 01:27:31 +0000 Message-ID: <20230821012734.18241-5-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230821012734.18241-1-yangjihong1@huawei.com> References: <20230821012734.18241-1-yangjihong1@huawei.com> MIME-Version: 1.0 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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774851993853639344 X-GMAIL-MSGID: 1774859887232896991 User space tasks can migrate between CPUs, we need to track side-band events for all CPUs. The specific scenarios are as follows: CPU0 CPU1 perf record -C 0 start taskA starts to be created and executed -> PERF_RECORD_COMM and PERF_RECORD_MMAP events only deliver to CPU1 ...... | migrate to CPU0 | Running on CPU0 <----------/ ... perf record -C 0 stop Now perf samples the PC of taskA. However, perf does not record the PERF_RECORD_COMM and PERF_RECORD_MMAP events of taskA. Therefore, the comm and symbols of taskA cannot be parsed. The solution is to record sideband events for all CPUs when tracing selected CPUs. Because this modifies the default behavior, add related comments to the perf record man page. The sys_perf_event_open invoked is as follows: # perf --debug verbose=3 record -e cpu-clock -C 1 true Opening: cpu-clock ------------------------------------------------------------ perf_event_attr: type 1 (PERF_TYPE_SOFTWARE) size 136 config 0 (PERF_COUNT_SW_CPU_CLOCK) { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|CPU|PERIOD|IDENTIFIER read_format ID|LOST disabled 1 inherit 1 freq 1 sample_id_all 1 exclude_guest 1 ------------------------------------------------------------ sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 5 Opening: dummy:u ------------------------------------------------------------ perf_event_attr: type 1 (PERF_TYPE_SOFTWARE) size 136 config 0x9 (PERF_COUNT_SW_DUMMY) { sample_period, sample_freq } 1 sample_type IP|TID|TIME|CPU|IDENTIFIER read_format ID|LOST inherit 1 exclude_kernel 1 exclude_hv 1 mmap 1 comm 1 task 1 sample_id_all 1 exclude_guest 1 mmap2 1 comm_exec 1 ksymbol 1 bpf_event 1 ------------------------------------------------------------ sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 6 sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 = 7 sys_perf_event_open: pid -1 cpu 2 group_fd -1 flags 0x8 = 9 sys_perf_event_open: pid -1 cpu 3 group_fd -1 flags 0x8 = 10 sys_perf_event_open: pid -1 cpu 4 group_fd -1 flags 0x8 = 11 sys_perf_event_open: pid -1 cpu 5 group_fd -1 flags 0x8 = 12 sys_perf_event_open: pid -1 cpu 6 group_fd -1 flags 0x8 = 13 sys_perf_event_open: pid -1 cpu 7 group_fd -1 flags 0x8 = 14 Signed-off-by: Yang Jihong Acked-by: Adrian Hunter --- tools/perf/Documentation/perf-record.txt | 3 ++ tools/perf/builtin-record.c | 44 +++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index d5217be012d7..1889f66addf2 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -374,6 +374,9 @@ comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0- In per-thread mode with inheritance mode on (default), samples are captured only when the thread executes on the designated CPUs. Default is to monitor all CPUs. +User space tasks can migrate between CPUs, so when tracing selected CPUs, +a dummy event is created to track sideband for all CPUs. + -B:: --no-buildid:: Do not save the build ids of binaries in the perf.data files. This skips diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 4ee94058028f..ae2e21b945fa 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -906,10 +906,44 @@ static int record__config_off_cpu(struct record *rec) return off_cpu_prepare(rec->evlist, &rec->opts.target, &rec->opts); } +static bool record__tracking_system_wide(struct record *rec) +{ + struct record_opts *opts = &rec->opts; + struct evlist *evlist = rec->evlist; + struct evsel *evsel; + + /* + * If all (non-dummy) evsel have exclude_user, + * system_wide is not needed. + * + * all_kernel and all_user will overwrite exclude_kernel and + * exclude_user of attr in evsel__config(), here need to check + * all the three items. + * + * Sideband system wide if one of the following conditions is met: + * + * - all_user is set, and there is a non-dummy event + * - all_user and all_kernel are not set, and there is + * a non-dummy event without exclude_user + */ + if (opts->all_kernel) + return false; + + evlist__for_each_entry(evlist, evsel) { + if (!evsel__is_dummy_event(evsel)) { + if (opts->all_user || !evsel->core.attr.exclude_user) + return true; + } + } + + return false; +} + static int record__config_tracking_events(struct record *rec) { struct record_opts *opts = &rec->opts; struct evlist *evlist = rec->evlist; + bool system_wide = false; struct evsel *evsel; /* @@ -919,7 +953,15 @@ static int record__config_tracking_events(struct record *rec) */ if (opts->target.initial_delay || target__has_cpu(&opts->target) || perf_pmus__num_core_pmus() > 1) { - evsel = evlist__findnew_tracking_event(evlist, false); + + /* + * User space tasks can migrate between CPUs, so when tracing + * selected CPUs, sideband for all CPUs is still needed. + */ + if (!!opts->target.cpu_list && record__tracking_system_wide(rec)) + system_wide = true; + + evsel = evlist__findnew_tracking_event(evlist, system_wide); if (!evsel) return -ENOMEM; From patchwork Mon Aug 21 01:27:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 136361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2893725vqi; Mon, 21 Aug 2023 02:59:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfi++45GsGCMZDLjc9Pi+FdBfxBywgXabBngGssDExp5Vnu+6uxRERLjAFmcc/S05q5rx5 X-Received: by 2002:a05:6402:1610:b0:525:70b3:72c2 with SMTP id f16-20020a056402161000b0052570b372c2mr4706715edv.14.1692611960427; Mon, 21 Aug 2023 02:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692611960; cv=none; d=google.com; s=arc-20160816; b=ohn1h0DZ8ktFLKo4/SidQ62R1pDzen49JB8nkhUyBVByY/tO3jWYQ9M+JStWsub9qA Dl+BkQRZx69k0w4aYdRs3GE72nK8b0fWhh7T3QBfOutaSoONxCyxDevO8Sgusu3xCXSI OoavyUU9GdeAUt+yvRTKbPZGH293q/4JlFOD7FS9PJnj3zk9KOeTEXEFuUbSWNVu+p9q aCWPFnaORBYRk3k4FCgIlGE6FSEt9gKiWEzNVxrv5VYR3xOmLbR4uvBmKu6yCkafsNA5 YxtrUjtra+d6Q29yxTAgN93H7D4nB8fbBvlHXcklcRNlPnRoyXhTvialjFYWTOSaItn4 rVow== 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=g3pdwHgmY7evmW6P2UQXVdPfh0DuDDsfo4UyXH9W6iI=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=r19rYdaRcl51BGawvalD63v7TYhQGD7DwrVdCusdQRWf8Y6C42eC8yNr1v4FydwsQD 5SkO3CNHghUsyax8LvVBEjxSCG8PZNu5orejBOfC4rk67QQwSAndp0Z/8rir2nQN70Os MvkzZZRaJjR2BS1l4GJsbSx3paqRyuMr80zqdP9vISWHuYcOmJfcN55rJ+PA6fgr+ji6 13PF7Ou9wnXUEH1RaCdwEF/1JU3e3nbSjygCgfRM3UjmejKA4FCZPVMRIZWRrOVmR3KC SoS3Bfx2/Pf+EHAtJNRz04+BRF17vjqYo0a8T1u6NZ0/DGguScSyURZn+JupziW5qwY/ kSaA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w25-20020aa7dcd9000000b005254dc5ba21si5725840edu.597.2023.08.21.02.58.56; Mon, 21 Aug 2023 02:59:20 -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 S232473AbjHUBaq (ORCPT + 99 others); Sun, 20 Aug 2023 21:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232434AbjHUBai (ORCPT ); Sun, 20 Aug 2023 21:30:38 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66C3CA8; Sun, 20 Aug 2023 18:30:33 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RTZZd6Q3rztRpW; Mon, 21 Aug 2023 09:26:49 +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.31; Mon, 21 Aug 2023 09:30:30 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v6 7/7] perf test: Add perf_event_attr test for record selected CPUs exclude_user Date: Mon, 21 Aug 2023 01:27:34 +0000 Message-ID: <20230821012734.18241-8-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230821012734.18241-1-yangjihong1@huawei.com> References: <20230821012734.18241-1-yangjihong1@huawei.com> MIME-Version: 1.0 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=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774832279287262475 X-GMAIL-MSGID: 1774832279287262475 If all (non-dummy) evsel have exclude_user, system_wide sideband is not needed. Add this test scenario. Test result: # ./perf test list 2>&1 | grep 'Setup struct perf_event_attr' 17: Setup struct perf_event_attr # ./perf test 17 -v 17: Setup struct perf_event_attr : --- start --- test child forked, pid 720198 running './tests/attr/test-record-C0-all-kernel' test child finished with 0 ---- end ---- Setup struct perf_event_attr: Ok Signed-off-by: Yang Jihong Tested-by: Adrian Hunter --- .../perf/tests/attr/test-record-C0-all-kernel | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tools/perf/tests/attr/test-record-C0-all-kernel diff --git a/tools/perf/tests/attr/test-record-C0-all-kernel b/tools/perf/tests/attr/test-record-C0-all-kernel new file mode 100644 index 000000000000..2d7549277c1e --- /dev/null +++ b/tools/perf/tests/attr/test-record-C0-all-kernel @@ -0,0 +1,32 @@ +[config] +command = record +args = --no-bpf-event --all-kernel -C 0 kill >/dev/null 2>&1 +ret = 1 + +[event:base-record] +cpu=0 + +# no enable on exec for CPU attached +enable_on_exec=0 + +# PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME | +# PERF_SAMPLE_PERIOD | PERF_SAMPLE_IDENTIFIER +# + PERF_SAMPLE_CPU added by -C 0 +sample_type=65927 + +# Dummy event handles mmaps, comm and task. +mmap=0 +comm=0 +task=0 + +# exclude_user for all-kernel option +exclude_user=1 + +[event:system-wide-dummy] + +# system_wide is not need for all (non-dummy) events have exclude_user +cpu=0 + +# exclude_user for all-kernel option +exclude_user=1 +exclude_kernel=0