Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1153335pxu; Fri, 27 Nov 2020 00:36:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJx86fMoeM3Ev/cRjX5gw/nZhqcgrNMLhlzFJVgHsY12K71FsXA9GOIbBa9BKHdaVjKgMOeT X-Received: by 2002:a50:cd4a:: with SMTP id d10mr5379482edj.184.1606466184432; Fri, 27 Nov 2020 00:36:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466184; cv=none; d=google.com; s=arc-20160816; b=UoiA5r5M/d9Lzm+s3KXhPKn3ZyOzgcppipr+4Na+rLGgTXDq0XPhx4nwaTUy7JE8O/ VvJ8L0VE3XOwr4riXbOw+bvj1ofmddk1rwfGRMYoI87lRr/VUu8whKhfdsFKsyy/djET y46Lu8CHzmeogTzaAF0YDq/Zzk7Tcxk5jJr45K4oK9fpYcylLX4OJaD+w9Par2t5mH5I POKO/bxWojveAiI1i30Y74MGgwe4iWReFKv+XCa35lImiVNnhhu50Gwt3ui7emjm1iWJ EiQap8+ArKDpqnzno9FHXYPlVb7WUUXewZ/znz1xYX66fn9og3KL1lRgpTjGFVYJsVtG d39w== 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=A47uTKbj5vlJIGdvzN7bQ8BfblVjeNVbx2SWMmmyL7E=; b=ODOeteIlvB3vtwuvDS1+3qbRNOYZo572Kdn+5sBTio3M4ErW2GXyala7dldTDk5ICv URtDfpY+dEVbGKOJYz2f5zKwK63VelIKCpYJYnoW84gOF1niFnMOUkEHbvFzMRIrTMG3 q+VTMeBetV0PQQIJ0Pzet8BVVlqhHRFLHypD8EENnhuzlendZ2ZaQnAZmdeWGPwR0u8R i7i9WBIjeVozj8Ph19fmG1pTQfbF68UH83xauhAqtCd6nPXwjgRUPtGuFy11HtE9S73O psBjW0tTOhlWuyKUzF06VBRaVA+av3xxTZ9FDtMelKCtVrOpuJhltAQUdYLRmEhSca0O 4dYA== 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 p3si4830050edp.84.2020.11.27.00.36.01; Fri, 27 Nov 2020 00:36:24 -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 S2404161AbgKZRBw convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Nov 2020 12:01:52 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:37717 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404106AbgKZRBt (ORCPT ); Thu, 26 Nov 2020 12:01:49 -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-188-260xEj2mMt-sQfg1-3W0zQ-1; Thu, 26 Nov 2020 12:01:41 -0500 X-MC-Unique: 260xEj2mMt-sQfg1-3W0zQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2003A18C8C06; Thu, 26 Nov 2020 17:01:39 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ACE960BFA; Thu, 26 Nov 2020 17:01:35 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Ian Rogers , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 17/25] perf tools: Add support to display build id for mmap2 events Date: Thu, 26 Nov 2020 18:00:18 +0100 Message-Id: <20201126170026.2619053-18-jolsa@kernel.org> In-Reply-To: <20201126170026.2619053-1-jolsa@kernel.org> References: <20201126170026.2619053-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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. Acked-by: Ian Rogers 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