Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp881537pxb; Thu, 12 Nov 2020 20:40:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJybemC7E6AlMilYXZGRWVsBlpla26v+Tqjb/YXyJyeUKJxp2FcCM8S6cAgOEumHyJN+gk1X X-Received: by 2002:a05:6402:143:: with SMTP id s3mr619120edu.267.1605242453266; Thu, 12 Nov 2020 20:40:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605242453; cv=none; d=google.com; s=arc-20160816; b=eALKSSLX+NWQfOfp/uHu8xt6yyntX6Ms7UyuBCpRvTf5AOugEr5wf9l+dNLJKR1kgw z8ZemLa1uMj6ro6R93gXytBKPPi0HpdigjpRW3efYh2KtGdr9jluO1gkq0Fs7+oegzdn sO7svgtT39D7gOz6BNfyH0JPh9GcbFExZ1fCJo36+CZ6xhLwpCAuxvCxZJ73/BL2JaDA 46qoWzKkoWCheo0ykJs4NzD4yP7flKRbqv8C7q2MBU0+xUi/DFhCwBvGtLTM1GLamJ8B qJnu13C1E50RmLEeWkreXCiCcNgXRX9VvL4D64MNa8noe0bDd0X3MxPg5zSyOjCZlEVA E6fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=DgCxaBiQW6UzX3uY7y+ChG5KYfVfI0G9jTipnpbluV8=; b=1GsV39YswRs4YE1YVSphUW+IfqTFW3VFBgwz5IYteU98OWxw95mMHQXTg5aDuYi/wY L07h+b9gtteSqiDhX8K2GIhHhLYsI2MpQawNUSUVjLPj9wMbgUCcrg8Q9kr84KX+Dw65 XzthLx2xKTpYFtz1yeZ2owsTAGAyilAKu9piYdX+opIJJO5Xnf47CQxVhc+wxtIWW56t o1rO6wh12o08KVM0mZ3eo7WGpAAd4rLwvBTUXUKrpljp1WygS8g8S5+N7dkiIdyT+imF rPmLp+ZMzum/CE45vQoZnhSdr7/BQB9pTA6x5fiB79aNeeXR+IVVnNg6dyVS09Cs44/5 g+cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hK97h6VH; 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 b27si81223eje.466.2020.11.12.20.40.27; Thu, 12 Nov 2020 20:40:53 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hK97h6VH; 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 S1726146AbgKMEcb (ORCPT + 99 others); Thu, 12 Nov 2020 23:32:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbgKMEc3 (ORCPT ); Thu, 12 Nov 2020 23:32:29 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C08D3C0613D1 for ; Thu, 12 Nov 2020 20:32:29 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id i26so6095631pgl.5 for ; Thu, 12 Nov 2020 20:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DgCxaBiQW6UzX3uY7y+ChG5KYfVfI0G9jTipnpbluV8=; b=hK97h6VHw76VGxSsGxGNWIQ4WDe3WtzacRWO4oj0Jd+8wHB28ABTf90SVU/gUo+nPi 9AaF8oc9Frg2/KGugrQoU2i882XV83dzd2VS3fIN+NPBf/K4Ae1rtZjUgZm9soJTn1/C huX6KXLwao012AJuuGaTxz06WVjr4MxXvnvcbnLN+TMqa4RnIteYIyNfrp7QnJDoeZ+Y 8UY9Z2SRUz8sNr1m4tmvs103M9K7rMljEUsh7uF4zYcH2pFw1/pMmZKZCMyF2Q8wsTFn XrdS494tB8+8Ta43tY4pnvBUCYS8Mt5ERrHwaYPpr57NhFBYDsGD2l+NMqHjXMRgg3HP yqNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=DgCxaBiQW6UzX3uY7y+ChG5KYfVfI0G9jTipnpbluV8=; b=nsqce7NqGr7BBdKhwHqvPXnz+ct9+RerHUsqwRh49v82vA/I2m/P7IxoHdMOKf1bYO 4i9Pdgud+t2/7t1tRQuADSNJX+MYot2JzPpKArWHws4cBAdbOWEvnoASXCyr5B4URIPB YFx2Zql2xNA45wDOLk8Xmkghg+bLu8QUwKOEg7SCDUEITzEL6kPaTAulgz9RCcFhT2tV t/5/wiFo8vt4ybzFKC263DzMJJJC1T7QxsBNlxj69WvVVLoL9L8x8SYlADD5IeEfJSTf oRsNktE5eQMrbLSP7YAdGDJjoh3h2vMtkORpToUuZpA92CLo27G73RHSz6eo0rlCU/sB qj3w== X-Gm-Message-State: AOAM53242bvOz6p7/Smrr8rM2mSGbfwFRIjsZ1pD9Rtrt1GE+gBJ+YZ9 3Hx4z1E0O70CEETE1RkSNbA= X-Received: by 2002:a63:2d02:: with SMTP id t2mr610985pgt.306.1605241949028; Thu, 12 Nov 2020 20:32:29 -0800 (PST) Received: from google.com ([112.159.19.5]) by smtp.gmail.com with ESMTPSA id q22sm7467863pgi.33.2020.11.12.20.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 20:32:28 -0800 (PST) Sender: Namhyung Kim Date: Fri, 13 Nov 2020 13:32:22 +0900 From: Namhyung Kim To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Michael Petlan , Song Liu , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 15/24] perf tools: Synthesize build id for kernel/modules/tasks Message-ID: <20201113043222.GB167797@google.com> References: <20201109215415.400153-1-jolsa@kernel.org> <20201109215415.400153-16-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201109215415.400153-16-jolsa@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 09, 2020 at 10:54:06PM +0100, Jiri Olsa wrote: > Adding build id to synthesized mmap2 events for > everything - kernel/modules/tasks. > > Signed-off-by: Jiri Olsa > --- > tools/perf/util/synthetic-events.c | 33 ++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c > index a18ae502d765..a9d5d1ff2cad 100644 > --- a/tools/perf/util/synthetic-events.c > +++ b/tools/perf/util/synthetic-events.c > @@ -347,6 +347,32 @@ 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; > + } else { > + if (event->filename[0] == '/') { > + pr_debug2("Failed to read build ID for %s\n", > + event->filename); > + } > + memset(event->build_id, 0x0, sizeof(event->build_id)); Likewise, we should not set the misc bit here IMHO. Thanks, Namhyung > + } > + event->header.misc |= PERF_RECORD_MISC_BUILD_ID; > + event->__reserved_1 = 0; > + event->__reserved_2 = 0; > +} > + > int perf_event__synthesize_mmap_events(struct perf_tool *tool, > union perf_event *event, > pid_t pid, pid_t tgid, > @@ -453,6 +479,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 +659,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 +1081,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 >