Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38446454rwd; Wed, 12 Jul 2023 07:49:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXr+5rHaYYbiAg1lNG2QmHnWTrK0TXtK1IZdlwZYwndd3z/pAb4Sm3yPRMUa7eh1f5iucI X-Received: by 2002:a2e:9dd0:0:b0:2b4:6f17:31f7 with SMTP id x16-20020a2e9dd0000000b002b46f1731f7mr16736639ljj.27.1689173355733; Wed, 12 Jul 2023 07:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689173355; cv=none; d=google.com; s=arc-20160816; b=AUcGr8ODKVsyUe5iKp3Z67GCpdHX55Qgn1AH78w2ggDzSjy88n/8Fo5I1wPjpNLVNt 2MyxZEJvZkGiJhhkULOPXhGLa2tD7en544oR7tClYCLaHcDSMACuHXQMvIr6M3FgbUep wvfdrn70xkPH30KxobSDhkULiL+o85euZzWwJvWQyVt5z06vArVuB/4L+p7iJRicb+cX kAXjx+Y6T4zTh1BJVEFX834PzXtyBVHcmo+Q2W1tWViK5EE2krdyib+N6eujS/bFCS/m lyBcFtfNnx9d7fm5gJzMkU1kLoMF+34Tcjivqv5Ra55/8D/lBIia34R5wOB8435BUxhs 8fGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=zR8PVcGmhJI6mFnsGoOrQQ4Dq4Ob7USPMUy1FxDGQmw=; fh=mHKvWaNSen2xS5iQ7Fn6ju1Wg3Evln+HhI3cUf5CIWg=; b=Vl81MDPywKtZvVgLqxEtxi408rClMdk9O9Ah8/su301R/Gu/T1nBVe3/bhBWeCUV3p DeGDBkzXtEPiVJXQk+I3I/Nt154VxZYMrFQDvZUgyv3MA1OrV6VcpKcARJ34B2QpXCoP LtsX2OOzRq3XbPheVIufvG6aL2mEMXpvieiLmMauA4f93ifUz5BOIh7r16Cc/Seu6jrd EZ52ICM+Zp9xVg62khMOKm4meHQ8Vs6QBI5CVZHhq1FHIPV6bOG6SmwXNYKEqqPMS4cY 2utHV8GkFNPOoRMe6pyKp7JPM+emIKGt9pHLCKvBper7k9gLulo31DWzYzIVnZ7fRjw+ iAJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rn8-20020a170906d92800b0099319803901si4188824ejb.844.2023.07.12.07.48.47; Wed, 12 Jul 2023 07:49:15 -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 S233199AbjGLOcp (ORCPT + 99 others); Wed, 12 Jul 2023 10:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233165AbjGLOco (ORCPT ); Wed, 12 Jul 2023 10:32:44 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 788081992; Wed, 12 Jul 2023 07:32:37 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R1Ks24TxHzPkB8; Wed, 12 Jul 2023 22:30:14 +0800 (CST) Received: from [10.67.111.205] (10.67.111.205) 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; Wed, 12 Jul 2023 22:32:34 +0800 Subject: Re: [PATCH 2/5] perf evlist: Add evlist__findnew_tracking_event() helper To: Adrian Hunter , , , , , , , , , , , References: <20230704074217.240939-1-yangjihong1@huawei.com> <20230704074217.240939-3-yangjihong1@huawei.com> <5882e592-641f-71cc-7a91-66f66b58d5a6@intel.com> From: Yang Jihong Message-ID: Date: Wed, 12 Jul 2023 22:32:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <5882e592-641f-71cc-7a91-66f66b58d5a6@intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.111.205] 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.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Hello, On 2023/7/11 21:13, Adrian Hunter wrote: > On 4/07/23 10:42, Yang Jihong wrote: >> 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. >> >> Signed-off-by: Yang Jihong >> --- >> tools/perf/builtin-record.c | 11 +++-------- >> tools/perf/util/evlist.c | 17 +++++++++++++++++ >> tools/perf/util/evlist.h | 1 + >> 3 files changed, 21 insertions(+), 8 deletions(-) >> >> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c >> index aec18db7ff23..8872cd037f2c 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); >> + 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..4621ddaeb8f3 100644 >> --- a/tools/perf/util/evlist.c >> +++ b/tools/perf/util/evlist.c >> @@ -1694,6 +1694,23 @@ 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) >> +{ >> + struct evsel *evsel; >> + >> + evsel = evlist__get_tracking_event(evlist); >> + if (!evsel__is_dummy_event(evsel)) { >> + /* Set up dummy event. */ >> + if (evlist__add_dummy(evlist)) > > evlist__add_dummy() does not exclude_kernel so it > will end up relying on evsel__fallback() to work in > cases where the user does not have kernel access. > > evlist__add_aux_dummy() is probably better suited. > Consequently perhaps pass system_wide as > a parameter to evlist__findnew_tracking_event() and > deal with that all inside evlist__findnew_tracking_event() > OK. These two points will be modified in the next version. Thanks, Yang