Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2468261pxu; Mon, 14 Dec 2020 03:09:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7Zmd1NcoiHXAISTvJMuUXhAu7hARxhDksrBaM7n5tfJZJH8VZ38PJb0KPP77X8qEqlmqz X-Received: by 2002:aa7:d154:: with SMTP id r20mr25463272edo.258.1607944197844; Mon, 14 Dec 2020 03:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607944197; cv=none; d=google.com; s=arc-20160816; b=A23gjfohpFrsvjRc6zjRG9NbdyjcZZBdzE1E4UaY5bij5IuIcT6Axr2bsWOcm1pSzr djZsBjbAcGfz1LvdNhAJDO5ZxWvwxZuMeH56LKF5ZUUcR1CJtqxIee272ROzUeO14dQg X+tXtSvLD/gTMn+9kJ5wyFvNF8pKCoPXYiHjYjPycnVWSJ81NmLGP4kmpY5qeNAfsRwi 2lIrLwu7R7WSW24yYcRZS3WRdaW4rOfCDl+2S7aihD19P7joP91aBlWue97ikrxViIc6 lPW4ubNqAYT8Dqbhuo1zPx5dwaql2eiWeWqKUc5JMxqIfU31S9Tqf8s35G5bSDvafKCl RvXw== 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=V81/VhNMiTz/Khzff91Umqt7qup3t0C9Z18dVQBUYyg=; b=REf6NdK+Fo6nb039aGM49+DxQHjEkMMbEj0mm7Kbu+QyNd1Oar3UlsgOj9y46rRZ9+ UA51fT0xScniRKjzX3sU1fAMxhSIKD3oyIuJONg1Hn8WYxgHG1C498Yx/vq+7witO0wN spvKd3LSUr1/MSTaHIs2vb5+OAAOrvzGkAytr6n5WAIeVM4N4FEkpX3t41HqF0bRyr2Y YbjmqGEMVEd7Apu4uPZYDmCGRmpSsuSmoPfYc1lN45rsAx7/9C8zJ9vDf7sWfrQbX4MM XXxY8SWtyMisNn/ldKPJOyzAlyEAMZS7zLvgHiesjYjD/y0M6l1sOKWGM8FO24/XrJSs Mewg== 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 u24si5888208ejb.106.2020.12.14.03.09.35; Mon, 14 Dec 2020 03:09:57 -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 S2407404AbgLNK5r convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Dec 2020 05:57:47 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:56604 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407343AbgLNK5A (ORCPT ); Mon, 14 Dec 2020 05:57:00 -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-149-qgEGsDKMMi6b2TwnfViS_A-1; Mon, 14 Dec 2020 05:56:05 -0500 X-MC-Unique: qgEGsDKMMi6b2TwnfViS_A-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 AA0C3107ACE3; Mon, 14 Dec 2020 10:56:03 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.194.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AC687048B; Mon, 14 Dec 2020 10:56:00 +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 , Alexei Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 10/15] perf tools: Synthesize build id for kernel/modules/tasks Date: Mon, 14 Dec 2020 11:54:52 +0100 Message-Id: <20201214105457.543111-11-jolsa@kernel.org> In-Reply-To: <20201214105457.543111-1-jolsa@kernel.org> References: <20201214105457.543111-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 build id to synthesized mmap2 events for everything - kernel/modules/tasks. Signed-off-by: Jiri Olsa --- tools/perf/util/synthetic-events.c | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c index c209377106f5..a8d951a79f5e 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -347,6 +347,31 @@ static bool read_proc_maps_line(struct io *io, __u64 *start, __u64 *end, } } +static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event, + bool is_kernel) +{ + struct build_id bid; + int rc; + + if (is_kernel) + rc = sysfs__read_build_id("/sys/kernel/notes", &bid); + else + rc = filename__read_build_id(event->filename, &bid) > 0 ? 0 : -1; + + if (rc == 0) { + memcpy(event->build_id, bid.data, sizeof(bid.data)); + event->build_id_size = (u8) bid.size; + event->header.misc |= PERF_RECORD_MISC_MMAP_BUILD_ID; + event->__reserved_1 = 0; + event->__reserved_2 = 0; + } else { + if (event->filename[0] == '/') { + pr_debug2("Failed to read build ID for %s\n", + event->filename); + } + } +} + int perf_event__synthesize_mmap_events(struct perf_tool *tool, union perf_event *event, pid_t pid, pid_t tgid, @@ -453,6 +478,9 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool, event->mmap2.pid = tgid; event->mmap2.tid = pid; + if (symbol_conf.buildid_mmap2) + perf_record_mmap2__read_build_id(&event->mmap2, false); + if (perf_tool__process_synth_event(tool, event, machine, process) != 0) { rc = -1; break; @@ -633,6 +661,8 @@ int perf_event__synthesize_modules(struct perf_tool *tool, perf_event__handler_t memcpy(event->mmap2.filename, pos->dso->long_name, pos->dso->long_name_len + 1); + + perf_record_mmap2__read_build_id(&event->mmap2, false); } else { size = PERF_ALIGN(pos->dso->long_name_len + 1, sizeof(u64)); event->mmap.header.type = PERF_RECORD_MMAP; @@ -1053,6 +1083,8 @@ static int __perf_event__synthesize_kernel_mmap(struct perf_tool *tool, event->mmap2.start = map->start; event->mmap2.len = map->end - event->mmap.start; event->mmap2.pid = machine->pid; + + perf_record_mmap2__read_build_id(&event->mmap2, true); } else { size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), "%s%s", machine->mmap_name, kmap->ref_reloc_sym->name) + 1; -- 2.26.2