Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp91054lqd; Tue, 23 Apr 2024 16:06:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhB5zbuSYUb/q7k4jTBvfQSieow09aU4+gKLnUYkEatYsKxEsiHsYEIck0s5Rp/3N2ooqoUauJToz2GYO3g94LQaN9GNUJJPQfz1ccGA== X-Google-Smtp-Source: AGHT+IGfdMBuOc/qmbmM+bV695Es5DgAt3khrEJLcLbhSEakMqhQb1204TwKmsNdYSCmiCTv4qcc X-Received: by 2002:a05:6a00:2e24:b0:6ea:74d4:a01c with SMTP id fc36-20020a056a002e2400b006ea74d4a01cmr1271738pfb.14.1713913569965; Tue, 23 Apr 2024 16:06:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713913569; cv=pass; d=google.com; s=arc-20160816; b=WQVyjKY+0ZPTHyVHetFEKqhmom6xOLTqNsMMF5YkAHVNzeksbQmIu8vqEJLjjnEbzV 2AHJLLhDBtdc3n7Kkyv4r4tNwcVihfFLk3Y+C8KTzjGD8qPPu5LH2RMlOT/ws1pxyLga 5oHR3WtcC23EnkTw6g3xOBMLxD1PctKqaA5j0n2B406xgfnLhn1srA10pXEiS5ZIE//C KV70MdFtIP0bLkgBoG+SHjqjC4EL8v63CQovm9/8g/gWELgCfIo8n5Y4AekEUXVIJW/G YOFWTxp8D5mGGyNGJIDwBUw90w0ZujwvjGy3iO7/4NdTHtHDeRB9p8+HyhB15G7rhkm8 ieKw== 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=3fesNdAlMc+WBAKd6UgQ2Xc2bJErGlYcbaUo7uByooc=; fh=+UviBGInnxD6cHdBM0VM6x5QJ0DTlCBOpdIx+HcT+C4=; b=obcIp9MnwhEl0sPfDUk+JicwieT4NoPAwWfHnXEETZ4YUA1AdQnw8XmTAGTqGOr6za rjojMohSvdf1bnLgusvMeAo15V2wBb1gry3Et+kEKbDPyj5tYXFxShVhYe6ugycv7hgT mKvf6uCp2wBbaelIRK9/zoyFzFF6UfQSmiqsxVxHjF5FdDuoX04qZcdlTAd028HKLrY7 cEfZNreI5/6XlBaStdl7Ea896OJcLHBNRkxZtgNzYneWGjmxR7nXVLiz5CJlRyB7iOQG LIT7MucF3lSm94mcSFAo5ju1Ubh0+zKOXaunTkshs3BLQaVvGZX4rvnnzjXP4GoEASZ1 +8xQ==; 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-155988-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155988-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. [139.178.88.99]) by mx.google.com with ESMTPS id y11-20020a056a00180b00b006e6b14382f5si6929589pfa.34.2024.04.23.16.06.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 16:06:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155988-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-155988-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155988-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 E84F1286CEA for ; Tue, 23 Apr 2024 23:06:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D49C936B0D; Tue, 23 Apr 2024 23:06:02 +0000 (UTC) Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 0130B2E63B; Tue, 23 Apr 2024 23:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713913562; cv=none; b=fyvYzlIZZdMr2NeFiumAMfgkU/GBkvKrcKU7tLqTAGjX4erThPKGSHjmEfC3Ir0gmf48QqGT5KiMfJPxVSJCKwNBGg193z7piGGbp4UJ+3HO5OZwLDtULKMu24Rwn1vW4YZKznRK/MCDTeJQs/TqtckwkSWkmeuvbjEizHDT8s4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713913562; c=relaxed/simple; bh=pHxTJKih1qDRp89Nf/sFqg67Or1LrveJzBXmaE0kgic=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=kAlQjrlqpEEwNwsg+ALPi+0I5Fd78BVQXsmeG95kCJYRxpfK9VOuCG7tTph3KwwDY9SuSMxCJtkc87hchudMDGz82ANpxByEywGFYnVkHpXwYqZF6RGjfp7ppcFh6I2RnuEjZ81jCkAp8ocNiBWatm6dgDr2JIx64ZSrI1jAtdc= 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.49 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-f49.google.com with SMTP id 98e67ed59e1d1-2ab1ddfded1so5198197a91.1; Tue, 23 Apr 2024 16:06:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713913560; x=1714518360; 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=3fesNdAlMc+WBAKd6UgQ2Xc2bJErGlYcbaUo7uByooc=; b=IwWnXic0zd59+ZSG+yeVa2cwm22uGWXEJm6oP5aDuABcIR7hKSFSdtrZj9rJYPFqku if+pVqz3z7psXX02lJeTTOHgWbgmpBXFsfLwQsvoulXUG2HeimAbN5IywNjBcM64ycqs Gi85ojFmbJRQF7jszq2S2L2t3wRE0LUn44APojanFX9CAFuHUYazDSF0/0vHFNkVCE7A 4u0kmCYheo12vhqj4ORP4g/WLmhHzFYIwfeQ6EnXGdP+Z7V5xgxc1LsXDsPLdGfwbb1q V6y4//hulJrVH+vCLqf19EapphaM1l+RgjFOrezhPuR6rK89upfpitstfhZqO4BuvoC+ FA2Q== X-Forwarded-Encrypted: i=1; AJvYcCXNZbWu0JkCvcXvdp74Mp3oks/aq0F51bmia7uUU3YZLgvwBrnznnvFwYPqxbHMiTUcvaoO8BgsS703w9JCkXZK4kG2p6W69M3yfeBqHesAhkkE26ZCCrs4bvpq+yb5/MWAGKKx7lksZofAKesTYg== X-Gm-Message-State: AOJu0YzPtxYXaA3JDxxH+T9YwRFb5znQcdqfj2axyeQdSBcbRPki9bJa n3XRKszADkH28rqbK5wvR59MHaeFck2FSGKPc2tkKBCzg6qE8hmFPcn6hTzfJSvUcFPceSx7Kr9 i0WD22+Eu9g1NJLhXyoHsHuKw/Zs= X-Received: by 2002:a17:90b:30d7:b0:2ae:9a80:9065 with SMTP id hi23-20020a17090b30d700b002ae9a809065mr722897pjb.28.1713913560179; Tue, 23 Apr 2024 16:06:00 -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: Tue, 23 Apr 2024 16:05:48 -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 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_requested_c= pu_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 sampling.\= 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 mentioned > > > 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 could wor= k > > > 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 trigge= red 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? Thanks, Namhyung