Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp639590lqd; Wed, 24 Apr 2024 12:15:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWr2THoMfgAGn+9NhdRNs2ICUdTuqRbA7jDnmPe6qRO+UL+EorwObqiFm9s7o0Z7H9cshNwYcNZBdMZEjEbzbCsslfccXmx3RwLBjMI2Q== X-Google-Smtp-Source: AGHT+IFCfJChydhTIkMVQz54aQbvNpZXYwlCfqbg2BfUSn9if6vuCfkXO6dfp64lv21y8dYzwOLx X-Received: by 2002:a05:6a00:2e18:b0:6ed:d68d:948a with SMTP id fc24-20020a056a002e1800b006edd68d948amr4241573pfb.23.1713986102840; Wed, 24 Apr 2024 12:15:02 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c10-20020aa7880a000000b006ed4a9726besi11657299pfo.295.2024.04.24.12.15.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 12:15:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-157557-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157557-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 82299B26CB5 for ; Wed, 24 Apr 2024 18:50:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 670401B7FD; Wed, 24 Apr 2024 18:49:53 +0000 (UTC) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 690A8179BF; Wed, 24 Apr 2024 18:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713984592; cv=none; b=KWyof0badTgyVxuBmJB5l46Pe0eg3WGyVo94Xo84hjSl1jhKrt00ZT0fX/KHlVj47VR3wl7mMo0pXKyRBAsuE6TNbAg396kkF4PDers9lr7b3Tv25qhetohgsHZEJHH6CinZIQp1QVfNylQWfT19mPuaIfab/ZO98S3SHe6u89s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713984592; c=relaxed/simple; bh=Se3HNVOOvek+2e5idqqauLlkJtRHfOv4B49/Rn+eoU4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=V5i3foWig1D+kbGjgMfmSIBBaxQ1TCjOeKR8sYY6VvmnfE+BRkgco2vdRsFxuRNggywsVTsi9raxXuzJZibatjmTqIkUdaHs4CQkziBEn3xucZr7ERKCgJDUYMY4kSoFs0LyUF1GhuN3YW9raJby0nuAXSTiME1f42SGEKgaPzQ= 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.44 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-f44.google.com with SMTP id 98e67ed59e1d1-2ac16b59fbeso219172a91.2; Wed, 24 Apr 2024 11:49:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713984591; x=1714589391; 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=N5QHrMtqSSrREwVmCam6Iu7SXQsyGFb2T7UApJWOjbw=; b=hdXH+6eRUWqt4S9ZJUJMi/JmSGYxOzDrlimpE48aDqmTCxmWI6D1YeOP0idz69wa/t 2c9TW23/XFhLoSx3CDX0Q8r3pXpUaRAEhghWc0sglIpWseCWgk/USR5baiw87knNRNIX wBhe/FdurgN6FhYq4O41hR10AtUBbetuQEbYB5rfN2lq0NZ0IFYhhBo1FsEzko61L7xw DQwxrcXkeBWgmrMv4PXTWOV5F1Rjq5leGh7e7FlBcswwYYknYGbaf5ceIldtiewMpl/Q Tz7Im/LsGUz4ONrrvu9FeckkETymj2WAs2IAyCCB3U+62qZxyBc9EOoGES3biGnbTZfv VMFA== X-Forwarded-Encrypted: i=1; AJvYcCVyV+Nh2lP7GiRAetY6a6IWA+RNc3eZrgAzX8RkufPq0kfiLGFGSFIcSJbNBnm0iI1lEZBZxFOlWRJB1grzNDMlhPNc+bbTd9S4rSBaZtainGN0CgWc9S84tRJ1fqoFIIwmG6XlPwYGVzMH3AZqAw== X-Gm-Message-State: AOJu0YwO7uggvEA5aDPmusmscPvMObOjz6F3ftaUDlF4jRj+pRwzYSyC Gro5O95SMZAtFzRQnrjmwq10F9D1Y7+zMrrXIdgfg3/HIPQOwCwHQwrQ0yXs9nJfvqTcFys9LbE CPMoq6UjfyNH3VMeeNoOb3XzfN+c= X-Received: by 2002:a17:90a:4585:b0:2ad:e004:76e6 with SMTP id v5-20020a17090a458500b002ade00476e6mr2986780pjg.7.1713984590588; Wed, 24 Apr 2024 11:49:50 -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: Namhyung Kim Date: Wed, 24 Apr 2024 11:49:38 -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: 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 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 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 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_request= ed_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 sampli= ng.\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 (des= pite the > > > > > > 'perf stat record'). If it's only Intel thing and we don't hav= e 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 mentio= ned > > > > > that put code in arch directory could potentially cause other bug= s. > > > > > So I'm wondering if we could keep this code here for now. I could= 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 bugs. > > > > > > 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 be tr= iggered 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 usual.= So I think > existing metric tests should work for it. > > If we want to add a fake metric uses the :R modifier for those platforms,= the metric > should either fail (if the fake metric uses an event not exist on the tes= t platform) or > return all 0 retire latency data. > > So, I'm not quite sure what we want the fake metric to test for. Maybe we= could > continue using existing metric tests to ensure all the defined metrics wo= rk 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. Thanks, Namhyung