Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3767230pxb; Tue, 17 Nov 2020 03:04:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfNTzxDTEQ+JAlaCNnC6KGwkslmeSEJsKBwZ1sco0Y3wKYgueGciVfPaFrPGrgRZiRW5mz X-Received: by 2002:a5d:6250:: with SMTP id m16mr7149133wrv.400.1605611077010; Tue, 17 Nov 2020 03:04:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605611076; cv=none; d=google.com; s=arc-20160816; b=cuyaiLj9SYPQEiIZQZUyk1X2FOQnIPNHCWyefIr0VRlVCYDsc9iVaCH5QC6/jCRpvm CCH1DfA9+E67j0dclCss17PQF8DoGp50JXWLQX03IF43aXfJSAAEcUE8A/br6alB1QcA vV3yFuGwfPaM3IDcKv8hM+2oaMiLituaxN67YJTpVqWu0BWuB/dTjMZ2EHO3oZgww33+ 2RS6lewFg22ISWRSprAOHCCKGJofIFp9zaF5cJzUP7B4F2pNqXKqWemg5CcSx2iMsBUz K/WY6JheNKz690CpxbOl4Op9bkN1pdsbqczwTXcG+OHdpXl6qDUobOWJM9uPbD82vH2/ HbnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=giqXxztKyor7YzVpjVR8viRVEBiEbqtTXMBhBtpmZtY=; b=HrACIECmHuNl3G+eEij4w1kEx4XoX2so1o6NGtjFUqqBOB+Vs9UZbevmwaexzB24Xs DcVLgiNCjO16jaQswNlmSez8P2/ydsVKGzV41qhkGk1K7Taei2U3G/bdXEFvBg76pOIa 1jPO1nicaZqstCONiy+q5w5gY359sJCX4yh8d82/2uicmgW9rjCaDFozEbU0IXq0GKwv o0zndd6acw3BLltD9Y01F2M/+EfhMUqs9D4KgKlU8juhtAXpKEp8n4vgHlLjco0iilTk +UtlwZ3F/s150W33wYPHTMATiB6rI3vqnAyUg/V7/wPdR4bG2UF6kNZuSWUN0IeUAZGD c+WQ== 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 n25si89997eda.190.2020.11.17.03.04.13; Tue, 17 Nov 2020 03:04:36 -0800 (PST) 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 S1728392AbgKQLCE convert rfc822-to-8bit (ORCPT + 99 others); Tue, 17 Nov 2020 06:02:04 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:21065 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728387AbgKQLCD (ORCPT ); Tue, 17 Nov 2020 06:02:03 -0500 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-364-l4ZGj_44N9OQaX4oKFGVmg-1; Tue, 17 Nov 2020 06:01:59 -0500 X-MC-Unique: l4ZGj_44N9OQaX4oKFGVmg-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 E4A191060B76; Tue, 17 Nov 2020 11:01:57 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id E64465C1CF; Tue, 17 Nov 2020 11:01:54 +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 , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 16/24] perf tools: Add support to display build id for mmap2 events Date: Tue, 17 Nov 2020 12:00:45 +0100 Message-Id: <20201117110053.1303113-17-jolsa@kernel.org> In-Reply-To: <20201117110053.1303113-1-jolsa@kernel.org> References: <20201117110053.1303113-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding support to display build id in mmap2 events: $ perf script --show-mmap-events | head -4 swapper ... @ 0xffffffff81000000 ]: ---p [kernel.kallsyms]_text swapper ... @ 0 <5f62adb730272c9417883ae8b8a8ec224df8cddd>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/firmware/qemu_fw_cfg.ko swapper ... @ 0 ]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/char/virtio_console.ko swapper ... @ 0 <86441a4c5b2c2ff5b440682f4c612bd4b426eb5c>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/lib/libcrc32c.ko $ perf report -D | grep MMAP2 | head -4 0 0 ... @ 0xffffffff81000000 ]: ---p [kernel.kallsyms]_text 0 0 ... @ 0 <5f62adb730272c9417883ae8b8a8ec224df8cddd>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/firmware/qemu_fw_cfg.ko 0 0 ... @ 0 ]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/char/virtio_console.ko 0 0 ... @ 0 <86441a4c5b2c2ff5b440682f4c612bd4b426eb5c>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/lib/libcrc32c.ko Adding build id data into <> brackets. Signed-off-by: Jiri Olsa --- tools/perf/util/event.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 05616d4138a9..fbe8578e4c47 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -288,17 +288,36 @@ size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) { - return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 - " %02x:%02x %"PRI_lu64" %"PRI_lu64"]: %c%c%c%c %s\n", - event->mmap2.pid, event->mmap2.tid, event->mmap2.start, - event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, - event->mmap2.min, event->mmap2.ino, - event->mmap2.ino_generation, - (event->mmap2.prot & PROT_READ) ? 'r' : '-', - (event->mmap2.prot & PROT_WRITE) ? 'w' : '-', - (event->mmap2.prot & PROT_EXEC) ? 'x' : '-', - (event->mmap2.flags & MAP_SHARED) ? 's' : 'p', - event->mmap2.filename); + if (event->header.misc & PERF_RECORD_MISC_MMAP_BUILD_ID) { + char sbuild_id[SBUILD_ID_SIZE]; + struct build_id bid; + + build_id__init(&bid, event->mmap2.build_id, + event->mmap2.build_id_size); + build_id__sprintf(&bid, sbuild_id); + + return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 + " <%s>]: %c%c%c%c %s\n", + event->mmap2.pid, event->mmap2.tid, event->mmap2.start, + event->mmap2.len, event->mmap2.pgoff, sbuild_id, + (event->mmap2.prot & PROT_READ) ? 'r' : '-', + (event->mmap2.prot & PROT_WRITE) ? 'w' : '-', + (event->mmap2.prot & PROT_EXEC) ? 'x' : '-', + (event->mmap2.flags & MAP_SHARED) ? 's' : 'p', + event->mmap2.filename); + } else { + return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 + " %02x:%02x %"PRI_lu64" %"PRI_lu64"]: %c%c%c%c %s\n", + event->mmap2.pid, event->mmap2.tid, event->mmap2.start, + event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, + event->mmap2.min, event->mmap2.ino, + event->mmap2.ino_generation, + (event->mmap2.prot & PROT_READ) ? 'r' : '-', + (event->mmap2.prot & PROT_WRITE) ? 'w' : '-', + (event->mmap2.prot & PROT_EXEC) ? 'x' : '-', + (event->mmap2.flags & MAP_SHARED) ? 's' : 'p', + event->mmap2.filename); + } } size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp) -- 2.26.2