From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F680C43461 for ; Sun, 13 Sep 2020 21:04:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAD032223E for ; Sun, 13 Sep 2020 21:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600031097; bh=mGV49Nv57RpQ5UEEGK97aRbHJhi+uIGSujTFDdEyMqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ocn855HZZw/XXlMJH440WvG3hB0hFdkjhdSWfwP4PdfGztopGRdcmusj029e4pzWS dtNjsX5fyzYeNk0dRlcnpZyqSf9laHAk9MwZD+9lMnhUw5ka04g7oC5GSbRRMT19Xt 97RzuYUTgwVUtK91zbnUC1PbwHC/p59jxyCKQ7a4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726048AbgIMVEw convert rfc822-to-8bit (ORCPT ); Sun, 13 Sep 2020 17:04:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23534 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726028AbgIMVEb (ORCPT ); Sun, 13 Sep 2020 17:04:31 -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-267-1h84JKj6PWa4UViSTMNObg-1; Sun, 13 Sep 2020 17:04:26 -0400 X-MC-Unique: 1h84JKj6PWa4UViSTMNObg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 648FA1074651; Sun, 13 Sep 2020 21:04:24 +0000 (UTC) Received: from krava.redhat.com (ovpn-112-4.ams2.redhat.com [10.36.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 844711002388; Sun, 13 Sep 2020 21:04:20 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , "Frank Ch. Eigler" , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 14/26] perf tools: Add mmap3 events to --show-mmap-events option Date: Sun, 13 Sep 2020 23:03:01 +0200 Message-Id: <20200913210313.1985612-15-jolsa@kernel.org> In-Reply-To: <20200913210313.1985612-1-jolsa@kernel.org> References: <20200913210313.1985612-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0.001 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 Displaying mmap3 events for --show-mmap-events option, the build id is displayed within <> braces: $ perf script --show-mmap-events kill 12148 13893.519014: PERF_RECORD_MMAP3 12148/12148: <43938d0803c5e3130ea679cd569aaf44b98d9ae8> [0x560e7d7f.. kill 12148 13893.519420: PERF_RECORD_MMAP3 12148/12148: <1805c738c8f3ec0f47b7ea09080c28f34d18a82b> [0x7f9e7dfc.. Signed-off-by: Jiri Olsa --- tools/perf/builtin-script.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index d839983cfb88..9c09581d5cb0 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2342,6 +2342,38 @@ static int process_mmap2_event(struct perf_tool *tool, event->mmap2.tid); } +static int process_mmap3_event(struct perf_tool *tool, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine) +{ + struct thread *thread; + struct perf_script *script = container_of(tool, struct perf_script, tool); + struct perf_session *session = script->session; + struct evsel *evsel = perf_evlist__id2evsel(session->evlist, sample->id); + + if (perf_event__process_mmap3(tool, event, sample, machine) < 0) + return -1; + + thread = machine__findnew_thread(machine, event->mmap3.pid, event->mmap3.tid); + if (thread == NULL) { + pr_debug("problem processing MMAP2 event, skipping it.\n"); + return -1; + } + + if (!evsel->core.attr.sample_id_all) { + sample->cpu = 0; + sample->time = 0; + sample->tid = event->mmap3.tid; + sample->pid = event->mmap3.pid; + } + perf_sample__fprintf_start(script, sample, thread, evsel, + PERF_RECORD_MMAP3, stdout); + perf_event__fprintf(event, machine, stdout); + thread__put(thread); + return 0; +} + static int process_switch_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, @@ -2498,6 +2530,7 @@ static int __cmd_script(struct perf_script *script) if (script->show_mmap_events) { script->tool.mmap = process_mmap_event; script->tool.mmap2 = process_mmap2_event; + script->tool.mmap3 = process_mmap3_event; } if (script->show_switch_events || (scripting_ops && scripting_ops->process_switch)) script->tool.context_switch = process_switch_event; -- 2.26.2