Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp258642lqh; Thu, 30 May 2024 23:42:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdXGNL6keWqNzvmaZjJW/iLWcmNjXNc2K+lsndMJmJt97WiXrYT7uqEVS0SvsLTNCsRcblGkECfXOwZRDACdhkohVCukKo+QN89mU6lg== X-Google-Smtp-Source: AGHT+IHsu44X50YXfHN1eRcbAwidD8bo2EYk/CUGUUn2Vr5WkxIsqBggM4FFGhXVoz8GxPfvpR1I X-Received: by 2002:ac2:4c86:0:b0:528:9d15:240e with SMTP id 2adb3069b0e04-52b896bfcebmr569092e87.43.1717137721702; Thu, 30 May 2024 23:42:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717137721; cv=pass; d=google.com; s=arc-20160816; b=szHLhBeuOpehymeYOZnhmZkiLEGwFx02oEAT4NZ0oPjNe7yhtvnlWXwX88nlDUqPVT +yQKp+qg5No+spTBAoJlqSIPDbFnoPeRGFvg/XvTe/QCQ1kYxvD0j6wmhKVY53b4QmFA tpn8aELaFza9S21ErAT0ZWyJlFkLaWX3ZJuSDibm2F1QITmA47gNednmFe/cLGgV1njf A1ynlf3OHf+qCksKPj4SMIdwxcs3tlYBBoaq9DNGGSk1lTwgWNsPzA+NsDnA3dHwx5V5 8LulJUg7oGkYfo5bRU4wEHq+0X8KDNhA/k9dv+iK8jeUr8ggLtRyp/bSoMEV8+WtaYep Zqwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=mu69OOs2tyNIzS9vQN8Sal9br//O/qQ7WPAbi99juhc=; fh=yWuLtXF/2kHXk+ZQSTyim6eyd29+wPq589TeO1C/QkQ=; b=fZMrx3zlqpdrUjvINwZP3ZZ5EUvJo2y3wcqLDOXxPblD0OIQe/H3A5K71r1NqVNNZd HaBHPMDEExyHDrknYnp3goy7/ZdEE1LIAtw1VYYsJIP2aqxQXJ3gvZvx5b2PO3YThyzv pkQ3UwAO5mRh1FMy8LbkFFgG67rxt3blX5XzcUwqaMHIkdfbIpcUCnIP41MZtC4mxkNS I4g+5pkjq0HilO6L47HqhgSz07TkruJnC+9xPpxCQiJraG6Oa5L7ZrcEAl18N5S7zIK2 x+oi9zUKFwYhGUtKpIycE1MZy8MAY4wI6/i1ZeVS5awT4pj38IdhMKfBRA6lYwPhc5lG NrDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-196356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196356-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c62fc5si618821a12.298.2024.05.30.23.42.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 23:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-196356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196356-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 60D651F21FB0 for ; Fri, 31 May 2024 06:42:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE08780630; Fri, 31 May 2024 06:41:07 +0000 (UTC) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEB1880029; Fri, 31 May 2024 06:41:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717137667; cv=none; b=nv1I5yD3cSNxOA/Ix4McOmiclMKYsv8u70HJLKadqG+KmFlNFcbX8xIRvqocV3WV1c5ciuB0F+EFEzzuV8jH66s9MX0mlkJFgIuEa6ewwwFGzNGU4No4vmDJVRLqxqMztPwOuKxKV+qJOTy73IiL01/h5xtP9ZWgdItFYc1/uD4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717137667; c=relaxed/simple; bh=/5AGhiPMoa8DA8+zCe5zB0MSwuL/3VLYSz1ac+hrezU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Z1y4ebeTRU23R1+rmHcLbL9upvcDH9GNJZGVa2H82VFdb1JUFfW1qxyfO1jNtt2a7V49uDjG9ffJ0W6I5ONfmmbeItLMOOBrG/e/9tLsKOo4E3pu2fqSmqymFgaZ3fzlY/l2nCpPXV+MlM94Q5na63/gZctparWviR8I4/2z4c0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2c195eb9af3so1253856a91.0; Thu, 30 May 2024 23:41:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717137665; x=1717742465; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mu69OOs2tyNIzS9vQN8Sal9br//O/qQ7WPAbi99juhc=; b=UvIH/4geRpuftQrwg/Igm6Q+WjM47UD+muw5eun2Xo5zlSbAeCtvAQnpf8inCgbP2y CJGlyWUmpcIehNLmhgyzyVpn0rco3l7VczAhFu9lILLxqocVhP7OXjpFuB9Nyn4L6UgE FivYW6NH/MkIEKIglacm3GP2TAvn3aIiThThKF1cF1aASeccC8pgw3nm7weJS/3cNOwm spTAnqQF1X7VuW9H4A5oWtZDeJvs5TZFOI0ZjnyJPWvu7BUZW2VFu3BeW3KEL0AkezTs p9IqZpcoVOlP4pVvCqd0yLBL03NPM+oJSKyOfx4vALA84ZE26RPb/U4hhshbAVpWPrfg aa2w== X-Forwarded-Encrypted: i=1; AJvYcCWTD+WxaqJod1XlXMG9y8LsqGRT0OSpb6rT9M2z1O/GO09LbShvkAque22fjOCeXZ3oBhhnVv8n6G+072o9ExA9lQfbVV0bxbPvWGL5hwSSTznSfqo7lCDI+HFAfAaIt9Hok9S02EuZSiID8EsTRA== X-Gm-Message-State: AOJu0Yw+u6W4ydzNPcCftj56Qjtzb/bWBFUGD3YHqs5hHDOKTGUyb3ge imH/pFk/yWe5+6uXAk9UQLikoifxfJK467NrI/+Fjya9pOMy2wREV6C2H8rs/EvPTlICpz0Ulky JuiWVK8yQSrjKTMuKOCeL+Ht6MUdjAw== X-Received: by 2002:a17:90a:8582:b0:2bd:e936:b28 with SMTP id 98e67ed59e1d1-2c1dc583606mr932720a91.20.1717137665113; Thu, 30 May 2024 23:41:05 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240529064327.4080674-1-weilin.wang@intel.com> <20240529064327.4080674-4-weilin.wang@intel.com> In-Reply-To: <20240529064327.4080674-4-weilin.wang@intel.com> From: Namhyung Kim Date: Thu, 30 May 2024 23:40:53 -0700 Message-ID: Subject: Re: [RFC PATCH v10 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric. To: weilin.wang@intel.com Cc: Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 28, 2024 at 11:43=E2=80=AFPM wrote: > > From: Weilin Wang > > When retire_latency value is used in a metric formula, evsel would fork a= perf > record process with "-e" and "-W" options. Perf record will collect requi= red > retire_latency values in parallel while perf stat is collecting counting = values. > > At the point of time that perf stat stops counting, evsel would stop perf= record > by sending sigterm signal to perf record process. Sampled data will be pr= ocess > to get retire latency value. > > Another thread is required to synchronize between perf stat and perf reco= rd > when we pass data through pipe. > > Signed-off-by: Weilin Wang > --- [SNIP] > +int tpebs_set_evsel(struct evsel *evsel, int cpu_map_idx, int thread) > +{ > + struct perf_counts_values *count; > + struct tpebs_retire_lat *t; > + bool found =3D false; > + __u64 val; > + int ret; > + > + /* Non reitre_latency evsel should never enter this function. */ > + if (!evsel__is_retire_lat(evsel)) > + return -1; > + > + ret =3D tpebs_stop(); > + if (ret) > + return ret; > + > + count =3D perf_counts(evsel->counts, cpu_map_idx, thread); > + > + list_for_each_entry(t, &tpebs_results, nd) { > + if (!strcmp(t->tpebs_name, evsel->name) || !strcmp(t->tpe= bs_name, evsel->metric_id)) { > + found =3D true; > + break; > + } > + } > + > + /* Set ena and run to non-zero */ > + count->ena =3D count->run =3D 1; > + count->lost =3D 0; > + > + if (!found) { > + /* > + * Set default value or 0 when retire_latency for this ev= ent is > + * not found from sampling data (enable_tpebs_recording n= ot set > + * or 0 sample recorded). > + */ > + val =3D 0; > + return 0; > + } > + > + /* > + * Only set retire_latency value to the first CPU and thread. > + */ > + if (cpu_map_idx =3D=3D 0 && thread =3D=3D 0) { > + /* Lost precision when casting from double to __u64. Any improvem= ent? */ As I said before I think you can set t->val * 1000 and then set the evsel->scale to 1e3 or 1e-3. Thanks, Namhyung > + val =3D t->val; > + } else > + val =3D 0; > + > + count->val =3D val; > + return 0; > +} > +