Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp32524lqp; Mon, 10 Jun 2024 17:09:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/IH8DDQCooJCyIjSK+klXLw2wXurgoLwE3TbGMSXLgz1QqC/Y728dUjtkk9z9MUTNj7brBfqAtopUsLNjdwkoUBDh/RgF9jZHEnwqeg== X-Google-Smtp-Source: AGHT+IF4A5y3oPn4fB6/Uniboj0ghWw4egLDF6l/LSf0RnJpHqX7ZBGwWlBEXslFN9H32eWkOmLn X-Received: by 2002:a17:90a:df8d:b0:2c2:e9e5:2d33 with SMTP id 98e67ed59e1d1-2c2e9e52ef4mr6499339a91.9.1718064585268; Mon, 10 Jun 2024 17:09:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718064585; cv=pass; d=google.com; s=arc-20160816; b=Cyle0IlEE5q/rlajgz9KFthzPEuFwtVBKqt3ehWwfCzMQ6WqhHrl1xSljml/C0xNeY sr/NaidJKXwlEIRtcJPKBSIlxvVvVaVSWUYx42mXbjeZTDeqz4n2ukjPQEvkNyrDFNZy UdJ+Yqf2t31fegAL+kH2a0A8kBuPiY4aBtzJYV7x4zpztsBEdbvfr6LstaNnSaPVRWmj 0thntEqR7ecVzPPOEcOteS4pAz5udSQx7Iau1t/FvqeVtPTEvcbL0FW4WTaU4wIiknoV LmaBWwekTazCIHCMrVQDyjvCOOrA7DetK8Kx6JE8Y+yGRWOJM3rWApN6UNyDhlT5swcJ 6xeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=I2jIrTMKDgV9G7GG8QlfbjW/5ZX8c6sUSrjjHwt0sj4=; fh=GUV9yTLv+nAGG6pS0gAzVwki03NMqizMupZ2FVDodeE=; b=uqId7k9/2f74F+VUbgoWPUJTIe6vXfgTVjLfrWylvXH7PH7SWRBtpZR5EMd5OTJ2Q6 TzKIzn5h5yHKiK4OJa1BGJ1RgOjRgbgm1J1dGLF0n5YUK+iRq4fu5ycyOSprtIjSQxia zHn1bl+hBmV0UtAiASjZNKf1lTXqXtQRoyNg5YP6aUHgoBmsHJYkpbM02BbcPkGZxxbf IesX4103jD6HOAIEeG+jqx74elPZ3bXLJVH33HAN8exUfHtl5e73L+SP6MeRrQzBO/W4 wkMcMfyECuBiLzd0kbdULcgjbXUVTf5Y+UAXXgiMFkcvQaMQuAQTBRiDK2opqXx9WQEc sG/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GaAhs4eC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-209106-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209106-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6f099efeda9si2619335a12.285.2024.06.10.17.09.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 17:09:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209106-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GaAhs4eC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-209106-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209106-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D0482281707 for ; Tue, 11 Jun 2024 00:09:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2286F167D91; Mon, 10 Jun 2024 23:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GaAhs4eC" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64EAD1667CE; Mon, 10 Jun 2024 23:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718063938; cv=none; b=dw11Wju8P4Jg60bym9N3vfugAz/wVSm7ptRVGn1YBUuHa2Ij403L2TmtonbcT/RXWdBiCpeIscAFmvJJ3heniH6m2JxCtXvwdHE4+OlhhHhMp/ES0hiF0u+chKQHwm8X10ypmcct0YMdNfyZ6gqjvLDcqjh4ZR1ZDdnhZbW+qiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718063938; c=relaxed/simple; bh=TMd9ShYqXLeevvMtmc025xx4ND5vCFYKY163BbYiDQk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k2u2/DYn3/xOBEFzSCAm3xixKX9UdBLqibS2EmBieBjvIEpaEeu/cEyNtVGQScRydXNX+JB2U6TfFXFzQnvnQo8r2srS/c8q71inkKs6OQ3wOfUUNYmdK74V5JA04zy7Y6mVk4M/LQb7a/Wa0m7Ce7X4U2vYrFSTpIflcKMdtCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GaAhs4eC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B833C2BBFC; Mon, 10 Jun 2024 23:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718063937; bh=TMd9ShYqXLeevvMtmc025xx4ND5vCFYKY163BbYiDQk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GaAhs4eCThrvSd04FwUkG/bwBIcHs+7/sOiGosfwJrtSzlG9OnTd54sUA0Dufw7IB PRrXr3pnvSyHCkzwvzvURpoC+m95gdK10lgNQbdb0tM1AVoxwoOj42FXCGve6b5l3I zP5JxNwaapH3H1r+afZqniAuZh+1yQtmS+uoa4QsdGsDrfA5lvOncB5PW1p3g2Eoo9 l3yBC7MgTtZIX4hEFws/Eu2VrLk41RBSPDleXjSyhTmxIeqtZS6vd8mVxb+74Fg0P7 SXkGZrb/a8mBecKi6rxqi38o5qMxgraiuqJqyf3tKYRb3xann34IQC39W6HIfd/FY6 N/6xPzq+d92Xg== Date: Mon, 10 Jun 2024 16:58:55 -0700 From: Namhyung Kim To: "Wang, Weilin" Cc: Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , "Hunter, Adrian" , Kan Liang , "linux-perf-users@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Taylor, Perry" , "Alt, Samantha" , "Biggers, Caleb" Subject: Re: [RFC PATCH v11 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric. Message-ID: References: <20240605052200.4143205-1-weilin.wang@intel.com> <20240605052200.4143205-4-weilin.wang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Sun, Jun 09, 2024 at 03:02:21AM +0000, Wang, Weilin wrote: > > > > -----Original Message----- > > From: Namhyung Kim > > Sent: Saturday, June 8, 2024 7:28 PM > > To: Wang, Weilin > > Cc: Ian Rogers ; Arnaldo Carvalho de Melo > > ; Peter Zijlstra ; Ingo Molnar > > ; Alexander Shishkin > > ; Jiri Olsa ; Hunter, > > Adrian ; Kan Liang ; > > linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Taylor, Perry > > ; Alt, Samantha ; Biggers, > > Caleb > > Subject: Re: [RFC PATCH v11 3/8] perf stat: Fork and launch perf record when > > perf stat needs to get retire latency value for a metric. > > > > On Fri, Jun 07, 2024 at 08:45:13PM +0000, Wang, Weilin wrote: > > > > > > > > > > -----Original Message----- > > > > From: Namhyung Kim > > > > Sent: Friday, June 7, 2024 12:20 PM > > > > To: Wang, Weilin > > > > Cc: Ian Rogers ; Arnaldo Carvalho de Melo > > > > ; Peter Zijlstra ; Ingo Molnar > > > > ; Alexander Shishkin > > > > ; Jiri Olsa ; Hunter, > > > > Adrian ; Kan Liang ; > > > > linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Taylor, > > Perry > > > > ; Alt, Samantha ; > > Biggers, > > > > Caleb > > > > Subject: Re: [RFC PATCH v11 3/8] perf stat: Fork and launch perf record > > when > > > > perf stat needs to get retire latency value for a metric. > > > > > > > > On Fri, Jun 07, 2024 at 01:07:12AM +0000, Wang, Weilin wrote: > > [SNIP] > > > > > > > @@ -2186,6 +2240,9 @@ static int evsel__open_cpu(struct evsel > > *evsel, > > > > > > struct perf_cpu_map *cpus, > > > > > > > return 0; > > > > > > > } > > > > > > > > > > > > > > + if (evsel__is_retire_lat(evsel)) > > > > > > > + return tpebs_start(evsel->evlist, cpus); > > > > > > > > > > > > As it works with evlist, I think it's better to put this code there. > > > > > > But it seems perf stat doesn't call the evlist API for open, then we > > > > > > can add this to somewhere in __run_perf_stat() directly. > > > > > > > > > > > > > + > > > > > > > err = __evsel__prepare_open(evsel, cpus, threads); > > > > > > > if (err) > > > > > > > return err; > > > > > > > @@ -2376,6 +2433,8 @@ int evsel__open(struct evsel *evsel, struct > > > > > > perf_cpu_map *cpus, > > > > > > > > > > > > > > void evsel__close(struct evsel *evsel) > > > > > > > { > > > > > > > + if (evsel__is_retire_lat(evsel)) > > > > > > > + tpebs_delete(); > > > > > > > > > > > > Ditto. > > > > > > > > > > Hi Namhyung, > > > > > > > > > > I hope both this and the one above on open could stay in evsel level > > because > > > > > these are operations on retire_latency evsel. > > > > > > > > Then I think you need to remove the specific evsel not the all tpebs > > > > events. > > > > > > > > > At the same time, a lot of the > > > > > previous several versions of work was to move TPEBS code out from perf > > > > stat to > > > > > evsel to make it more generic. I think move these back to > > __run_perf_stat() > > > > are > > > > > opposite to that goal. > > > > > > > > Oh, I meant you can have the logic in utils/intel-tpebs.c but add a call > > > > to tpebs_delete() in __run_perf_stat(). I think it'd better to keep it > > > > in evlist__close() but we don't use evlist__open() for perf stat so it's > > > > not symmetric. :( > > > > > > > > Anyway, all I want to say is that tpebs APIs work on evlist level. So I > > > > think it's natural that they are called for the whole list, not for an > > > > event/evsel. > > > > > > I think we're trying to work at evsel level and open(remove) or close one > > > retire_latency evsel at a time. In addition to that, we put all the required > > retire_latency > > > together in one perf record launch in order to reduce overhead to fork > > multiple perf > > > record. I hope this makes sense. > > > > Well.. I think we can do something like this in the current code. > > > > __run_perf_stat(): > > ... > > > > tpebs__start(evlist, target); > > > > evlist__for_each_cpu(...) { > > if (create_perf_steat_counter() < 0) { > > .... > > > > instead of doing it in the evsel__open(). What's the issue with this > > approach? > > This is basically how tpebs__start() was invoked in v9 (https://lore.kernel.org/all/CAM9d7ci7tgjR8LVNx+ZrFKMGo+OZn=eFSksPL56MeP_Q84PkMw@mail.gmail.com/) > > I changed it in v10 so that it works at evsel level. > > Ian, could you please let me know what do you think about this? Ok, we sync-ed offline and agreed to have it in evsel level. I still think it's better to handle it in evlist level (at least for TPEBS) but unfortunately we don't use evlist__open() consistently and there are places it's not called. Probably we need to convert the all call sites to open evsel to be from evlist__open() then move tpebs__start() there. Thanks, Namhyung