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 */