Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3114391lqo; Tue, 14 May 2024 23:07:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXni/LubmM7hT37fxG2ez7vvE+BIS+eYYLReUidCRaNtt2qb8YkhEbuxJYFi90FMSMb1cy08x3rPRdmxGUhXGSkn+zsC5vRhD3DSGm3KQ== X-Google-Smtp-Source: AGHT+IHhEgkcuxmojgkXwoZKAliStlkF4bXqpUG6DgiIVsJjFLSKvP3F1jicL7p0W8mWOJ5GpRK7 X-Received: by 2002:a17:903:18e:b0:1eb:e89:62e0 with SMTP id d9443c01a7336-1ef43d08ce2mr182464345ad.14.1715753248357; Tue, 14 May 2024 23:07:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715753248; cv=pass; d=google.com; s=arc-20160816; b=hhDMpp7LB1ygY9RP3Q4oJCkMfNo9TkLVgWHvTuo3pkIsWjOARzNkpWWfYdll9nuQdx l1pVz0JiZmuPGG36h3F5vnIBOYlwrahqGlZlq2dq1dO9yTjACJw0QzXlgQ4eXQXHJDQn XpNpfPjQyK2711KS07ssTF090iXEUkk3Pr2sYSwvMngxFUsRRRFXMkfafpYvWog2AVlV ExSl1kCcOSuAQ5OUF+216lYICaGYnEa4EQB+PfkgHLr71GI4fgnrfDr1RnhMtpClg9b7 H592NxxwJQc7+9wOAjEjbO5o6npoFlZ7WizN38JS3R/17b4BN/N/ahZXyb9YHgmsDD3q Thow== 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:dkim-signature; bh=sw46tNmLyy6/gqhuKbv79aER+4CQjoFXDtqPExJDGXQ=; fh=I64YNcJtiOu2lYRo2wamLbzjSeglyR2Vyrt7SdxTXlA=; b=u8zfwwzuP+BgNc0l3iHHykD3nxziJfEBkWiyk7bmyt/Jz+Tv+umzZomRIoBCfgq3SZ 39nzN09vX2/M/TjGcxwT72ta4XO0JmTBhD57Xq3eTcQPbQ5H1FLCBcmjacAaosq/OLhY ScLHeP1UKjBkuLfAFGhdu6ARdpEBF81MgKpTld4bmuJbJ5vvfuCTrxl3Bepz0YOMqWyA jm5VvQDFPFQB0rxUn6pPr9Jcrp7/Nvcaq67+yu9/BT63Ko30Rs8o2YSFUye+HBF2fb9n 9OaqKpURez3Unda8LhVA6HSA8w+EBTGAJ4taQXAavqx7MY+lK2heFsOdqrZIby1RAdPt ma4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Z5Q9dPtn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-179510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c14d072si131566995ad.503.2024.05.14.23.07.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 23:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179510-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=@google.com header.s=20230601 header.b=Z5Q9dPtn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-179510-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179510-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 7A34A2833D8 for ; Wed, 15 May 2024 06:07:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A88DD3BBC1; Wed, 15 May 2024 06:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Z5Q9dPtn" Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 C415B3A8E4 for ; Wed, 15 May 2024 06:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715753221; cv=none; b=OoYFT6r8bIMRBnEvoZuEu8UTgEiiCQB5w7DZaNAVP/nFGNVMgMbHBhVxo6tdQTZOKuCg3snDwbQVYBpyFZ6pW2CBYc/HODKPcglaKKr35BqD8pjWtOW5hXCs7YOCMtiKW6GkrWthyfpvjz2rf6x+1l4kxt4xIxdX5dp9tXBB5fo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715753221; c=relaxed/simple; bh=kUL4zZYBA6Zz37ENPOn7eSbSBL2HQB6Dt7zdYhhamFc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BtQ1IksZjV6rErwZ4myy3DR1wMuZYcNG/HNljd8HMMoA5t56BcwEDdeSjiznS8Lc9+4Pc92IK//lm0uMjdpkQBmsORTgqWG+rqyXEr/BQBq+D/u+Ofiju0yd8AYQkQkJQSj6H77ENmHdo9t5gW1WBnsfJ0ko6TpncUyL2UBnYlo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Z5Q9dPtn; arc=none smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-43dfe020675so1814701cf.0 for ; Tue, 14 May 2024 23:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715753219; x=1716358019; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sw46tNmLyy6/gqhuKbv79aER+4CQjoFXDtqPExJDGXQ=; b=Z5Q9dPtniOh6Uq2JbA8QW55FIASwF+jIR6xza9a23e1XGBGV3P9UFx9aSlt0m9S8A2 0ib7VJwtu3pSsbvrnACx3crX3xF4hSS1NeodyFvdoQmmekZKWv8qU2KRJKaCBG3VMd1S lBvWAqkIOddBcbrqNFpMsvVOBjv+Uyv+PA0LpIQ1f5yMQAQltuuN8uwIh479NOU0tUm/ 3UgcT/LldOatiHXqz+90t0BqEdheiqQ5t2Nm976BY2IyrWdJONA1uY7HKUqSYdKbq3TY oaSBfZ1l/imeXLctcVY3prPO25Fwwj8xXTaHbhnmxLG3rbEDTwFvV2dPBfXnyZAr7bJo P+DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715753219; x=1716358019; 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=sw46tNmLyy6/gqhuKbv79aER+4CQjoFXDtqPExJDGXQ=; b=kemIAJIZCuQLrpxyG9YpFWMbqwjdJWos+31YPzhuX1X4DCgDztai1c2wNszFEXdFcL DhcjA0Y97g8bDhk3jjU9oueYG2C6tgQV6ajBdZMMyRHxDXFOJn05eP5UWFU98lZZpmB4 OPZ0psFv/VaykRbj3h8NM+1aqOM3aDeR8jH3EzP2cCfpvcI+Bdc9XPTrdyxhLrcaNPta ItGH+NsGFS2M4uQn4T3M5ld6jaAFkG3N3mQWR86KIX7+iOT9ppVXWqMtdNIviclGlmwv lUsPnPWd5QA615G/GCrmr/Yk8sXFNH6R988vO2DNAOpM3Al8bWfssiglUxhIole756jv BAUw== X-Forwarded-Encrypted: i=1; AJvYcCXOEB3j5o/4Vo2yfqSOoILfzuP4N/BfnKjEokgips5wyBEklWPyKW5E3IPWoL9KSLzkkpUsrdyXDb+S7ayIJKjqv2jsamQLLlKQH2L7 X-Gm-Message-State: AOJu0Ywr/DGp/JrmiybhykbdjwINp+JAhaatrDxcHOQbt4Lv3Bc9p8sG j0OOQtfsyRZ5kk0zSXLINx8CmtagUpmvxrOxM7tmRWRITqLTLx1jxrDR1vXmd+ZHM0oEblLjdj1 m0hS4I0eF+wnIWOkKoTiULolQqsfOfhLxidXb X-Received: by 2002:a05:622a:2291:b0:437:986d:86f4 with SMTP id d75a77b69052e-43e09555a24mr8295751cf.22.1715753218537; Tue, 14 May 2024 23:06:58 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240329191224.1046866-1-weilin.wang@intel.com> <20240329191224.1046866-3-weilin.wang@intel.com> In-Reply-To: From: Ian Rogers Date: Tue, 14 May 2024 23:06:47 -0700 Message-ID: Subject: Re: [RFC PATCH v6 2/5] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric. To: "Wang, Weilin" Cc: Namhyung Kim , 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 Tue, May 14, 2024 at 10:57=E2=80=AFPM Wang, Weilin wrote: > > > > > -----Original Message----- > > From: Namhyung Kim > > Sent: Wednesday, April 24, 2024 11:50 AM > > 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 v6 2/5] perf stat: Fork and launch perf record = when > > perf stat needs to get retire latency value for a metric. > > > > On Wed, Apr 24, 2024 at 10:08=E2=80=AFAM Wang, Weilin > > wrote: > > > > > > > > > > > > > -----Original Message----- > > > > From: Namhyung Kim > > > > Sent: Tuesday, April 23, 2024 4:06 PM > > > > To: Wang, Weilin > > > > Cc: Ian Rogers ; Arnaldo Carvalho de Melo > > > > ; Peter Zijlstra ; Ingo Moln= ar > > > > ; Alexander Shishkin > > > > ; Jiri Olsa ;= Hunter, > > > > Adrian ; Kan Liang ; > > > > linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Tay= lor, > > Perry > > > > ; Alt, Samantha ; > > Biggers, > > > > Caleb > > > > Subject: Re: [RFC PATCH v6 2/5] perf stat: Fork and launch perf rec= ord > > when > > > > perf stat needs to get retire latency value for a metric. > > > > > > > > On Tue, Apr 23, 2024 at 3:16=E2=80=AFPM Wang, Weilin > > > > wrote: > > > > > > > > > -static int __run_perf_record(void) > > > > > > > > > +static int __run_perf_record(const char **record_argv) > > > > > > > > > { > > > > > > > > > + int i =3D 0; > > > > > > > > > + struct tpebs_event *e; > > > > > > > > > + > > > > > > > > > pr_debug("Prepare perf record for retire_latency\= n"); > > > > > > > > > + > > > > > > > > > + record_argv[i++] =3D "perf"; > > > > > > > > > + record_argv[i++] =3D "record"; > > > > > > > > > + record_argv[i++] =3D "-W"; > > > > > > > > > + record_argv[i++] =3D "--synth=3Dno"; > > > > > > > > > + > > > > > > > > > + if (stat_config.user_requested_cpu_list) { > > > > > > > > > + record_argv[i++] =3D "-C"; > > > > > > > > > + record_argv[i++] =3D stat_config.user_req= uested_cpu_list; > > > > > > > > > + } > > > > > > > > > + > > > > > > > > > + if (stat_config.system_wide) > > > > > > > > > + record_argv[i++] =3D "-a"; > > > > > > > > > + > > > > > > > > > + if (!stat_config.system_wide > > > > > > && !stat_config.user_requested_cpu_list) > > > > > > > > { > > > > > > > > > + pr_err("Require -a or -C option to run sa= mpling.\n"); > > > > > > > > > + return -ECANCELED; > > > > > > > > > + } > > > > > > > > > + > > > > > > > > > + list_for_each_entry(e, &stat_config.tpebs_events,= nd) { > > > > > > > > > + record_argv[i++] =3D "-e"; > > > > > > > > > + record_argv[i++] =3D e->name; > > > > > > > > > + } > > > > > > > > > + > > > > > > > > > + record_argv[i++] =3D "-o"; > > > > > > > > > + record_argv[i++] =3D PERF_DATA; > > > > > > > > > + > > > > > > > > > return 0; > > > > > > > > > } > > > > > > > > > > > > > > > > Still I think it's weird it has 'perf record' in perf stat = (despite the > > > > > > > > 'perf stat record'). If it's only Intel thing and we don't= have a plan > > > > > > > > to do the same on other arches, we can move it to the arch > > > > > > > > directory and keep the perf stat code simple. > > > > > > > > > > > > > > I'm not sure what is the proper way to solve this. And Ian me= ntioned > > > > > > > that put code in arch directory could potentially cause other= bugs. > > > > > > > So I'm wondering if we could keep this code here for now. I c= ould > > work > > > > > > > on it later if we found it's better to be in arch directory. > > > > > > > > > > > > Maybe somewhere in the util/ and keep the main code minimal. > > > > > > IIUC it's only for very recent (or upcoming?) Intel CPUs and we > > > > > > don't have tests (hopefully can run on other arch/CPUs). > > > > > > > > > > > > So I don't think having it here would help fixing potential bug= s. > > > > > > > > > > Do you mean by creating a new file in util/ to hold this code? > > > > > > > > Yeah, maybe util/intel-tpebs.c (if it's better than arch/x86/...) ? > > > > > > > > > > > > > > Yes, this feature is for very recent Intel CPUs. It should only b= e triggered if > > > > > a metric uses event(s) that has the R modifier in the formula. > > > > > > > > Can we have a test with a fake metric so that we can test > > > > the code on non-(or old-)Intel machines? > > > > > > All the existing metrics in non-(or old-)Intel CPUs should work as us= ual. So I > > think > > > existing metric tests should work for it. > > > > > > If we want to add a fake metric uses the :R modifier for those platfo= rms, the > > metric > > > should either fail (if the fake metric uses an event not exist on the= test > > platform) or > > > return all 0 retire latency data. > > > > > > So, I'm not quite sure what we want the fake metric to test for. Mayb= e we > > could > > > continue using existing metric tests to ensure all the defined metric= s work > > correctly > > > in each machine under test? > > > > I think it's ok to return all 0 retire latency for fake tPEBS metrics. > > It's just to verify the background record + report logic works ok. > > Hi Namhyung, > > After think more about how TPEBS and metrics work, I feel should discuss = more > about defining a fake TPEBS metric in unsupported platforms. > If we'd like a add fake metrics, where should we define and store these m= etrics? > Should we add this type of metrics for every platform? All the official m= etrics > we publish are defined by architect and stored in JSON files under separa= te > directories for each platform. I think it is not a good idea to place fak= e metrics > together with real metrics. Could you please let me know if there is any = other > method to define fake metrics for testing? We do put fake events/metrics in the "test" arch: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/pmu-events/arch/test/test_soc/cpu/metrics.json It is something of a pain bringing things here over to the NO_JEVENTS=3D1 (ie no python) empty-pmu-events.c file. I agree on not wanting to pollute real metrics with test metrics, we currently just use the test metrics to fake up some expression parsing tests: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/tests/pmu-events.c#n811 Thanks, Ian > Thanks, > Weilin > > > > > Thanks, > > Namhyung