Received: by 2002:a05:7208:2202:b0:86:316c:7444 with SMTP id s2csp678608rbb; Fri, 31 May 2024 14:40:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZV1/7F8f2us4C+t0Tm96pDzGNdPm0RT8Wl25gdzMsoAhXvkeOVpT+EKmHKU9E5DdDvH2biC2s4rRW+++3C732XVCnhVGqPcm6njQZ7w== X-Google-Smtp-Source: AGHT+IEmE8ie59Szsz9PlcNyOFVsZmwRx/noeXBafhH+GsbMeyErA62/l7wO6sfFK1RFB5lwIMh1 X-Received: by 2002:a50:999a:0:b0:56e:23db:3e87 with SMTP id 4fb4d7f45d1cf-57a363d8286mr2073605a12.11.1717191649541; Fri, 31 May 2024 14:40:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717191649; cv=pass; d=google.com; s=arc-20160816; b=MI75h6FhpQmCSdIr7isZ7nc216E47tuqMokQbs4jNOw/DSAKDAkSzEP6nI904snCrc mqDhYrXzVVNu3yoE0GP44HUrQV7l+ZDHQPnLb+EszJFacNDDlffhwlr46/B+79eu0mLj 7hwUlqcMLuEFckMVZ+gx3srZm8/2NTcoURkRhmWYxtBXX9E0UhvGUH5wE7LBf58whB15 Gpm73wLMDj0t/qRIgDZINmocwre77UL76rqnviVttoh3/SDGFN1JE36y1ceJBQLLPCHq IcpHJaeiXnz4FQQzcsfEb7ArHph1qXsstvqh/LeVK3rf+lSWRyOk3QDNIxnhR3sGIQrn Pkcw== 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=DVNjkBJYVeKrZqddtj398UOYP5tbEGwouSvGlhcZZio=; fh=SdjqqM0fenNzBlsx0sXizrHHjxLz2nkYA0r2Vp0VBUE=; b=RhH+O+iKTjYRa/D68JD6fDJlbSaNpON5C+e48xw9L0BKgdowE0hoTaRqEV5blZtrUN at8F4J5if9qn3o1YT//XXo3P0JTMn4VZygTFrjI9zxgw6E88t5wyR/dQdLpWI9pQmDqg RvABnKSGM+TAm3sojjQB849VX8uem2Yap0Jp3gUOc7wEYYXQJoiTRbl8yrmygse4lmmm YJF8O16yGJVLhYWNAycGbijqw6qEqR8MxET+zHy2SHL5UC4i6sxaMusTLZmNclsx/med 3I77QCaC/F3MUJKzDJpF9ZJ4bZpIEbyRN8YUSIzTEVtq8bBlncp0EsJFzKqgbuJ7CnEN NKKQ==; 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-197524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197524-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-57a39885f04si1023955a12.464.2024.05.31.14.40.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 14:40:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197524-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-197524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197524-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 246A71F2746A for ; Fri, 31 May 2024 21:40:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBFC882876; Fri, 31 May 2024 21:40:04 +0000 (UTC) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (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 AD8E7824B0; Fri, 31 May 2024 21:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717191604; cv=none; b=QQ2PcrNTxvQ0QWYQdMFCLoHMUJKajzFnU05vlKb0zsv9LtLl0Mhxq+cAmGI8YQq5+4qb6kxRv/fLqV9cWKPLe9CrDe81ZW/7TYNRb3VbrX2E87L0RSAb68vHd0xzNxJ+lCmDfDOzS9lpw0jOlRIX//GRfPd0iDgifKXUBgbW6M8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717191604; c=relaxed/simple; bh=PS1Zb3Ua1t3vKzQK0lFelDKo1TPa4JWNWk6dhN0bg38=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=GHHHNNDYu8VZMJNQ4IwdvclYNhZPk/k1s0KYxwmGJj2xibkFweozyNd4oqGlP55GcSG5v1P51pBPw8Q8npb3gGGRBNc3mg7kxDYg8t3bl3LPH/1ClG2xC0m4OKmTYr5zBzeAUoAhHukCJzgUOBHJ5MJd/JCOpFFkumkKklU1oHk= 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.215.177 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-pg1-f177.google.com with SMTP id 41be03b00d2f7-6c3b5c5e32cso853998a12.1; Fri, 31 May 2024 14:40:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717191602; x=1717796402; 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=DVNjkBJYVeKrZqddtj398UOYP5tbEGwouSvGlhcZZio=; b=MJJ87aEUAoyRsqd+rlEByeKFEg7O6u+rlOBkXWr2nYf98oXaOkrtlC/z2O4D2YZWiK x5uYTOKuYq6urNBNsoo8LKOpwVoYCh0rPnbHDj4atM6RNrrBidVdFRyBoJJqj1so2QW2 rg/hAP6S+hpmUevssBRW+u/ZQEMA1MH8/6Ra+HVvW1h8Msr2P9KCLMvRS0qaXIEZ4DJi ggE8uaDZ4r40BSxEGsdK2H0xOb5d0e0FXkjs3lcXs8bJZBI7saHuApInei0qdNGyDGVq Q8vwMqblvJCxgEeSmrFCR5E8tEDXHuuaUGa4tzxzhHVBZvURn+GbYGuqTyvBjwUZRfez uG5g== X-Forwarded-Encrypted: i=1; AJvYcCXR+8CM1c5VvSPN2MHqQfPZOKCD0Cr8mbMvE8Qlxo3Xv1lWMJhWo9501zvj3b9q9e1F8D3eSeZWm1p3/SqaPWsWFnXqgf35dAReRPe65SoEzNb9nwgIy4V1Am0ivD6Spg5FSK9r+Bz8tBI2WKiSCw== X-Gm-Message-State: AOJu0YyuLfdK1fabFAv3qQnHk/ReKus1DoNvwwdBntnYraxq02WGwF51 0pv0aOndAMQNxPPkYSmSui5bg7p7b/YljDk6C+1X04YkA5+yR4dXJf4cgxI3pvqTs+hq037CKoP aY38LTOS3+EeVQWb/cFApkgsRTt8= X-Received: by 2002:a17:90a:c284:b0:2c1:b88a:3a22 with SMTP id 98e67ed59e1d1-2c1dc5cd779mr2636876a91.45.1717191601678; Fri, 31 May 2024 14:40:01 -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: From: Namhyung Kim Date: Fri, 31 May 2024 14:39:50 -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: "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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 30, 2024 at 11:46=E2=80=AFPM Wang, Weilin wrote: > > > > > -----Original Message----- > > From: Namhyung Kim > > Sent: Thursday, May 30, 2024 11:41 PM > > To: Wang, Weilin > > Cc: Ian Rogers ; Arnaldo Carvalho de Melo > > ; Peter Zijlstra ; Ingo Molnar > > ; Alexander Shishkin > > ; Jiri Olsa ; Hun= ter, > > Adrian ; Kan Liang = ; > > linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Taylor,= Perry > > ; Alt, Samantha ; Bigge= rs, > > Caleb > > 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. > > > > 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 fo= rk a perf > > > record process with "-e" and "-W" options. Perf record will collect r= equired > > > retire_latency values in parallel while perf stat is collecting count= ing 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 b= e > > process > > > to get retire latency value. > > > > > > Another thread is required to synchronize between perf stat and perf = record > > > 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- > > >tpebs_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 thi= s event is > > > + * not found from sampling data (enable_tpebs_recordi= ng not 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 > > improvement? */ > > > > As I said before I think you can set t->val * 1000 and then > > set the evsel->scale to 1e3 or 1e-3. > > Hi Namhyung, > > Sorry if this is a repeated message. I thought I replied to your suggesti= on > on this last time. I'm thinking we should keep it like this for now and m= ake > this change unless we find the precision loss is critical. Because I thou= ght > we don't want to add special code to handle the calculation and final pri= nt > to keep code simple. > > I kept this comment here so that we don't forget about it. Please let me > know if you'd like me to remove it. Please see print_counter_aggrdata(). It's the generic code to print the event value and it'll display the value multiplied by the scale (default to 1.0). So you can keep precision as long as you set the scale properly (1e-3). Thanks, Namhyung