Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1154082pxu; Fri, 27 Nov 2020 00:37:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJf4R4yDEu+zhkEBeXqw37qTWdD/9IOShD6a+aMqCYTGe3kD5fMVCL6NornYuZ/TNIlhkf X-Received: by 2002:aa7:d883:: with SMTP id u3mr6487499edq.69.1606466270038; Fri, 27 Nov 2020 00:37:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466270; cv=none; d=google.com; s=arc-20160816; b=dUyddAbwbl64eH31jSNO4xG2wTBhUhTh5NxCPScpon7Q8OBptoTyF4cuN/dhgWjSoY 3jcC8EpoJ/fwfgGdKn2I0r4+dPIgfAdWfrrwK2/bh/8XSZQA57+wbZih7I/biHTiljvf r1Dn5OrhJWYQuvNP37xWPNMcOFf0WnU5JtlwKwAkIj/VPvof2MdAjzPxFi7IDiZ+Pr1S JxEl97BxB7MQNaPkJGHlmqeaIfZnlH+koP6G0HsHH/p5gBHevnN17MPJiwXquJZjlqZm 61VLa09wGNU0x1FjRwaN2/qOEzbItJPmJDrQHNjeTN08me6r6baIIwsjpC7LQvkoQhtg vVWA== 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=crQIDL79C04JNrs+MIaJdXqhkDqBK/xkWyuILyYTcLY=; b=EZo18C1SWbIP7xHVXUyUhDM6/lcMk0B/yO7jl1gwDynppidu3olQCV9OBtzAS0e0XG tBH4fjcXMspCPv9un2EonQMlYstsUHqPS7C83joSp63ByqyFqLHNL/8utvTgcwVMCWHR xFHj2ylnHSyo+l1KZNe4MIRQY9dMQZOtc79gzxag+a+WWAqKSnlRMSBsfNLcVQ8RPbtm 43DwDDURnkc4k8/+6KShqJRTy1EgGeuiF501+jE5As3A+Y4cV3zhJqpQj5hDtnkjG7tu qcCbRf/H9gSgWt8rcnJVk1x5+HlyKKolLwtFX80ooorvxvuNfuyk2z78CXnXI/o7//aV /vIA== 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 o22si4706485ejd.580.2020.11.27.00.37.27; Fri, 27 Nov 2020 00:37:50 -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 S2404128AbgKZRBp convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Nov 2020 12:01:45 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:38946 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404121AbgKZRBo (ORCPT ); Thu, 26 Nov 2020 12:01:44 -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-412-JU61E8ElNmG0L_wHp-IFDg-1; Thu, 26 Nov 2020 12:01:37 -0500 X-MC-Unique: JU61E8ElNmG0L_wHp-IFDg-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 BB1B0101AFA8; Thu, 26 Nov 2020 17:01:35 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC00E60BFA; Thu, 26 Nov 2020 17:01:32 +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/25] perf tools: Synthesize build id for kernel/modules/tasks Date: Thu, 26 Nov 2020 18:00:17 +0100 Message-Id: <20201126170026.2619053-17-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 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 a18ae502d765..91b1962d399c 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; @@ -630,6 +658,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; @@ -1050,6 +1080,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