Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp463492lqg; Fri, 1 Mar 2024 10:18:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWb4GiyAtKveWJW9L1lCwyRGFVFzdUjVJ2tKYblOTArUeIfHIu1sCkccVg0jm4rqhl6SyWEEmRiCFgoifij2tSP1jbrruYKa3IJI4Q9lw== X-Google-Smtp-Source: AGHT+IGR6QxOTSCvYKvUZKAADtN32ZbUD1Wt70/j27yDy5l4Y7VruAXPUKtfURRADSs13+c5tm1q X-Received: by 2002:a17:906:4947:b0:a3e:3bc0:64f5 with SMTP id f7-20020a170906494700b00a3e3bc064f5mr1884208ejt.64.1709317111227; Fri, 01 Mar 2024 10:18:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709317111; cv=pass; d=google.com; s=arc-20160816; b=mJMMR7xWUGk3483CktmIhfrEVkG2c8wCp8qFZDg5eQeVV18ahNRyz82OnotF/J35/E hNHdat+/mgSIYvivOTfXOIGV4PccnfIpQKt3l1SKL3cgBAbe/AyJGYzJXMO9AM/On5Hx j6Lt8EXFVtvLWedEzejQmIuaLLHZilKbEPKsV+J2jWHMw1N4x/Ap+WppbTnIJjBDy4JW y5z9LkuDZSTm+tAxG35zk00ijxu5SLp1xSSu/5P4CcUWiCEHCG4cRMuaUpz3GnTRGLj3 qlduwvt9YhhsU5x5A1+hrXdpV9m6iD8ORe8eD7FY8ogH0lShBvrfCupfk2rUvSAyMwhH PWRA== 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=7/XpCAVrNR7f3usUyCsnp/6VufeVu2JOUWJrzYbrmGQ=; fh=IJ0dzLfPgxXcrA9EEY9b9p2LIEtOOO4isY6i7hW0He4=; b=MJvpEca9HU3z3OcpY3izspuQc/Bu7CXTWjerlbMpaZRMOvAAdRlkCayfV3A000RrzS AqV/FYRW8wnNnxegtVteuS7hz3dq0y6WXzWgjqQqhAasPjVpKrnrqbwsyqD/qrBxOdIM LPPena/xU5VdKDaDC/CjhOkB2e84swPFVzvgnwCAwkAaU96nDkZ8Jve7/I+dzc7Z2Kta t99mDYE9SlR457b3feoXZqxQJOF4qFmpqe7NNexMetec2gHLT3YWNbohU2kx391NqNSS 6kz35pyX026I0qgJFJQCUqKvr2Bs95uhBFxgnG8x5BNSy1NVaFFEnsNTp5TCCZq/NAgg T4Fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=E+whfIv5; 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-88895-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88895-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kj2-20020a170907764200b00a3d2344a467si1638799ejc.118.2024.03.01.10.18.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:18:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88895-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=E+whfIv5; 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-88895-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88895-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7D5D31F2310F for ; Fri, 1 Mar 2024 18:18:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F5B73A8E9; Fri, 1 Mar 2024 18:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="E+whfIv5" Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 CBA883A1C5 for ; Fri, 1 Mar 2024 18:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709317040; cv=none; b=PhXbVaeFmHnv5rBHpMRBCvYYXjbR1Ar0qDOvihwOV0shIdBpOHvM4w+63pUisnsIx51IUNGNUQkhjyiaItkCL77HWpHXuwi0bsFoEe9/sd0/AUToUU1O+rN91hHqZ8S00kwxBEhFihy43nJKk83+ZZERUOIcOiJIt6KjtwAJXRg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709317040; c=relaxed/simple; bh=ORNRTXO5tve5Nbc9/dvCua1upVjXHlRaDwslfC29pOY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=SOQGkfbT7Nj92GP7hOtHxrAvcfJ0ARYOOqqt7UB0q5rZ8YmFAK2RKtjKeO8t5k2XWj4yS+/dvrSfOfQm3s3Rz4qTFWlqt9DRZI30lqpJ02MN1Cz8k9YtcFBWxw8ZDsFYb/1dfbgqMQUJkbAzazw4x+KfmXUKC16d0sLOjemR1Cw= 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=E+whfIv5; arc=none smtp.client-ip=209.85.160.176 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-f176.google.com with SMTP id d75a77b69052e-428405a0205so343411cf.1 for ; Fri, 01 Mar 2024 10:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709317038; x=1709921838; 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=7/XpCAVrNR7f3usUyCsnp/6VufeVu2JOUWJrzYbrmGQ=; b=E+whfIv5HtsOENwRwBFdE0T2vskCsJAZtnt8OHrddv5xurWapjck55iYJm+LcLeJyW /sNWfZtPsOHODuNej02qgvEHpf9/cs655CX7b2yWHNJVgia8JZEk1ZGRAlauRoJXJCrx dxH/6paFv+z3N/w6SvS5BCPOGgFnlB03t0X8PEGQm3y7Zy7Z3b1dtjNmWMM5LhI3+9uZ 9s8WrmfnpIg4PtBtTl9/ZA5xVdFalB9OKpTqT33a5oiE6D+KG0euUxj/rpsRSxyulWTm CVJkZY5md48Htfrwpfqqr/M4t870M/DeZDJT3c/su4vSJjTLBf+IwJDKgaEZUUsP9Rlg Rtxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709317038; x=1709921838; 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=7/XpCAVrNR7f3usUyCsnp/6VufeVu2JOUWJrzYbrmGQ=; b=shXs7tciGMUolKrl7bCHzDyfAvkVR5PFS6rep47oExkRMYrmyMdy9kmiKCrCDfYikV l+UqfhnO4wx8786DsQhNRS5zvi5b1g4CMYeS0usk6HXVbpBCX/7kzzK7VUsfFdCoe4fw Is3i8En8B7lr7C4Qv/yNGSfLhxXNVw2Nh0lE/B7B7jQBJ7HIFiX/iRf6tDUH8IAY20MV l0iiK19VK5Us8AdwIQsFzOXN0Q8xAzI725BZBAEzkabYom+y4aqnWb3bm0iv2Ls3erEf bxXuWLQSj4AWj0qSzDsFDS1t1yzEV25AfdyELof8zm5KkOzltFNOk2T4fBJdpt73tTNG IbeQ== X-Forwarded-Encrypted: i=1; AJvYcCWGIqn2PfAxMRCPN3NDsbYPkfJyyWB3pk9mDvz4mDVdxC++1SC7DFrV6HMzBoKi2+lePWlP6jdpH1dbSxY1cui7WnfBh9ZqjRYPxqdm X-Gm-Message-State: AOJu0YxVEzVV0fD4jnRtZWR8Rm8tSxTC18Pbq2u2nVb8FW5NIVcusPV7 A6M3BmMnSpo1OPp2yuJxFgK3FvS8aTd6Lybb663eanldc/z0U0wxLTdHmDDgL4QXJSPugS5RbWF CTLZQO/U3thaLaRUCSCEYqtcepd3y1yXq4YpZ X-Received: by 2002:a05:622a:170b:b0:42e:d51e:c718 with SMTP id h11-20020a05622a170b00b0042ed51ec718mr46389qtk.9.1709317037508; Fri, 01 Mar 2024 10:17:17 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240229001806.4158429-1-irogers@google.com> <20240229001806.4158429-3-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Fri, 1 Mar 2024 10:17:03 -0800 Message-ID: Subject: Re: [PATCH v1 02/20] perf jevents: Add idle metric for Intel models To: Andi Kleen Cc: Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Stephane Eranian Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 1, 2024 at 9:49=E2=80=AFAM Andi Kleen wrot= e: > > > +def Idle() -> Metric: > > + cyc =3D Event("msr/mperf/") > > + tsc =3D Event("msr/tsc/") > > + low =3D max(tsc - cyc, 0) > > + return Metric( > > + "idle", > > + "Percentage of total wallclock cycles where CPUs are in low powe= r state (C1 or deeper sleep state)", > > + d_ratio(low, tsc), "100%") > > TBH I fail to see the advantage over the JSON. That's much more verbose > and we don't expect to have really complex metrics anyways. Are you saying this is more verbose or the json? Here is an example of a json metric: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json?h=3Dperf-tools-= next#n652 ``` { "BriefDescription": "Probability of Core Bound bottleneck hidden by SMT-profiling artifacts", "MetricExpr": "(100 * (1 - tma_core_bound / (((EXE_ACTIVITY.EXE_BOUND_0_PORTS + tma_core_bound * RS_EVENTS.EMPTY_CYCLES) / CPU_CLK_UNHALTED.THREAD * (CYCLE_ACTIVITY.STALLS_TOTAL - CYCLE_ACTIVITY.STALLS_MEM_ANY) / CPU_CLK_UNHALTED.THREAD * CPU_CLK_UNHALTED.THREAD + (EXE_ACTIVITY.1_PORTS_UTIL + tma_retiring * EXE_ACTIVITY.2_PORTS_UTIL)) / CPU_CLK_UNHALTED.THREAD if ARITH.DIVIDER_ACTIVE < CYCLE_ACTIVITY.STALLS_TOTAL - CYCLE_ACTIVITY.STALLS_MEM_ANY else (EXE_ACTIVITY.1_PORTS_UTIL + tma_retiring * EXE_ACTIVITY.2_PORTS_UTIL) / CPU_CLK_UNHALTED.THREAD) if tma_core_bound < (((EXE_ACTIVITY.EXE_BOUND_0_PORTS + tma_core_bound * RS_EVENTS.EMPTY_CYCLES) / CPU_CLK_UNHALTED.THREAD * (CYCLE_ACTIVITY.STALLS_TOTAL - CYCLE_ACTIVITY.STALLS_MEM_ANY) / CPU_CLK_UNHALTED.THREAD * CPU_CLK_UNHALTED.THREAD + (EXE_ACTIVITY.1_PORTS_UTIL + tma_retiring * EXE_ACTIVITY.2_PORTS_UTIL)) / CPU_CLK_UNHALTED.THREAD if ARITH.DIVIDER_ACTIVE < CYCLE_ACTIVITY.STALLS_TOTAL - CYCLE_ACTIVITY.STALLS_MEM_ANY else (EXE_ACTIVITY.1_PORTS_UTIL + tma_retiring * EXE_ACTIVITY.2_PORTS_UTIL) / CPU_CLK_UNHALTED.THREAD) else 1) if tma_info_system_smt_2t_utilization > 0.5 else 0)", "MetricGroup": "Cor;SMT;TopdownL1;tma_L1_group", "MetricName": "tma_info_botlnk_core_bound_likely", "MetricgroupNoGroup": "TopdownL1" }, ``` Even with common metrics like tma_core_bound, tma_retiring and tma_info_system_smt_2t_utilization replacing sections of the metric, I think anyone has to admit the expression is pretty unintelligible because of its size/verbosity. To understand the metric would at a first step involve adding newlines. Comments would be nice, etc. > And then we have a gigantic patch kit for what gain? I see some of the gains as: - metrics that are human intelligible, - metrics for models that are no longer being updated, - removing copy-paste of metrics like tsx and smi across each model's metric json (less lines-of-code), - validation of events in a metric expression being in the event json for a model, - removal of forward porting metrics to a new model if the event names of the new model line up with those of previous, - in this patch kit there are metrics added that don't currently exist (more metrics should be better for users - yes there can always be bugs). I also hope the metric grouping is clearer, etc, etc. > The motivation was the lack of comments in JSON? We could just add some > to the parser (e.g. with /* */ ). And we could allow an JSON array for t= he > expression to get multiple lines. Imo, a non-json variant of json would just be taking on a tech debt burden for something that is inferior to this approach and a wasted effort. We already generate the json from other more intelligible sources using python - so I don't find the approach controversial: https://github.com/intel/perfmon/blob/main/scripts/create_perf_json.py The goal here has been to make a bunch of inhouse metrics public. It also gives a foundation for vendors and other concerned people to add metrics in a concise, with documentation and safe (broken events cause compile time failures) way. There are some similar things like common events/metrics on ARM: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/pmu-events/arch/arm64/arm/cmn/sys?h=3Dperf-tools-next but this lacks the structure, validation, documentation, etc. that's present here so my preference would be for more of the common things to be done in the python way started here. Thanks, Ian > -Andi