Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1854874lql; Wed, 13 Mar 2024 09:55:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZKNFmnyBDoukPK7vYVAfPIcporFqUq9pz9Fb8xVwSsLYuHkHxtLIMorX6ObKFAvPfhFSm9K5d0LQoRmfxbBqhs4KpDNnOHMXe39UW7Q== X-Google-Smtp-Source: AGHT+IHfPKbVU2GaBBRjmE9bkgJXKHgDxl/kQcEEMY9+Llx6ncJ0qANv8w75UE47Iwg4GE9xDaHm X-Received: by 2002:a17:90a:d908:b0:29a:a378:ce88 with SMTP id c8-20020a17090ad90800b0029aa378ce88mr10017587pjv.27.1710348954369; Wed, 13 Mar 2024 09:55:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710348954; cv=pass; d=google.com; s=arc-20160816; b=fRqaAnPRBgOCaiY7SWKMrEK+5aKP6bvKGlQtpv/WxJpptkQrM66262j8y10lsU85zY cBoWwtD1efwvNgU4AU/12DeSoXfm+r/BtRlBPxnvVa3cvlI7B4MMDCnoMvR7tESOwaXc Mtfu2ktHOxgUbY2m7xFoGK3+fefqGYNjaWyAqv3+CADoLx1BY7PznienKx8+oCBvpbN5 o3RoJdq/44Cnt9zbf4s335gmdcEkjQJ3ssfYzk3FDQ9634/NGTo1f/caiLDoqp+fP9pe mSqfSVffqgO2kLYSvBkZFL726nzMqyeeeIJnMNDXz+vjV8fWJWICavtD7vfpED3MFLGN NsIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ziTk2VVnwSbKnG4IrC495Ce8fiBl0VJEtpYGCvaGwWQ=; fh=gKC57c3FAQ3jZQHo2BprGov1wfU8lcrLELLPe4HbuH0=; b=EILA8L5v3NX2pvLxQkFrAvjbVvQQbH6umK9vC37jl+tRtPJu2Z9NG5ZEVT5A/dI9eO 9IcNOcdzSwChQPR7lBmHHWrpKBj3omlqVYSe0cyCuglgmDPA4AducDBq26S9VwYLoUEU zAZ5W8YP1joqxC/UTZniIM2yyhcOWHZeaTXikMz5VfZ0PX+xKnSTTJ/xyLtGGwcOwabl TmfviDytsbT2kydrlQ+yG0IxLpjQP4kgrqwbnIR+gnKZm4gEviwRc7DnVzZtjoljpGjF rC0K2f10rCItg2hPDnoNq18XkEqR0t0URtf+lZ7UeTkU+UaaoKaXNSO2vn04CSDSWZrk 4v+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ext14AfK; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-101702-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101702-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id lk14-20020a17090b33ce00b0029bf25ea5absi1793701pjb.187.2024.03.13.09.55.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:55:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101702-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; dkim=pass header.i=@intel.com header.s=Intel header.b=Ext14AfK; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-101702-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101702-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AFD93B20E73 for ; Wed, 13 Mar 2024 15:55:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD6ED481AA; Wed, 13 Mar 2024 15:55:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ext14AfK" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E588446BF; Wed, 13 Mar 2024 15:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710345316; cv=none; b=cqyKS2a7S4E4q56qf6i+WQ7q+Xx2tWH/tasGu0AZMrEpMqoc4wnVajFkfQ3jDPGhw20xb0TUJg3GTHJ1ORNxs7GZjg0JCKqauHBDYLkp8KJt1hQ/9fgtMa4DLr/mda/KjUY2evT+Km1TcGk2nxSOIHMHgcp/bQKRMVMYASt3w+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710345316; c=relaxed/simple; bh=Nwk/w5uGh1hbn5empdNZ/Fn5j6qCvuoI6jaUjQjaVdo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=j2pjlxWzMg1LReeKpSuEYPH2hx11L49YtoXjo6gCsM3MgFoO8wYCklWfLAPcJ1mCh4wHDUjrNY3OGPsvtt7b2si5xZpi8KwOgZxZD7Z9czK8l+8Qb0g34TcLULi/ZGzsTdZbPz7LfcknopHpOj6C3DKXcrh24vDE5Mn9QUIK1Ng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ext14AfK; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710345314; x=1741881314; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Nwk/w5uGh1hbn5empdNZ/Fn5j6qCvuoI6jaUjQjaVdo=; b=Ext14AfK+dEHyIw0h0cZzdAe3KryXf/7djPF0IpGVEDqsrXMPfay2/b6 bwhripTpX0b+l71fD66KP8rNfTTU+B1W0j+xR+/Rh+lh2LZ46nfrvZIJ/ BqI8+LQRy1GImFzbU1a29ALrq4AwLRrqLrGlugv82Nfo5CcHlNXOf5sWo nXEz/va8itukB3XYY8ecnC1lnR/09owOToFw1x2lWFg8oUN3YQLzb+u/K ZIYwC3611lWxSFYN1BTnxuI5zoxC72AmxjybOIQeoctN59e/ze6kTlJ1D 7SRojxvzElbfFEUErUhp94R3hIdccpiqb1TrVETOaflBKmZSm/LsMYhw1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11011"; a="4987932" X-IronPort-AV: E=Sophos;i="6.07,122,1708416000"; d="scan'208";a="4987932" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2024 08:55:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,122,1708416000"; d="scan'208";a="16562454" Received: from tassilo.jf.intel.com (HELO tassilo) ([10.54.38.190]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2024 08:55:13 -0700 Date: Wed, 13 Mar 2024 08:55:12 -0700 From: Andi Kleen To: "Wang, Weilin" Cc: Namhyung Kim , 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" Subject: Re: [RFC PATCH v4 2/6] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric. Message-ID: References: <20240312234921.812685-1-weilin.wang@intel.com> <20240312234921.812685-3-weilin.wang@intel.com> <87le6nm20o.fsf@linux.intel.com> <87edcflzkr.fsf@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Mar 13, 2024 at 03:31:14PM +0000, Wang, Weilin wrote: > > > > -----Original Message----- > > From: Andi Kleen > > Sent: Tuesday, March 12, 2024 5:56 PM > > To: Wang, Weilin > > Cc: Namhyung Kim ; 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 > > Subject: Re: [RFC PATCH v4 2/6] perf stat: Fork and launch perf record when > > perf stat needs to get retire latency value for a metric. > > > > "Wang, Weilin" writes: > > > > >> -----Original Message----- > > >> From: Andi Kleen > > >> Sent: Tuesday, March 12, 2024 5:03 PM > > >> To: Wang, Weilin > > >> Cc: Namhyung Kim ; 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 > > >> Subject: Re: [RFC PATCH v4 2/6] perf stat: Fork and launch perf record > > when > > >> perf stat needs to get retire latency value for a metric. > > >> > > >> weilin.wang@intel.com writes: > > >> > > >> > From: Weilin Wang > > >> > > > >> > When retire_latency value is used in a metric formula, perf stat would fork > > a > > >> > perf record process with "-e" and "-W" options. Perf record will collect > > >> > required retire_latency values in parallel while perf stat is collecting > > >> > counting values. > > >> > > >> How does that work when the workload is specified on the command line? > > >> The workload would run twice? That is very inefficient and may not > > >> work if it's a large workload. > > >> > > >> The perf tool infrastructure is imho not up to the task of such > > >> parallel collection. > > >> > > >> Also it won't work for very long collections because you will get a > > >> very large perf.data. Better to use a pipeline. > > >> > > >> I think it would be better if you made it a separate operation that can > > >> generate a file that is then consumed by perf stat. This is also more efficient > > >> because often the calibration is only needed once. And it's all under > > >> user control so no nasty surprises. > > >> > > > > > > Workload runs only once with perf stat. Perf record is forked by perf stat and > > run > > > in parallel with perf stat. Perf stat will send perf record a signal to terminate > > after > > > perf stat stops collecting count value. > > > > I don't understand how the perf record filters on the workload created by > > the perf stat. At a minimum you would need -p to connect to the pid > > of the parent, but IIRC -p doesnt follow children, so if it forked > > it wouldn't work. > > > > I think your approach may only work with -a, but perhaps I'm missing > > something (-a is often not usable due to restrictions) > > > > Also if perf stat runs in interval mode and you only get the data > > at the end how would that work? > > > > iirc i wrestled with all these questions for toplev (which has a > > similar feature) and in the end i concluded doing it automatically > > has far too many problems. > > > > Yes, you are completely right that there are limitation that we can only support -a, -C > and not support on -I now. I'm wondering if we could support "-I" in next step by > processing sampled data on the go. -I is very tricky in a separate process. How do you align the two intervals on a long runs without drift. I don't know of a reliable way to do it in the general case only using time. Also just the non support for forking workloads without -a is fatal imho. That's likely one of the most common cases. Separate is a far better model imho: - It is under full user control and no surprises - No uncontrolled multiplexing - Often it is fine to measure once and cache the data It cannot deal with -I properly either (short of some form of phase detection), but at least it doesn't give false promises to that effect. The way to do it is to have defaults in a json file and the user can override them with a calibration step. There is a JSON format that is used by some other tools. This is my implementation: https://github.com/andikleen/pmu-tools/blob/master/genretlat.py https://github.com/andikleen/pmu-tools/blob/89861055b53e57ba0b7c6348745b2fbe6615c068/toplev.py#L1031 -Andi