Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4093688ybv; Mon, 10 Feb 2020 12:10:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyncqoj4RJYY3oORVmb81uaq5jtPI/7OuNeFzrzgxk7hEkay0QiLTW/aRvE5Rm1dhzw7+4Q X-Received: by 2002:a05:6830:95:: with SMTP id a21mr2384615oto.171.1581365431760; Mon, 10 Feb 2020 12:10:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581365431; cv=none; d=google.com; s=arc-20160816; b=o21QHnMpZlqLJ9UnhRaN3sIBvnuWh8rKAOqirzVO6sIF8BvrOCWEYd/8cMCmf85umP dk0Q1994y+ZKwLH0peHJMeXY774querBYlHFLSsAxL90TjmdHh03uqpAJ5iGbXMn3hVT 3VEV8mbjacJcNixcCZI3Gp9Z790la3qeJle7WKJIDY2mgWZIanRinZycllRIJFzaX0kN dP8v76rnDtqVjoI5OFNg0zJdSI1RUUYYRjaIguWd+dbOo4g85NxR1QSQsirqBrGDXh9B ptd6Fb8Nxyaxj6rXd7leflhX/tGYxeozPc+X+SQIHieT3oM6bqsLrgbVHDUaazqyJ7JK WjNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zefW9F6cB3PjlP2xIHsQltDrSp4Pn5FgnQMxBmPCTg4=; b=PnDWdKMjN+n8JXWgRMrI+6Ep5kUVY4QYEPu463XzwBIWWIpm+LVahqOFBVKbFcsLhh tXTZPIbkcs3Pf2RaJDpK/puSS9cC2a8PLoRlRu1295xv38PwPmL2vafjJmtJ/87Y7/wW RtvRIxmJ59/e+Pnvn/PsHzOeBlNgKDgyezCNdZU8o5AAuOA925bFaaOWMyY5FGNvhoDe sKqG6j6RyDLmrFRk7oetd5dfk+7wg9FSwGHW51QI6ckVIrOfJUo1nwc0NULKLLthABZr 80SvwhRHOuhh8GhYxsxVaeTCDnfag/CVLABQ2/JKcgwHIuFrStsuyK7fjM6vq2+zfpcw hS/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ma6w1DXV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l20si659520otr.202.2020.02.10.12.10.20; Mon, 10 Feb 2020 12:10:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ma6w1DXV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbgBJUJN (ORCPT + 99 others); Mon, 10 Feb 2020 15:09:13 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:29375 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727121AbgBJUJN (ORCPT ); Mon, 10 Feb 2020 15:09:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581365352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zefW9F6cB3PjlP2xIHsQltDrSp4Pn5FgnQMxBmPCTg4=; b=Ma6w1DXVoAXZonZhfW4Tq12yjqW1f03p3mNP7mZgMBrC1a213Ay0nEz5g4Q3T3BBi/nR8q ssM5OdNwCa9osOzjBxB2OTnR4ckwLm8Kng954x3lvBmpMzbOmyGrT+rV913ulfcg2A6Biw /qQToO3J7/sGL7lhsJKCmeVuU8cm/o0= 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-373-N4bxFSCuNXCOvtTBjrK68w-1; Mon, 10 Feb 2020 15:09:02 -0500 X-MC-Unique: N4bxFSCuNXCOvtTBjrK68w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 987181857342; Mon, 10 Feb 2020 20:09:00 +0000 (UTC) Received: from krava (ovpn-204-37.brq.redhat.com [10.40.204.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3743E87B01; Mon, 10 Feb 2020 20:08:58 +0000 (UTC) Date: Mon, 10 Feb 2020 21:08:47 +0100 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Ravi Bangoria , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCHv2 2/4] perf tools: Mark ksymbol dsos with kernel type Message-ID: <20200210200847.GA36715@krava> References: <20200210143218.24948-1-jolsa@kernel.org> <20200210143218.24948-3-jolsa@kernel.org> <20200210151759.GB25639@kernel.org> <20200210152537.GA28110@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200210152537.GA28110@krava> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 04:25:37PM +0100, Jiri Olsa wrote: > On Mon, Feb 10, 2020 at 12:17:59PM -0300, Arnaldo Carvalho de Melo wrote: > > Em Mon, Feb 10, 2020 at 03:32:16PM +0100, Jiri Olsa escreveu: > > > We add ksymbol map into machine->kmaps, so it needs to be > > > created as 'struct kmap', which is dependent on its dso > > > having kernel type. > > > > > > Reported-by: Ravi Bangoria > > > Tested-by: Ravi Bangoria > > > Signed-off-by: Jiri Olsa > > > --- > > > tools/perf/util/machine.c | 10 ++++++++-- > > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > > > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c > > > index e3e5490f6de5..0a43dc83d7b2 100644 > > > --- a/tools/perf/util/machine.c > > > +++ b/tools/perf/util/machine.c > > > @@ -727,8 +727,14 @@ static int machine__process_ksymbol_register(struct machine *machine, > > > struct map *map = maps__find(&machine->kmaps, event->ksymbol.addr); > > > > > > if (!map) { > > > - map = dso__new_map(event->ksymbol.name); > > > - if (!map) > > > + struct dso *dso = dso__new(event->ksymbol.name); > > > + > > > + if (dso) { > > > + dso->kernel = DSO_TYPE_KERNEL; > > > + map = map__new2(0, dso); > > > + } > > > + > > > + if (!dso || !map) > > > > We leak dso if map creation fails? > > yep :-\ will post v2 v2 attached, it's also all in my perf/top branch thanks, jirka --- We add ksymbol map into machine->kmaps, so it needs to be created as 'struct kmap', which is dependent on its dso having kernel type. Reported-by: Ravi Bangoria Tested-by: Ravi Bangoria Signed-off-by: Jiri Olsa --- tools/perf/util/machine.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index e3e5490f6de5..0ad026561c7f 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -727,9 +727,17 @@ static int machine__process_ksymbol_register(struct machine *machine, struct map *map = maps__find(&machine->kmaps, event->ksymbol.addr); if (!map) { - map = dso__new_map(event->ksymbol.name); - if (!map) + struct dso *dso = dso__new(event->ksymbol.name); + + if (dso) { + dso->kernel = DSO_TYPE_KERNEL; + map = map__new2(0, dso); + } + + if (!dso || !map) { + dso__put(dso); return -ENOMEM; + } map->start = event->ksymbol.addr; map->end = map->start + event->ksymbol.len; -- 2.24.1