Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp456033ybk; Wed, 13 May 2020 04:40:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4sBeXdzqs0XUnmaX6P5R0Q9WjDuKyZIhgvlIRCZIgvvCKFyV4WVHN2T/mLj/x/adwWbG2 X-Received: by 2002:a50:9f85:: with SMTP id c5mr7909285edf.72.1589370048099; Wed, 13 May 2020 04:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589370048; cv=none; d=google.com; s=arc-20160816; b=kjY3brvwcscvvHcLFXf38Fw2BW54/VYu1cthA988fktWyyD8KyX2izeyJbh6Iy9MTR gwy8TB5Q7iIftxNuTWYOzcD3dz1WoazJ8N2MXI9sE/Ndi3IHHdXubn81I5jywST970PU 3Q8GVPAz2pgJtyiBsfqxOnewcwuGA+3wowaBk1jqRNa8G9BYN+NrI6y+D2+1rINygfxM 2i1kwkrKiwQE+BZnnonmZoDgQKKwzLdPMZkZO5W+rbIgazGhM4nnB5Bn9Cb7jAU+oa+N TzmdcODlMaNHqK/k72+UEHtBM/qAIAIUpylIQxtC7iMWHTz7GhCvDs0A5WYYX0i6wHt5 H5Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=LRUoCKtlXHJ46xoUgnC/etCJOTrU/b9ynoKVd4gTyFc=; b=X/lyUza7bzNKRast+lfdVbzvEnp9Y+OJcag/7QdmJUqBgoceXXcclY0SLAXtAMej6V eMIp1Q0s1VO7sb/JSuzydfJnakw1sxz7+uhZXS+aTR88/XmZYySAnhs3IvD/dsJkNvIX PQfkVjaQgfl+cJsfGM9NzFeVe8NC10mJI1rXVekCxO1t9mxuxVygWjQQmzENrYMsEkIR 6rQXOo8PMgTvChEqpXf1PtrqtI2Ck/qbArRIXffEzoZlCxQT2xfw29TxA7ZJHkX+yRkI iNioRoPWdriKp0ZJIaamNXDSlCPoTy9Ih9oN5RGKJCyXqEtR+stez2U4CrkoOe+V/2lN M80Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZAYVD7ve; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si9320931eju.478.2020.05.13.04.40.24; Wed, 13 May 2020 04:40:48 -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=@redhat.com header.s=mimecast20190719 header.b=ZAYVD7ve; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731192AbgEMLdy (ORCPT + 99 others); Wed, 13 May 2020 07:33:54 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47180 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728930AbgEMLdy (ORCPT ); Wed, 13 May 2020 07:33:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589369632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LRUoCKtlXHJ46xoUgnC/etCJOTrU/b9ynoKVd4gTyFc=; b=ZAYVD7veetJacorI73OsR/IyhdgpVhYDLpU2A+OHpaiVbhAnOlFHBehSB34ioH85XkZPic Oa0HAk+vvFQ82zpx2BYnbZ77yFgkxwcpKy8tGzHlSdvf4gNaR7D/IoDAUcYl9gp4pRhYpB bKq+r5rnh4Sc1rCzzM0XBvY9QWdbfLg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-508-lEQl-fVjN_2UtkpBD_nS2A-1; Wed, 13 May 2020 07:33:50 -0400 X-MC-Unique: lEQl-fVjN_2UtkpBD_nS2A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7480460; Wed, 13 May 2020 11:33:48 +0000 (UTC) Received: from krava (unknown [10.40.195.109]) by smtp.corp.redhat.com (Postfix) with SMTP id 219BB5C1BB; Wed, 13 May 2020 11:33:45 +0000 (UTC) Date: Wed, 13 May 2020 13:33:45 +0200 From: Jiri Olsa To: Ian Rogers 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 Subject: Re: [PATCH 3/4] perf stat: Add --metrics-file option Message-ID: <20200513113345.GI3158213@krava> References: <20200511205307.3107775-1-jolsa@kernel.org> <20200511205307.3107775-4-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 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 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