Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp2635746rbd; Tue, 9 Apr 2024 12:30:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUs0qh/MlJ0GEYfAslEt3bvJx+WFLQiv/RH/8XzWmXHeQoNaEg95VxHCgV8JYSpBGV3A9tAOQGBje5GLVCXElC1eSvwS6wI6w8bvC+z2A== X-Google-Smtp-Source: AGHT+IG+lvRWE8pLMHaCBogWJWVessk7g7DKEegTDqtATrv1lDKOtUT3qp+Z/vdUxn2rkOWWWpux X-Received: by 2002:ac8:5f52:0:b0:434:bb25:ed02 with SMTP id y18-20020ac85f52000000b00434bb25ed02mr475655qta.63.1712691054868; Tue, 09 Apr 2024 12:30:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712691054; cv=pass; d=google.com; s=arc-20160816; b=RS4rMtoMwyRq1+jlnvckabYHC7ZSfO6Th8CSJnQ5NtGBCGJTT2mg1gnQugpIwAMD6R Z1N8k6jqYFqBoS20A6jY1IjzKrp5ZxndozlNADMfoalMMoaXQrJc0IJai1gxmTFavOAh XcyEjLMpWIXq+d6EjV2e1IUF2PDL39elcoka0xbVGvy7yCZNmxkbNLR+89iV0rly7uem FEVTfsdSnelJP3APmkwVAL/86kySrSVGuv5+LJkLrKz0ShcwtbDcMrZPGxN0ETOnRfEc mYWsBgQHqqo8Xxv7Ec7crov8OLqaJt9Py9RbIncM0DWFrUp0flCthbKBvfXEShHkWGs+ hYDA== 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=cXBwMc0h/4YLxnhtwXB+DKeKsXV/rxCsNtc2huo+byQ=; fh=DjhCHWzpMfL2nQZN26EGFcX53TSPOwhUDRO6r7A5L4Q=; b=D7ahHI4lJ13O8sHFjcBbzdQmZFz5Q00M6vcVtPJ1D/TT0vCTrTMwCj4Ge5HmXHoa02 Dn0xq+HYs1B/kduhH3eLvj4pmnCrdSUmRSxgY5O1uuHvt2PoO+pWAWUrhThtzmL6Yzze lzSaZg/dsOpixIiydYgOG7HUwhkc41Xq9t92ezUlh/cHTSClBOKCyM42ox+Ktf4gGxRT hn2aMcgmtCmpvA23ASQEpuhBif5ju+ul1XRLisATl1JTZcjy7y3zNYiv8ePU/PwlSjvl a4jb3AhAm0fKQcLJ8VHCsmCMUwIgFYZG8rzlyXFqkYfFkXuSF/6F+Md1TMmwy/TOhzW+ WzFQ==; 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-137538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137538-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d6-20020ac85ac6000000b00434b1c39ce2si4033594qtd.427.2024.04.09.12.30.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:30:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-137538-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137538-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5C3E21C21103 for ; Tue, 9 Apr 2024 19:30:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 486AC1581E5; Tue, 9 Apr 2024 19:27:58 +0000 (UTC) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 E312A156F28; Tue, 9 Apr 2024 19:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690877; cv=none; b=kXSoWw6UtlkzlwtZuAy1UM2xDIf5WJH2hUo68tnur2+yy5mHw3ulGOE0DgP7Vw1RjppSaq6wRK80K3GRfcuEbdePNB84zchZ3dzGQaU6/dRN6lu2dSCveDbmLIgmaMOHE9T7SfT6eJ0MX0tvkmBB8hD8I3/dm+u8d5scZwiNKjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690877; c=relaxed/simple; bh=NBlFKQKXdDSYGy3jDOPVW5jSTQHFXmqLC8ubcBtwg54=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YjaOac+v4PBja4E22NhbbDfHXiCE44TlvnfYPasXOMDFsQb7ogtYMPumsxFVuWkhG1UcB62PQzaQ7bdyaD2rjnsKE9GLB6lVXfeKMC97FW0cTyyWKEZTkDrzk3+m6QCZwwDVwTUiguQznoBgEHJcK9rXJMFJ0PVqaKOPqWAw3oU= 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.46 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-f46.google.com with SMTP id 98e67ed59e1d1-2a5215314a4so1667516a91.0; Tue, 09 Apr 2024 12:27:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712690875; x=1713295675; 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=cXBwMc0h/4YLxnhtwXB+DKeKsXV/rxCsNtc2huo+byQ=; b=LGav91RS97JIfWh9RMP+qb5CxXwRZiQTKLrfOYxuLMXmk8wfX0O8ttvIf/4LHjXL1O umQ/pc/AcQ6rCt4ui0cZEXK3QRapLWdZcSB5K7i8926JOG3QE7Hoj3YsxDp1THHbENpM xS8Y7l8i6+eiihSfvgyUzvPpCznH6h9zvYdxnApVo+OcbNB2TE771UaUTReJkhXfxmke b3Er4WGImrUbWKo2EaAvks7S+1+ybnZVkjhopioAOl1c0H+BpGzjCWfNI436FZpT6l+5 ysSCBv9Y0u9/x18VEEYUKjwi/MHbpCbfLo0VzHHp/enJDqTmIPoqU6v463ATodnFSoSv NIVw== X-Forwarded-Encrypted: i=1; AJvYcCXpPmvWa949/GN0Sj62CSdIFHODRinHuf+zi3AvS08PWJZ239SjdDj2uRg7rCEhS+xjNujlvzKteT7WWSfA1nBKlE0X/AwnCP/jPR/+uVMSsbCiavK8xLQYBdAa2f3SvfyWr86RgdwIsdF+sTRf6g== X-Gm-Message-State: AOJu0Yz8NC307DjGdAgqVWj/DI5kMJZRUb0qfJoDAduLQFF4DzYUpMS7 lxWYYQiC4++MWW9AmrTC4a6B/Xf2NCxhKnbWQzEQN4Pp46tuBh+t3ABTWOsFnR/zrrwGsV+9bWB rrp+SKHBislN3jwfEvq4Q0uSW2vU= X-Received: by 2002:a17:90a:38a1:b0:2a1:f455:c3d7 with SMTP id x30-20020a17090a38a100b002a1f455c3d7mr600957pjb.16.1712690875020; Tue, 09 Apr 2024 12:27:55 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240409000659.1727785-1-namhyung@kernel.org> <20240409000659.1727785-3-namhyung@kernel.org> <0ec1328a-0731-42a6-b953-163ac5a56deb@linux.intel.com> <16587efd-ab12-463a-bd87-7721adfc731d@linux.intel.com> In-Reply-To: <16587efd-ab12-463a-bd87-7721adfc731d@linux.intel.com> From: Namhyung Kim Date: Tue, 9 Apr 2024 12:27:43 -0700 Message-ID: Subject: Re: [PATCH 3/3] perf report: Add weight[123] output fields To: "Liang, Kan" Cc: Arnaldo Carvalho de Melo , Ian Rogers , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Stephane Eranian , Andi Kleen , Athira Rajeev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 9, 2024 at 11:18=E2=80=AFAM Liang, Kan wrote: > > > > On 2024-04-09 12:53 p.m., Namhyung Kim wrote: > > Hi Kan, > > > > On Tue, Apr 9, 2024 at 9:37=E2=80=AFAM Liang, Kan wrote: > >> > >> > >> > >> On 2024-04-08 8:06 p.m., Namhyung Kim wrote: > >>> Add weight1, weight2 and weight3 fields to -F/--fields and their alia= ses > >>> like 'ins_lat', 'p_stage_cyc' and 'retire_lat'. Note that they are i= n > >>> the sort keys too but the difference is that output fields will sum u= p > >>> the weight values and display the average. > >>> > >>> In the sort key, users can see the distribution of weight value and I > >>> think it's confusing we have local vs. global weight for the same wei= ght. > >>> > >>> For example, I experiment with mem-loads events to get the weights. = On > >>> my laptop, it seems only weight1 field is supported. > >>> > >>> $ perf mem record -- perf test -w noploop > >>> > >>> Let's look at the noploop function only. It has 7 samples. > >>> > >>> $ perf script -F event,ip,sym,weight | grep noploop > >>> # event weight ip sym > >>> cpu/mem-loads,ldlat=3D30/P: 43 55b3c122bffc noploop > >>> cpu/mem-loads,ldlat=3D30/P: 48 55b3c122bffc noploop > >>> cpu/mem-loads,ldlat=3D30/P: 38 55b3c122bffc noploop = <--- same weight > >>> cpu/mem-loads,ldlat=3D30/P: 38 55b3c122bffc noploop = <--- same weight > >>> cpu/mem-loads,ldlat=3D30/P: 59 55b3c122bffc noploop > >>> cpu/mem-loads,ldlat=3D30/P: 33 55b3c122bffc noploop > >>> cpu/mem-loads,ldlat=3D30/P: 38 55b3c122bffc noploop = <--- same weight > >>> > >>> When you use the 'weight' sort key, it'd show entries with a separate > >>> weight value separately. Also note that the first entry has 3 sample= s > >>> with weight value 38, so they are displayed together and the weight > >>> value is the sum of 3 samples (114 =3D 38 * 3). > >>> > >>> $ perf report -n -s +weight | grep -e Weight -e noploop > >>> # Overhead Samples Command Shared Object Symbol Weigh= t > >>> 0.53% 3 perf perf [.] noploop 114 > >>> 0.18% 1 perf perf [.] noploop 59 > >>> 0.18% 1 perf perf [.] noploop 48 > >>> 0.18% 1 perf perf [.] noploop 43 > >>> 0.18% 1 perf perf [.] noploop 33 > >>> > >>> If you use 'local_weight' sort key, you can see the actualy weight. > >>> > >>> $ perf report -n -s +local_weight | grep -e Weight -e noploop > >>> # Overhead Samples Command Shared Object Symbol Local= Weight > >>> 0.53% 3 perf perf [.] noploop 38 > >>> 0.18% 1 perf perf [.] noploop 59 > >>> 0.18% 1 perf perf [.] noploop 48 > >>> 0.18% 1 perf perf [.] noploop 43 > >>> 0.18% 1 perf perf [.] noploop 33 > >>> > >>> But when you use the -F/--field option instead, you can see the avera= ge > >>> weight for the while noploop funciton (as it won't group samples by > >> > >> %s/funciton/function/ > >> > >>> weight value and use the default 'comm,dso,sym' sort keys). > >>> > >>> $ perf report -n -F +weight | grep -e Weight -e noploop > >>> # Overhead Samples Weight1 Command Shared Object Symbol > >>> 1.23% 7 42.4 perf perf [.] noploop > >> > >> I think the current +weight shows the sum of weight1 of all samples, > >> (global weight). With this patch, it becomes an average (local_weight)= . > >> The definition change may break the existing user script. > >> > >> Ideally, I think we should keep the meaning of the weight and > >> local_weight as is. > > > > Hmm.. then we may add 'avg_weight' or something. > > > > But note that there's a subtle difference in the usage. If you use > > 'weight' as a sort key (-s weight) it'd keep the existing behavior > > that shows the sum (global_weight). It'd show average only if > > you use it as an output field (-F weight). > > > > As my understanding, the -F weight is implicitly replaced by the -F > weight1 with this patch. There is no way to get the sum of weight with > -F anymore. Right. > > I think that's a user visible behavior change. At least, we have to warn > the end user with a message, e.g., "weight is not supported with -F > anymore. Using weight1 to instead". Only updating the doc may not be enou= gh. I understand your concern. I can add the warning. > > > The issue of the sort key is that it cannot have the total sum > > of weights for a function. It'll have separate entries for each > > weight for each function like in the above example. > > > > That seems to be a different issue. If the total sum of weights for a > function is required, we should fix the existing "weight". Yeah, I guess that's more reasonable behavior. But I'm not sure how we can fix it without breaking the existing behavior. Actually this is my approach to keep the behavior for the "sort" key. I think users are more familiar with -s (--sort) rather than the -F (--fields) option. That's why I'd like to "break" that part only. Thanks, Namhyung