Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1233029imm; Tue, 5 Jun 2018 11:05:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJkom3Qznqe5NqvcK3rFNw0XfgsmZ/dg4oW16DAdLm2/KMPrpcqedZSKDTiDqlUt2fL4sn+ X-Received: by 2002:a63:ad46:: with SMTP id y6-v6mr21757602pgo.10.1528221920379; Tue, 05 Jun 2018 11:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221920; cv=none; d=google.com; s=arc-20160816; b=t9Cq0sjLk/kWkclwQwRsNcO2sFYq7h1ivZEovySMl0AFPfYY30jfT+X8N3F3rEooTU XoPAXgGWtySeF/gFhwedfVlF2Ju/VzA9/9bLcQmDBHdYsMLV2BpI6fCQQCKw2/qadzcs UnPIuKrzzvZ3S8xNMWcVTthAdx0znEAFdU6ldf57hn/icYRjTPyYIr+/C4KfcHhE0bxY 4+uGXVlpVC/MG6jFd4mWpzi6LO03vUUB1+r1ERul0j/Ywn/6o8uQVZoZ0O65+H0J3eYG z5SRN4N5lMe3HkMBJ6A2Dskw8qzHcKRLD8f8VtcJ5aftInqsscezY46QOl9r3YVT0fk4 2sYQ== 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=UKMu6fBpHyla3ffyGc6JYJJEdJD961J/afY/nWlzpng=; b=a27By5TzW8MoOFRAKjH8veOpbkAcW/feyRnqwdAur2R7nxhK4dmrnWct+wqKInDMKH zEW6zosbqjBZwCNhN+lf2mDZof5p5uNE6cZq82PjDj8r4mRyrdAWH1wxMAShqf/i6Zdh JJ0cqaTo3qKSqChiiQRpHNrxxSIDBTP+qJpuwhhc7f+ztxgEfssc0XrP/ochuXlRCULp 08qrjsYwSnGiPamo7/j3jEyA6/RhKzp/zPdRb19yvvGhN6Ah8Oy4taF13R9o9g0T/kIz xsm4pU8yVydMi2tZSzMIvimjzK6+cS/eV1EUObjtOGe8m954Bitcc54CSWyEnMagIN7P Aeuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f9l4RLI9; 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 t4-v6si16755604pgp.594.2018.06.05.11.05.05; Tue, 05 Jun 2018 11:05:20 -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=f9l4RLI9; 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 S1752938AbeFESEe (ORCPT + 99 others); Tue, 5 Jun 2018 14:04:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:45740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752244AbeFERvS (ORCPT ); Tue, 5 Jun 2018 13:51:18 -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 F1A0A2077B; Tue, 5 Jun 2018 17:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528221077; bh=dqWmGhnfOiPBiOCCZPfYf11JVf9+VvaqqYYT1NCB2NY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f9l4RLI9Ijt3qFW7RPrDOJIDD2OOvyNblJWaUv9iYxOSdyC0vl+/Q40EiOR1kUq7P bwHDWY58P72BhjsZ5PsZD6Z06KSZLILAxU/Ik8mbsUqM8gpM5nkhHXr0xZ1pbvzvju ocRpZvOW8DgTY7ljOVY0fLlIe8aD1mzMFFPLECOA= 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 12/46] perf annotate: Introduce symbol__cycle_hists() Date: Tue, 5 Jun 2018 14:49:56 -0300 Message-Id: <20180605175030.32549-13-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->cycles_hist, 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-pqj81aneunhftlntm66tmhz0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 467bae0279ce..f11199f0be27 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -848,19 +848,23 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map, return 0; } -static struct annotation *symbol__get_annotation(struct symbol *sym, bool cycles) +static struct cyc_hist *symbol__cycles_hist(struct symbol *sym) { struct annotation *notes = symbol__annotation(sym); if (notes->src == NULL) { - if (symbol__alloc_hist(sym) < 0) + notes->src = annotated_source__new(); + if (notes->src == NULL) return NULL; + goto alloc_cycles_hist; } - if (!notes->src->cycles_hist && cycles) { - if (symbol__alloc_hist_cycles(sym) < 0) - return NULL; + + if (!notes->src->cycles_hist) { +alloc_cycles_hist: + symbol__alloc_hist_cycles(sym); } - return notes; + + return notes->src->cycles_hist; } static struct annotated_source *symbol__hists(struct symbol *sym) @@ -900,13 +904,13 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, static int symbol__account_cycles(u64 addr, u64 start, struct symbol *sym, unsigned cycles) { - struct annotation *notes; + struct cyc_hist *cycles_hist; unsigned offset; if (sym == NULL) return 0; - notes = symbol__get_annotation(sym, true); - if (notes == NULL) + cycles_hist = symbol__cycles_hist(sym); + if (cycles_hist == NULL) return -ENOMEM; if (addr < sym->start || addr >= sym->end) return -ERANGE; @@ -918,7 +922,7 @@ static int symbol__account_cycles(u64 addr, u64 start, start = 0; } offset = addr - sym->start; - return __symbol__account_cycles(notes->src->cycles_hist, + return __symbol__account_cycles(cycles_hist, start ? start - sym->start : 0, offset, cycles, !!start); -- 2.14.3