Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1232691imm; Tue, 5 Jun 2018 11:05:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKBxiVl6MgMo4U4KozIf/BkGSjY8KFyO8RrhHUYAQJeilUXkawbeyAjSSMtp+s0LrJKdDiE X-Received: by 2002:a63:7419:: with SMTP id p25-v6mr22323498pgc.24.1528221904908; Tue, 05 Jun 2018 11:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221904; cv=none; d=google.com; s=arc-20160816; b=e04/W0L4wE8Ena5wcm8pvRArHOhTMeIzc9vPm+1Ch5vfdzJDz9KY7O+G/aUF2dr/km vtePIa650RAkJK+VAmyT4a5T7jItO3r4ozVO4DqhlgQAwnIFVRd1wKL68Ijs3HoRMhxS 61Zzx6dFI0kq/hb0F96W9k3c82vYC5nNqP6Eni63O3vwVyYY+ZOtzswlKViB4y0237/V 52QxAqSAUnYksJaEhTrFA3GY9nb+QuMrqS5LRoTOwlH8dWiw07DtI9NxcxCBIPGP3Qdw JfBL2gyGIfNv1fBzdJmYK+Wwz23L5kWCB8yI/4omjcDFnR+ewcJxiNWrB00HB6j9qOQI 0h8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7qepb7nM6iR/MfZ7aktPwtOIaMFXz7N8BNU0twi/1HE=; b=QeK0tuPKj4ubXKhkCP2GonW2Wa9lHfvCImL4J53GyNSHH4gBVk/KjjG6O/fPg3n0om y1OGiQhI7sCd2EPVxx6rkPvhh+rBlKqqKssAs7KeAlVDZxw9tMptXeYoXSxDO5vRUFwj QGRWu5YeFLlZwXim2jBAwMH9S4fAV9z4qq3gV4HWC4i62HvHLsr1+pdRqO8VkP4EHl6j LK1cc4fxn3xFS0/rdltbwzvDqXl065UjCAJuuMGQm6qA20LjVIpzgwBC5LhrVGLAiRO+ szvI71qj1Huhxc2lTVqmC89tpN+Tj2xnfVH3Rbs+lW5AZMk9FHpIT6HCWWUQoF4tRZi2 r8TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ba31SMAd; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1-v6si22070246pgc.100.2018.06.05.11.04.50; Tue, 05 Jun 2018 11:05:04 -0700 (PDT) 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=@kernel.org header.s=default header.b=ba31SMAd; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752264AbeFERvS (ORCPT + 99 others); Tue, 5 Jun 2018 13:51:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:45724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752196AbeFERvP (ORCPT ); Tue, 5 Jun 2018 13:51:15 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 100402075B; Tue, 5 Jun 2018 17:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528221074; bh=iGfZH9PtDXq3y1SCOctBzF/Q1E3OJ9AzAblbCobPsFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ba31SMAdvUkVgyBNNpJTrOeAxXLYGTCoK430OHZrxAhAvIewavXx3rRk/qc0uu55r OAIauDw+j2Hi9QijCPggOvmFSDLjcirM5LKKoyMJtHSyQ40CKNyMdOfYU6V2TJ0ZQe aWowJPdcTCintVBtt+lkjAMENNX+KEHXykUIShTs= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 11/46] perf annotate: Introduce symbol__hists() Date: Tue, 5 Jun 2018 14:49:55 -0300 Message-Id: <20180605175030.32549-12-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180605175030.32549-1-acme@kernel.org> References: <20180605175030.32549-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo In this case we're wanting just notes->src->histograms, allocating it if needed. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-4iatualjskia7sojmdb65cmm@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index a5a6d686004e..467bae0279ce 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -863,18 +863,38 @@ static struct annotation *symbol__get_annotation(struct symbol *sym, bool cycles return notes; } +static struct annotated_source *symbol__hists(struct symbol *sym) +{ + struct annotation *notes = symbol__annotation(sym); + + if (notes->src == NULL) { + notes->src = annotated_source__new(); + if (notes->src == NULL) + return NULL; + goto alloc_histograms; + } + + if (notes->src->histograms == NULL) { +alloc_histograms: + annotated_source__alloc_histograms(notes->src, symbol__size(sym), + symbol_conf.nr_events); + } + + return notes->src; +} + static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, struct perf_evsel *evsel, u64 addr, struct perf_sample *sample) { - struct annotation *notes; + struct annotated_source *src; if (sym == NULL) return 0; - notes = symbol__get_annotation(sym, false); - if (notes == NULL) + src = symbol__hists(sym); + if (src == NULL) return -ENOMEM; - return __symbol__inc_addr_samples(sym, map, notes->src, evsel->idx, addr, sample); + return __symbol__inc_addr_samples(sym, map, src, evsel->idx, addr, sample); } static int symbol__account_cycles(u64 addr, u64 start, -- 2.14.3