Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2173574ybk; Mon, 11 May 2020 13:55:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3rL6Vkz5l1lcXtOtxx7nZYDgBPG03FD4MZP/1F4xArGN6mgx8tiiN3c6P25K6TVyb7S2F X-Received: by 2002:a05:6402:2292:: with SMTP id cw18mr2517827edb.217.1589230508417; Mon, 11 May 2020 13:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589230508; cv=none; d=google.com; s=arc-20160816; b=uswDGRwzO+Vky75AGDEIGMZSx9fsMHIoUAojFEkKx1ipJ74TvmndrRysp2Dhrm61Ao 4izPk8Oh5lKUE/8zutO66u34dwgpcMxS+scbVoz+A8FEwEKSGBA1qIBKp0ZNCZLvowro Bai9l3VZUf+GVzr0+Q9oEzXhzTRPvjEkiFtCNXaPFxsZQuscoSboLupjXc1cJiqUWCjs LUd80B9dU1OpNzLZWrYXc2lztr8OchXLfWkZTyduO7GsXHcoR60QhVH7ba51dgV9jQzW gWtaW1Nu9YTIInis4UX6D06l90ut0nGFjMsg1jiocmVun/d1b5qb3xhZBFZPkB07xDto mj7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ceb69sTkZlBARVlRm7qbh+VNqAtd39B3o4C/guYtgzI=; b=0A1UORN8BCU79p0NLnhQOOfZ74e+s0/wjTzuPHrfB9zhNeDdBpSjbFtnwkth96lgHW PN2Eq2yRaife6o8lmO1z3f9IrAVYgD2Q+43tMmwYE7RGlHXYJ47Vj+Hw7x/v6Ow0H4DQ 7AM9KkSGS64PjNDsYSHdtyCeBcBIS3z7sP2gh8aGV7rH0k84PBkFIO7oa7QVdddpGiya cQFJEuOAJxl5Ff/ulHR35PZk86EUiBBUvPJxtGNR/Iq+1MYKjvyi/uEJNGfl2hc8vjSm PeUltSHSx6XJbGMklmglYBSAmTNGS+V9o/RIAViOdXmLvmgttvFr2QIFywVcsS/wP7im 3FCw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k21si3727743edv.458.2020.05.11.13.54.44; Mon, 11 May 2020 13:55:08 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731637AbgEKUxV convert rfc822-to-8bit (ORCPT + 99 others); Mon, 11 May 2020 16:53:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39517 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727873AbgEKUxV (ORCPT ); Mon, 11 May 2020 16:53:21 -0400 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-169-RQ4zLB1gNv6FU3FCOjtiRg-1; Mon, 11 May 2020 16:53:13 -0400 X-MC-Unique: RQ4zLB1gNv6FU3FCOjtiRg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6BAD1005510; Mon, 11 May 2020 20:53:11 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.194.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D35C6444B; Mon, 11 May 2020 20:53:08 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Joe Mario , Andi Kleen , Kajol Jain , John Garry Subject: [PATCHv3 0/4] perf tools: Add support for user defined metric Date: Mon, 11 May 2020 22:53:03 +0200 Message-Id: <20200511205307.3107775-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi, Joe asked for possibility to add user defined metrics. Given that we already have metrics support, I added --metrics-file option that allows to specify custom metrics. $ cat metrics # IPC mine1 = instructions / cycles; /* DECODED_ICACHE_UOPS% */ mine2 = 100 * (idq.dsb_uops / \ (idq.ms_uops + idq.mite_uops + idq.dsb_uops + lsd.uops)); $ sudo perf stat --metrics-file ./metrics -M mine1,mine2 --metric-only -a -I 1000 # time insn per cycle mine1 mine2 1.000536263 0.71 0.7 41.4 2.002069025 0.31 0.3 14.1 3.003427684 0.27 0.3 14.8 4.004807132 0.25 0.2 12.1 ... v3 changes: - added doc for metrics file in perf stat man page - reporting error line number now - changed '#' style comment to C way with '//' v2 changes: - add new --metrics-file option - rebased on current perf/core expression bison/flex enhancements Also available in: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git perf/metric thanks, jirka --- Jiri Olsa (4): perf expr: Add parsing support for multiple expressions perf expr: Allow comments in custom metric file perf stat: Add --metrics-file option perf expr: Report line number with error tools/perf/Documentation/perf-stat.txt | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/builtin-stat.c | 7 +++++-- tools/perf/tests/expr.c | 18 ++++++++++++++++++ tools/perf/util/expr.c | 6 ++++++ tools/perf/util/expr.h | 21 +++++++++++++++++++-- tools/perf/util/expr.l | 34 ++++++++++++++++++++++++++++++++++ tools/perf/util/expr.y | 21 +++++++++++++++++---- tools/perf/util/metricgroup.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- tools/perf/util/metricgroup.h | 3 ++- tools/perf/util/stat.h | 1 + 10 files changed, 242 insertions(+), 16 deletions(-)