From patchwork Sat Jul 15 03:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 120738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3013vqt; Fri, 14 Jul 2023 20:51:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlFFGb0cLtcEdWRXuUVdern4wl8829zpBFFqEqXDxgIuKUtLsVreF8KCUkawzghmTebg9Tjj X-Received: by 2002:a17:906:3956:b0:991:d727:6977 with SMTP id g22-20020a170906395600b00991d7276977mr5267860eje.38.1689393088827; Fri, 14 Jul 2023 20:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689393088; cv=none; d=google.com; s=arc-20160816; b=X9AlxfVxa23RoWrEYKHLS2bAkAD/y8+MUObVTMTN2Sr4vz/SKpDVHQyr13FtIgaAOn r683ab9UAO/HGfGzDCmKMbQgGw4XcHEpgY8Ft0utviFnXf6IDLROI4Uc44VXXbSTfVHZ idMNUqY+pLF8g3hvNVNwkWenZWbN9mPtU7D/yehsI3ZA1ETG6aFSs4EBXhHFQ+vIpS5d HR70pvP6EllcIcJD0hTzrRcXQrslz8I8G2prXAlPpdNKvLfmAdOXS4XjZx8CslgDn6X3 JpD9q2ebgk2UmEfJakALAtm53regiASdFzEBVuKRXXcvThEt3BKAsaA6nK6GNg0Frb/w yd+A== 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=NRO6ll3NODRZGsv8c8lf/yozKZ6mRiA3XVYR111eioU=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=er7Kgu2Atop/D3XE83zAPykLBLxENE1H212r3dsCAZpf5x0PzjQgNkW2vmRBbvmHKZ upfrXxqvDfUBJYl8AgpnOIIgMm+SJykeMEsYQ7lVPn6mGb8fCj/J7uCyDntWemou6MEb uEPow1b/xjJ+y8yZsB3ngvna0z9oJTu3rWxlhZH96MFiTKp8yjLwLSaSXPnipEuwZ3HM YkrqfA0UGSA+hYIM7j7lARJgS+5HqX6lDa5LqopKhwklExB3qbDMJkYyHZTxzfYoNo0v 6eZEBJ0C+UO8KHIOv2Dm4+Xnzk9VR7AtgpDfCLWUPzCk+RkI8XdcL7aJwTSjE7Sx7Irm 8zpw== 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 rn5-20020a170906d92500b0099396527229si11705459ejb.65.2023.07.14.20.51.05; Fri, 14 Jul 2023 20:51:28 -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 S229895AbjGODbg (ORCPT + 99 others); Fri, 14 Jul 2023 23:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjGODbe (ORCPT ); Fri, 14 Jul 2023 23:31:34 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69EB43A96; Fri, 14 Jul 2023 20:31:33 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R2v2r211nzLnj2; Sat, 15 Jul 2023 11:29:08 +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, 15 Jul 2023 11:31:30 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v2 1/7] perf evlist: Add perf_evlist__go_system_wide() helper Date: Sat, 15 Jul 2023 03:29:09 +0000 Message-ID: <20230715032915.97146-2-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230715032915.97146-1-yangjihong1@huawei.com> References: <20230715032915.97146-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,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771457047524869984 X-GMAIL-MSGID: 1771457047524869984 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 --- 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 Sat Jul 15 03:29:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 120736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp224vqt; Fri, 14 Jul 2023 20:36:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlGPgYBoBgSGMVm0AGQADzPJmQYXLckcwiWbBPUyDh5WaJ8dvVKCVci3Dg3yGRkvFnIP2lC/ X-Received: by 2002:a05:6512:210a:b0:4f6:6b:a43b with SMTP id q10-20020a056512210a00b004f6006ba43bmr4273409lfr.52.1689392207779; Fri, 14 Jul 2023 20:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689392207; cv=none; d=google.com; s=arc-20160816; b=VYvW3e5wztEh7E25WEc6qkr1gzJUuILOsFBUZv++RMPqBc4WJgJOOMknrkCAD+o1/H dAnaZj8Yn/s4qWhz9xa7ml7FH79EM0vSRm48g+32uVLjXzLqVvxfu85q6Q4KKsZb1TVW fmK3+D0gGnB7ZP/rjKXMi6YAZDEulp9wIWBqTUELoXWlBBOo0BSc5l86U0xeLDKjUFnz E9mT3kxwioF8aoX6KMVwheDY3msBSV6Q23TUlbj5c4wEYZ4FQR4CMZPaQeQRFW3K6bI/ pJpgm75TlTE1wnfuN9j2EoVtAxx2wMTdHwUt2iX9P2+E7drYDb4Qirv7IWJ9pvivs5WG vttA== 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=Op/wOwUQ6kgLn1wSpQN6Nxcm0PTNIgrnEOInp+6SHFk=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=NIJCLj9QjuePMop8meeN1dlrVcDRYf5ul2G/tFQbakU7FPhyJL/Gf/A1R7NqGIY/Pj QnqMAUFfOb0AOY41YGyI5RpJzrYm3mUg4p82IqLZqARPhtbxdhkXBLnYCV+crwuUepmg I8mikJWzg/8BdV5A/Hvd44CJr33yk2bv22dCzpBXE4RlVVZLCuGGjx2LRPAOpNCNyd9B 4lXln7xfrTmitrc61Du0R1uM5mOzcrp87HlfNn18JLJJZwJh4GgtweH+fgLbtgcvtVHz piYoX7YHXaXVofKvsUcSPnnZCZB567lbrBBqo8jyBrqO0SV2t13UhWABC89ggYzvkoi6 0eBA== 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 b3-20020aa7c6c3000000b0051e2936779fsi4141298eds.380.2023.07.14.20.36.24; Fri, 14 Jul 2023 20:36:47 -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 S230109AbjGODbn (ORCPT + 99 others); Fri, 14 Jul 2023 23:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbjGODbf (ORCPT ); Fri, 14 Jul 2023 23:31:35 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C0B3A99; Fri, 14 Jul 2023 20:31:34 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R2v25500VztR9j; Sat, 15 Jul 2023 11:28:29 +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, 15 Jul 2023 11:31:31 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v2 2/7] perf evlist: Add evlist__findnew_tracking_event() helper Date: Sat, 15 Jul 2023 03:29:10 +0000 Message-ID: <20230715032915.97146-3-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230715032915.97146-1-yangjihong1@huawei.com> References: <20230715032915.97146-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771456123528246571 X-GMAIL-MSGID: 1771456123528246571 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 --- 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 aec18db7ff23..ca83599cc50c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1295,14 +1295,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 Sat Jul 15 03:29:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 120741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp4204vqt; Fri, 14 Jul 2023 20:57:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlEhIknNdICEAs2/c5m/nukz9KvFIlFpG+lQKIfnai70t/c1jz/JoHb2S8TOL3m0p+7EgnEx X-Received: by 2002:a50:eb0b:0:b0:51e:65b:bc3b with SMTP id y11-20020a50eb0b000000b0051e065bbc3bmr5838535edp.15.1689393446814; Fri, 14 Jul 2023 20:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689393446; cv=none; d=google.com; s=arc-20160816; b=LCD3QcZiUG4uchkBJ8t47iUddt3Uc6RR2+rq12S1jrkM8reqCOyAAn1uhlZE0BMfnS 3H5qJ7z9U4SczA51pQ48s46AmjTQLQCCFkW9vx7KgQwY+Ig5n0ODWlL/3Xye0a4zqpxj 2bSA4ouHcsCoK109r8hK68gBAARbE0+6aelpagzfqea2rTS5P+jWeWVDvDBBYF5ABn15 WQLgq8heuPM1GpJuwuGwz4zof103hWPkz4sCAwZDaesKVUKKMxTjdPIsq0XaS6/okg1E J5uFUgQWvCJ41MC1ILg4ExIGW/iLUB4TbTnxLwQYbjc6saEalPobsDqINUiMKMEQVF3f F8KA== 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=xkfZCqhxVXYuQrKuecFhg1RgpxKjIEu3Yf9cDP57xVg=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=IOldm7/tMo3jpThPl9T3OUX9C1wEfS6hm0ec9C72U2iF3oQERAvAsvU7YUySVabvoJ 2mAMznoI0rg52eqUoz+PFZv3k+etdsMwAjtHs4szbpFos30xlAgEtsd1zehs5KOp3elF ZxAiEtVMch43/nQhE0e+HFpBtMT9CuCNA+VjjlKJAMv36pqHMosVdrxtUt80f2u4KiD0 D/LNn+DkwLDCNgaz6ryZzDPabKOV/I+G+OA4hDpwRr+3h4vdgKLcwTstLKyeDebrMvGH SEqLj+G/mnBZ8PuCf5kPSQutFm/6LjRmgFvYKjoUXTTunYfrYUDQWNfgeXcyb/iK1YLE xeaA== 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 w6-20020a50fa86000000b0051def1478e6si9502079edr.586.2023.07.14.20.57.03; Fri, 14 Jul 2023 20:57:26 -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 S230145AbjGODbz (ORCPT + 99 others); Fri, 14 Jul 2023 23:31:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjGODbh (ORCPT ); Fri, 14 Jul 2023 23:31:37 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65F923A96; Fri, 14 Jul 2023 20:31:35 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R2v262NSQztRTY; Sat, 15 Jul 2023 11:28:30 +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, 15 Jul 2023 11:31:31 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v2 3/7] perf record: Move setting dummy tracking before record__init_thread_masks() Date: Sat, 15 Jul 2023 03:29:11 +0000 Message-ID: <20230715032915.97146-4-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230715032915.97146-1-yangjihong1@huawei.com> References: <20230715032915.97146-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771457422459819861 X-GMAIL-MSGID: 1771457422459819861 When dummy tracking go system wide, the mmap cpu mask is changed. Therefore, needs to be placed 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 size 136 { 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 6867 cpu 0 group_fd -1 flags 0x8 = 5 sys_perf_event_open: pid 6867 cpu 1 group_fd -1 flags 0x8 = 6 sys_perf_event_open: pid 6867 cpu 2 group_fd -1 flags 0x8 = 7 sys_perf_event_open: pid 6867 cpu 3 group_fd -1 flags 0x8 = 9 sys_perf_event_open: pid 6867 cpu 4 group_fd -1 flags 0x8 = 10 sys_perf_event_open: pid 6867 cpu 5 group_fd -1 flags 0x8 = 11 sys_perf_event_open: pid 6867 cpu 6 group_fd -1 flags 0x8 = 12 sys_perf_event_open: pid 6867 cpu 7 group_fd -1 flags 0x8 = 13 Opening: dummy:u ------------------------------------------------------------ perf_event_attr: type 1 size 136 config 0x9 { 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 6867 cpu 0 group_fd -1 flags 0x8 = 14 sys_perf_event_open: pid 6867 cpu 1 group_fd -1 flags 0x8 = 15 sys_perf_event_open: pid 6867 cpu 2 group_fd -1 flags 0x8 = 16 sys_perf_event_open: pid 6867 cpu 3 group_fd -1 flags 0x8 = 17 sys_perf_event_open: pid 6867 cpu 4 group_fd -1 flags 0x8 = 18 sys_perf_event_open: pid 6867 cpu 5 group_fd -1 flags 0x8 = 19 sys_perf_event_open: pid 6867 cpu 6 group_fd -1 flags 0x8 = 20 sys_perf_event_open: pid 6867 cpu 7 group_fd -1 flags 0x8 = 21 Signed-off-by: Yang Jihong --- 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 ca83599cc50c..ccbcb005e188 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -908,6 +908,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 evsel *evsel; + struct evlist *evlist = rec->evlist; + struct record_opts *opts = &rec->opts; + + /* + * 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]; @@ -1288,28 +1319,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) { @@ -4235,6 +4244,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 Sat Jul 15 03:29:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 120739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3116vqt; Fri, 14 Jul 2023 20:52:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlHkUyBiPLf3gdrolc3U9UVIor7vxgUNFdAnBCA8slQq7MnB1Yu+25S/tNJcW4xjj+L9DZB6 X-Received: by 2002:a05:6402:524e:b0:51d:cf7b:c9f0 with SMTP id t14-20020a056402524e00b0051dcf7bc9f0mr6341206edd.12.1689393124652; Fri, 14 Jul 2023 20:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689393124; cv=none; d=google.com; s=arc-20160816; b=lGbQ6aRpqyT80Gs3f+heiYRy/1TvsrcTH5cUCbaqITlZqdc8dErO4iTpnzpUhUeawC xPiS4i0FTWwNZ6MdU2H/C39tbRDrhT/As5cH9UeXGcT8dZFPLtmJR4pacer9P9e8X2JA s5MefAN2J5H1sZghdL/apBY1DKFGGPjNhlXiBzApyLx/dcc4Nwfv6pIXiWoFVySVTe7H bYYrP7nOUhJ6hcrv4u7Af1s1E6vbR6jYh8xZCu5W4bg23tzpXGbOShYORucUdKX/95qr VWHX/ZyODwRZDojEMoV2UY+6ODBo+Y7ednAxL18HyMu7ug9AekxeEAgLDbPp+PAIdGvf VVAA== 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=5D+oJvvR3cLHl10EriNh8wzHAvUbBBl+MuodtDyZ9vA=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=GlIpjBTf3MQJH4mZJD5+3K+o0UD1rqt7rrYQV4EpC78K6Wzes5Ld2fUHhZGBS6y4NQ LGycejSlEsutZxAr3LrhSieg/lTqap9FhuAigoCtn2PpYc6sMMXbpBlXLkDQeYpNFnpj utYmQX+FdaXCWRTc1oSVd3mBgB+HYCL02fg3/ZVZG/3fAyHPhuwdQ4S1blJk6vHMbI4P 9ZKgEI2guqHFXp4JeTF6aP8EqxJHzaL4rjeq0MwI/mJnKaCemoTPAFFt9sNZnLPPCoWD Mh+PpfF3XFSumjjS0YnLFXra01l30sMsTSNjly2mANMYObElE8TkI9Z/UeThnyP+EBl1 3aZg== 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 i4-20020aa7c704000000b0051e186a6fadsi10362159edq.227.2023.07.14.20.51.41; Fri, 14 Jul 2023 20:52:04 -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 S230183AbjGODbw (ORCPT + 99 others); Fri, 14 Jul 2023 23:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjGODbh (ORCPT ); Fri, 14 Jul 2023 23:31:37 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73A893A9C; Fri, 14 Jul 2023 20:31:35 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R2v2672BwztRBW; Sat, 15 Jul 2023 11:28:30 +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, 15 Jul 2023 11:31:32 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v2 4/7] perf record: Track sideband events for all CPUs when tracing selected CPUs Date: Sat, 15 Jul 2023 03:29:12 +0000 Message-ID: <20230715032915.97146-5-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230715032915.97146-1-yangjihong1@huawei.com> References: <20230715032915.97146-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771456753511648849 X-GMAIL-MSGID: 1771457085034229830 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 size 136 { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|ID|CPU|PERIOD 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:HG ------------------------------------------------------------ perf_event_attr: type 1 size 136 config 0x9 { 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 --- tools/perf/Documentation/perf-record.txt | 3 +++ tools/perf/builtin-record.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 680396c56bd1..dac53ece51ab 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -388,6 +388,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 ccbcb005e188..4a15b2e06f45 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -921,7 +921,12 @@ 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. + */ + evsel = evlist__findnew_tracking_event(evlist, !!opts->target.cpu_list); if (!evsel) return -ENOMEM; From patchwork Sat Jul 15 03:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 120737 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2447vqt; Fri, 14 Jul 2023 20:48:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlFHC1jeFmcpZd0o9HiQKKb59hBj4R0MovonY713/MUmAE0fqAgvH3GEEt7VCQrHyD+ArhBO X-Received: by 2002:a17:907:7ba8:b0:989:21e4:6c6d with SMTP id ne40-20020a1709077ba800b0098921e46c6dmr5085550ejc.28.1689392922421; Fri, 14 Jul 2023 20:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689392922; cv=none; d=google.com; s=arc-20160816; b=L2jfnvZK9GznG/S3ycacDDFI1FxusfUgM93e9RNVIrNlK5HI37TTXK8PmPs+57tDaF NvDWjFv1KjQFswPIB4JFx1WvgeyZtqJUZ+ptQdAWRw3HA/BkWhtlsH5pxCdJIMWZ3cdP cv25c2bhz6Pmoitu+yrhigsRi3qLBWFEHqwdb6QDfzsl2bdq9z8UX7noio76vYc6jMWW Ppfsw87o5LH1NEc78Fv2CNrbisz7azOwlAYydlQkIeVLPzsEY8VsnNxyOZGt7OPnzOBT ArVc4balhXQPnphU3VjThN+85eZL2a6F9QkRJx4pP+QC2BJeG6AU+DgEeSPNLbpcm+EI Ic3A== 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=KYyF7GMwdJnmcSDi3ym4N6moo/bcg8n7UAWJpc/Ey+o=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=AZBczwfI0v/rFlj3s1rV+/KTPDcqYhJf5GSoXG/PPQLHoTkfxCIx6MwnF1BOkT4Sck Nb29BprbCcMdC9qTqhwoKaH4uFtC3MupreFuNkCc6dx0aUZ+C0dVKoDgvVua8E7+azsK 43hWUIUqWMwdkjVUa+JMD3y0zfenTYLaY8zXHTGVBKOgAEGdaDg1Bu2VHGTPqEkcCTY8 U9jEeTJ0iHQnG/PipOizClxnvUPL13Bq+7IyDZU8227IZyMTgTZLTRUU24NGwRdSZ3el gAxV1fOdq6UODX92elD+xNeWYU1JdYqsts1FzR5YFZx6yccBEGxluYSZbQFOMlNg6987 HQkg== 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 gz10-20020a170906f2ca00b009886b606a71si9767336ejb.696.2023.07.14.20.48.19; Fri, 14 Jul 2023 20:48:42 -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 S230146AbjGODbq (ORCPT + 99 others); Fri, 14 Jul 2023 23:31:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjGODbh (ORCPT ); Fri, 14 Jul 2023 23:31:37 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EB753A97; Fri, 14 Jul 2023 20:31:36 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R2v1q5TclzNm9v; Sat, 15 Jul 2023 11:28:15 +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, 15 Jul 2023 11:31:33 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v2 5/7] perf evlist: Skip dummy event sample_type check for evlist_config Date: Sat, 15 Jul 2023 03:29:13 +0000 Message-ID: <20230715032915.97146-6-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230715032915.97146-1-yangjihong1@huawei.com> References: <20230715032915.97146-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771456873196304336 X-GMAIL-MSGID: 1771456873196304336 The dummp event does not contain sampls data. Therefore, sample_type does not need to be checked. Currently, the sample id format of the actual sampling event may be changed after the dummy event is added. Signed-off-by: Yang Jihong --- tools/perf/util/record.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 9eb5c6a08999..0240be3b340f 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -128,6 +128,13 @@ void evlist__config(struct evlist *evlist, struct record_opts *opts, struct call evlist__for_each_entry(evlist, evsel) { if (evsel->core.attr.sample_type == first->core.attr.sample_type) continue; + + /* + * Skip the sample_type check for the dummy event + * because it does not have any samples anyway. + */ + if (evsel__is_dummy_event(evsel)) + continue; use_sample_identifier = perf_can_sample_identifier(); break; } From patchwork Sat Jul 15 03:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 120743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp4368vqt; Fri, 14 Jul 2023 20:58:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlGsh5D8zRwELtmozBdHPOx+fIc/+4UULa3oTc8sIt4miV6olQtQJaagFfrBT09+73xJ3XqV X-Received: by 2002:a17:906:7786:b0:993:d8be:53f5 with SMTP id s6-20020a170906778600b00993d8be53f5mr6018274ejm.14.1689393491574; Fri, 14 Jul 2023 20:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689393491; cv=none; d=google.com; s=arc-20160816; b=D9OurC44qqSoIBePclbmvZGySob3Brrb/aHH+j+iEPla4bfYdoqsTzSrzzJY6DpZCf CkhtjunWE2lPGqugAZmhn0T4V6hIK0761Vv+jKHxzlzqxQqlMkc3XABS9SA/eI/gLwto hwgBdL+L/xeoGknRunUZ/8b2cKOa3BKdtwZV1p/iIncNEC8IDBcd5FC6809CSSK09HRT hO8obI4UOlRNlkDUT3OesnJ1xbgH/jILXvAKuvEs1UXnjO5WS9YkTZ5tBZunlTi/gRnG HEnAyqUsliZ4qwFTxEDoW42HsgWIJXnizLJAEPXwOLnhiKl7bk+nESNv+0DqQjIBvXWV t+IA== 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=IatdIuDm32S+jI7u2TTnbDbca96AqMuozFPWM3DhnF0=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=wA2PPI/6epbI6WYmmjzWzvRYC1l/fYZWKmQZhmrMvuLJ3BYeR6B6d/p2NWUPKCatto UaxsLDO+ItRYx23Ej6TtImTiDsijQ2z18YwW7F40mSEKBlUEideuP5uSiU1iSDz9rczt GkKJqSNwtEd3qUxD1lmMSeyJPG4T9j3Syt5LW7t2hmTsHZUEEmw6sD2mm4i3PJ3q5PCU W5SROpvPcJRqB9TMlmFfImxbeB216K/hjdl4X16a8ej/PyzNve4zdB+MUejz2RBfaKl1 gV8Y6Lg944CYjwzXBKcKpo9KOcBA8qr1o7j2CHVhXmr+MTyIkQ1o5+jMT5lOz9ZWwtnt ssAA== 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 j15-20020a50ed0f000000b0051e05151467si9858616eds.224.2023.07.14.20.57.48; Fri, 14 Jul 2023 20:58:11 -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 S230235AbjGODb7 (ORCPT + 99 others); Fri, 14 Jul 2023 23:31:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjGODbh (ORCPT ); Fri, 14 Jul 2023 23:31:37 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C87B43A99; Fri, 14 Jul 2023 20:31:36 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R2v492nYMzVhkT; Sat, 15 Jul 2023 11:30:17 +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, 15 Jul 2023 11:31:33 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v2 6/7] perf test: Update system-wide-dummy attr expected values Date: Sat, 15 Jul 2023 03:29:14 +0000 Message-ID: <20230715032915.97146-7-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230715032915.97146-1-yangjihong1@huawei.com> References: <20230715032915.97146-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771457469980824604 X-GMAIL-MSGID: 1771457469980824604 The perf record uses evlist__add_aux_dummy() instead of evlist__add_dummy() to add a dummy event. The value of attr needs to be updated. The perf test result is as follows: # ./perf test list 2>&1 | grep 'Setup struct perf_event_attr' 17: Setup struct perf_event_attr # ./perf test 17 17: Setup struct perf_event_attr : Ok Signed-off-by: Yang Jihong --- tools/perf/tests/attr/system-wide-dummy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/tests/attr/system-wide-dummy b/tools/perf/tests/attr/system-wide-dummy index 2f3e3eb728eb..69f61f3271cc 100644 --- a/tools/perf/tests/attr/system-wide-dummy +++ b/tools/perf/tests/attr/system-wide-dummy @@ -9,8 +9,8 @@ flags=8 type=1 size=136 config=9 -sample_period=4000 -sample_type=455 +sample_period=1 +sample_type=199 read_format=4|20 # Event will be enabled right away. disabled=0 @@ -18,12 +18,12 @@ inherit=1 pinned=0 exclusive=0 exclude_user=0 -exclude_kernel=0 -exclude_hv=0 +exclude_kernel=1 +exclude_hv=1 exclude_idle=0 mmap=1 comm=1 -freq=1 +freq=0 inherit_stat=0 enable_on_exec=0 task=1 @@ -32,7 +32,7 @@ precise_ip=0 mmap_data=0 sample_id_all=1 exclude_host=0 -exclude_guest=0 +exclude_guest=1 exclude_callchain_kernel=0 exclude_callchain_user=0 mmap2=1 From patchwork Sat Jul 15 03:29:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 120742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp4351vqt; Fri, 14 Jul 2023 20:58:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlFxmCHK5sPrFRnET2MUxNzCkkkX1HEjc6REvXAjxWq+aBIt+GaOKNaGbiQh+oEja416ITg/ X-Received: by 2002:a17:906:3a19:b0:991:c566:979 with SMTP id z25-20020a1709063a1900b00991c5660979mr4758449eje.36.1689393486980; Fri, 14 Jul 2023 20:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689393486; cv=none; d=google.com; s=arc-20160816; b=BAr9CiJwcDHfOo79JMfNcYP/JgzpP1L/SwchAbyoDuenbtxcGZTV9+NxojTH3L+4+t lkSPwNm7dRUc+6z03bVQtAZwXhru71GqH7rhKvfOZVFSnXGyMif3v1eTnzSlRYJebOBB HmC0mWgTB/iq7nUH9wJDyGhbUO5ozhwDGCwBrnmUPHal/omQmWL4J6fTRE0a8BpCxv7X lXw6kjETeSPXgvH8YOlFp9Tcyd/5dSUH3CemYWAXEAKgkrD/WT193W59dyY0qcw1WPgz KakgFwE1bxZHXF1iITnyOPZWY0W8l5jWYBRDoglLQw7sk8YLmoTGsioua+2Yf209LcLz dhGQ== 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=U7/nH6h+1TtIa5MrmS1IezEGgpmVONO1g4fV6/3NCiw=; fh=Ib1wi7jRbo+eNDLEErvWCJx+cnUm87PkGFthhdFf08Y=; b=XkLsEHVatzyNNYigrphwLOD/OYQT3qdQ3WwvksNH23crSdrxQkN8qTnwhN93lPU40V k2WsN/JruYCh9DFy8IH/0LJk3TV/gYlZENNO7h9pZ2gbwSqW3xISZl6Kr/7QTmQDuk4A HONDSOIRcxzS5SP5cEpM6lWn1Ulu8/YHRV2pMETvv0Z1Vu9k1hkM+ypRLlJ/urM/9L4U FGoDJ8xxwNYW2hu+Sb3hFWYgD6+JwsEP8mU29k7p8hAacysdnJBvDqtOgKMTR823uBnW B9SCXQkU21Tcawsd1jhzeC0YSfSh5aC+R6rc/A34mF5csbeW+8jAjJ2Z69FpA3nIjZ8n my4A== 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 o19-20020a17090637d300b0099300425125si10020076ejc.89.2023.07.14.20.57.43; Fri, 14 Jul 2023 20:58:06 -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 S230079AbjGODcF (ORCPT + 99 others); Fri, 14 Jul 2023 23:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbjGODbi (ORCPT ); Fri, 14 Jul 2023 23:31:38 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715EB1BF9; Fri, 14 Jul 2023 20:31:37 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4R2v4x0KFyz18LrJ; Sat, 15 Jul 2023 11:30:57 +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, 15 Jul 2023 11:31:34 +0800 From: Yang Jihong To: , , , , , , , , , , , , , , , CC: Subject: [PATCH v2 7/7] perf test: Add test case for record sideband events Date: Sat, 15 Jul 2023 03:29:15 +0000 Message-ID: <20230715032915.97146-8-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230715032915.97146-1-yangjihong1@huawei.com> References: <20230715032915.97146-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,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771457465259595273 X-GMAIL-MSGID: 1771457465259595273 Add a new test case to record sideband events for all CPUs when tracing selected CPUs Test result: # ./perf test list 2>&1 | grep 'perf record sideband tests' 95: perf record sideband tests # ./perf test 95 95: perf record sideband tests : Ok Signed-off-by: Yang Jihong --- tools/perf/tests/shell/record_tracking.sh | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 tools/perf/tests/shell/record_tracking.sh diff --git a/tools/perf/tests/shell/record_tracking.sh b/tools/perf/tests/shell/record_tracking.sh new file mode 100755 index 000000000000..44fc0af92f81 --- /dev/null +++ b/tools/perf/tests/shell/record_tracking.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# perf record sideband tests +# SPDX-License-Identifier: GPL-2.0 + +set -e + +err=0 +perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) + +can_cpu_wide() +{ + if ! perf record -o ${perfdata} -BN --no-bpf-event -e dummy:u -C $1 true 2>&1 >/dev/null + then + echo "record sideband test [Skipped cannot record cpu$1]" + err=2 + fi + + rm -f ${perfdata} + return $err +} + +test_system_wide_tracking() +{ + # Need CPU 0 and CPU 1 + can_cpu_wide 0 || return 0 + can_cpu_wide 1 || return 0 + + # Record on CPU 0 a task running on CPU 1 + perf record -BN --no-bpf-event -o ${perfdata} -e dummy:u -C 0 -- taskset --cpu-list 1 true + + # Should get MMAP events from CPU 1 + mmap_cnt=`perf script -i ${perfdata} --show-mmap-events -C 1 2>/dev/null | grep MMAP | wc -l` + + rm -f ${perfdata} + + if [ ${mmap_cnt} -gt 0 ] ; then + return 0 + fi + + echo "Failed to record MMAP events on CPU 1 when tracing CPU 0" + return 1 +} + +test_system_wide_tracking