Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1017553ybk; Wed, 13 May 2020 20:45:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBVUDb770VanCW4CUfP0B//vhbccn00fvGaB6KzAGgreqqXe3d3git9PF12vMTQoyQkTus X-Received: by 2002:a05:6402:7d6:: with SMTP id u22mr2230924edy.149.1589427936158; Wed, 13 May 2020 20:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589427936; cv=none; d=google.com; s=arc-20160816; b=E1O+lw/CxnBKJiJrDh9tRK34vtlPQ5mN6njRs6dRE9LCvgPT5nrkx3xiUAzxebXlXR rOgjK+39nERYkPIKBGg9s5y8BTBbhCWhFhzKdRCzgW35/slMCsCk45dw15Ej+ztt1iJg zQ7gMQV6hcnJ+L/UDnjboFhOzbh1IgpLcZdO4w8pDBsKqvCxv6LlZy64C8sr1DkOoO2N pN6QLkodC/4bURlCQ9eA0yFPQlodcyIOHmKC2DsihdnhYKKtbckvdU3NUHjm+/M2kPK2 K7BjpwGX3NQZ11FVcUfIvTldwUd0V4rqpI2sWxhI3wJJDyXBOY5gGcynHz13VHworeAR tKcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wgGBPApfMen/3AKC9GulhxtmJ5nu3WUilZQROpGUHVI=; b=bqJq6AVqoqClqfkhh5g+vmBQB859vVARa9d5wTl9SCiWCWDYNOzcj8WO1KB3BndOwN UmR6xNnwxsU6EO9fGvlMJlGZ4fTA8XOzPjAb+Zroa5NAORhIyDnaGREWTxBNz2eiuUwv mtVyD23eVeWwPuxHMxjNkMwfvukEUunQdzy3Vix2/81M2f4E9BCmwZ/ymqoFkDoPUKXv kiAdmKzpfa/4HRhfItgRnzc+9HJVbzXQJ5ljPHltKyT91ZdcbgEw+7m8rtrjvU5nq/d1 YQGga2vVrmJ3664N0WwUvxu5s827wscoGUPaTIxuso8/m12ZwR7zhA7orBSL3F9pDZE5 fpcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=g5FGegCB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si746513edt.220.2020.05.13.20.45.12; Wed, 13 May 2020 20:45:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=g5FGegCB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726011AbgENDld (ORCPT + 99 others); Wed, 13 May 2020 23:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725931AbgENDld (ORCPT ); Wed, 13 May 2020 23:41:33 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D103CC061A0C for ; Wed, 13 May 2020 20:41:32 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id s37so806073ybe.13 for ; Wed, 13 May 2020 20:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wgGBPApfMen/3AKC9GulhxtmJ5nu3WUilZQROpGUHVI=; b=g5FGegCBPa+B9wy5kadW3vK8vhhdO+DosxKNSA+6+nu1h1bIBvrS3FWYUQW+9cokgw D05Xy5v7qn7fW4oyK9FQbNIdC7X8hc6fiEyaFt62jUv+ZtHILVK4RFM7S5TMNSGpyO0H NBIDpGnC5PB+nC5lFIk40gRAv/Jv14lyhob3kwuk17ebvUnKG5wGus9SES/6dQ24IOcY +KXHbardCdeu4pQ5KZwlm8tCT9UIkFEt0cOGR+EYX6RLipoUU7GInaydrxdKQ3I8qEVB sLQPwaVzOLZ1uvp/svlFMp10SZDr4hE+C2K/sp4kXcrgtsiqCfPe8uW00s1izENr/ehW 0fDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wgGBPApfMen/3AKC9GulhxtmJ5nu3WUilZQROpGUHVI=; b=dAQH7NhynVCMgMBnA4KyXZubCXwHBZFLCTIfRHOZ2paxzLowj6Y0B5VK7H7J7Jy+Z3 6v6n+ktO4Mi88VRM45a0D3Y8UCI5d7Wy0hSv3OOe8PgYIZ9LPrN/Oh9dwRvVTTW/bmjC Ak9MkkjzmCuvLAz35Tt/DbZK9X4XYtsD6nrFYmUOFMoINy1IaWU0S4GAj9dCU5hjiMQn vNV0501xGokjXojbc1QqtvSY03YqK8rC/3vjiUwWrUzgKm7+l+fX3O9ffRg5TuUgxv21 3lWGvLPkhJ9Eftnxq8w5cF4aiTnm6LNrcr4nFUtzJLd0BclIUWzYztZWAaKFYWOe97z8 ar0Q== X-Gm-Message-State: AOAM533AXQvZuAjbeiiP+B26HarHmb9rnaZOQ7zcJXuji2IRHz4w4t7A 3KuWaF73P4IGEWFF3GX6kgjY25t0NIl8kolj/kadMA== X-Received: by 2002:a25:3182:: with SMTP id x124mr2502468ybx.324.1589427691446; Wed, 13 May 2020 20:41:31 -0700 (PDT) MIME-Version: 1.0 References: <20200511205307.3107775-1-jolsa@kernel.org> <20200511205307.3107775-4-jolsa@kernel.org> <20200513113345.GI3158213@krava> In-Reply-To: <20200513113345.GI3158213@krava> From: Ian Rogers Date: Wed, 13 May 2020 20:41:20 -0700 Message-ID: Subject: Re: [PATCH 3/4] perf stat: Add --metrics-file option To: Jiri Olsa Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Joe Mario , Andi Kleen , Kajol Jain , John Garry Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 13, 2020 at 4:33 AM Jiri Olsa wrote: > > On Wed, May 13, 2020 at 12:04:55AM -0700, Ian Rogers wrote: > > SNIP > > > > +METRICS FILE > > > +------------ > > > +The file with metrics has following syntax: > > > + > > > + NAME = EXPRESSION ; > > > + NAME = EXPRESSION ; > > > + ... > > > + > > > +where NAME is unique identifier of the metric, which is later used in > > > +perf stat as -M option argument (see below). > > > + > > > +The EXPRESSION is the metric's formula with following grammar: > > > + > > > + EXPR: EVENT > > > + EXPR: EXPR if EXPR else EXPR > > > > Not introduced by this patch, but this patch is exposing it as an API. > > yea, I was thinking about this and I think we will put a disclaimer in > here that this is not an API and the interface can change.. it's really > mostly intended to help out with running a custom metric which is not > compiled in ... I don't want to be commited to support old API > > > This notion of if-else is really weird. For one thing there are no > > comparison operators. The unit test doesn't really help: > > ret |= test(&ctx, "1+1 if 3*4 else 0", 2); > > What kind of comparison is "3*4"? If 0.0 causes the else clause then will -0.0? > > A typical expression I see written in C is to give a ratio such: > > value = denom == 0 ? 0 : nom / denom; > > I've worked around encoding this by extending expr.y locally. > > AFAICS it's used only with #SMT_on in the condition, aybe we could limit > the condition only for #SMT_on term? > > > > > > > + EXPR: NUMBER > > > + EXPR: EXPR | EXPR > > > + EXPR: EXPR & EXPR > > > + EXPR: EXPR ^ EXPR > > > > Again, it's odd that these cast the double to a long and then assign > > the result back to a double. > > is this even used anywhere? perhaps it was added just to be complete I don't believe they are used and checked with the pmu parsing test that removing them doesn't cause any x86 expressions to break. I'd prefer it if we could remove the unused operators and avoid advertising here. Thanks, Ian > SNIP > > > > + 2.002460174 0.86 23.37 0.86 > > > + 3.003969795 1.03 23.93 1.03 > > > + ... > > > > A feature request would be to allow metrics in terms of other metrics, > > not just events :-) For example, it is common to sum all cache > > hit/miss events. It is laborious to copy that expression for hit rate, > > miss rate, etc. > > > > Perhaps the expression parsing code should be folded into the event > > parsing code. > > nice idea, but let's finish straighten up what we have first ;-) > > I'll try to go through all the fixes/tests you posted and let's > get it in first > > thanks, > jirka >