Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1231960imm; Tue, 5 Jun 2018 11:04:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKftvZgfcDQIzOfXeEOxaaWV+00eLi4E1xGO+3YJwtYxtRptNyGGNaxXYNMl4ygP3z+Q+yR X-Received: by 2002:a62:c45a:: with SMTP id y87-v6mr26977363pff.190.1528221862764; Tue, 05 Jun 2018 11:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221862; cv=none; d=google.com; s=arc-20160816; b=bWBG91LSKPh1QyHYMIrJFhjLYbNkk5lJ+3+PDBEmJykhC4dbn4km4jm9fOC+VTKOE1 OY+nfho7XGvXJC8Efpd9LDrQVWiptJhO8K+zimOF4Nh2JnzR5jccUdzg2gLcFO4F4l3A L2+5LWN6qmd/v27lrNkMVBU5iFpFA78s6Zs5WoZiad3aL6OqgJG1dUheszkZdHzDwwyT qBlLptZHvPA7bQlRzyLYLlINs5iUp6o2T+qkQ/cYCFOwqwFHYSTduNNUoAK+A3wARZEp xna8/Tbyi9h+pxFuttt0JoPbjZdVXuJYA7rbNOayXGKivKZBdoZ+dp9o7YA0HARwf75y PCTA== 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=U/W8qHtxcRM85YX9CA1JsBz/zfazYgpgZyljRziTry8=; b=rrmLOcqsgIsqGlbijyoNQDqWnc/dSSCWdHISML6eiC4DOtjLclRQc6pVg2AkcQLx8i dIvkaT5UTaxvB0vkCt5/yY6QFBO0AO6Kxa8XZSwF6LsIgYN7/uI9iZ7WB75KhsL8Xmrk rPxklXTtCLbqH2b0uGTCPZ5fRtCv4OS3p2rhBLQcSfygYR5lzj/OFoNKMUgUmFLoy4+P gld8R5P/BPsMtpliOxNbodBdvkccAtEYy1peQOHMjUeKhmAxoFEI3M8mD2aMkvSt/eej Qavdky8z7V0rsq0KjfP8kbL6Zt7l+CFJBRQTgrSTSj9nK9ELvvHZLi4nSLwYN8VkyClE FWCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fgShoYK9; 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 1-v6si22981813plz.379.2018.06.05.11.04.08; Tue, 05 Jun 2018 11:04:22 -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=fgShoYK9; 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 S1751925AbeFERv0 (ORCPT + 99 others); Tue, 5 Jun 2018 13:51:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:45824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752298AbeFERvX (ORCPT ); Tue, 5 Jun 2018 13:51:23 -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 CF5E32077B; Tue, 5 Jun 2018 17:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528221083; bh=6juS7IsFrumha0YR8fD2OL6b3kgrpPslT2NtSXt5MX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fgShoYK9TKqiMCmn4HtdJOGTy23nZbsdvW4U7fI1TuTup3AZ0/0u0TZJj79Eirqmm fzeWjpt0ruQVlU1p0kfvDy3EmS8BfjsQkSpkUFg9dHQ9p+RSqdhkeMDE7pFB6RZJz3 J80IAoTeIjmoy6LjR9aoHMEJLINf3OyLGapmiqlo= 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 14/46] perf annotate: Replace symbol__alloc_hists() with symbol__hists() Date: Tue, 5 Jun 2018 14:49:58 -0300 Message-Id: <20180605175030.32549-15-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 Its a bit shorter, so ditch the old symbol__alloc_hists() function. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-m7tienxk7dijh5ln62yln1m9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-top.c | 8 +------- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 21 ++------------------- tools/perf/util/annotate.h | 2 +- 4 files changed, 5 insertions(+), 28 deletions(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index bc71e899096d..04fe04885e99 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -123,14 +123,9 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he) } notes = symbol__annotation(sym); - if (notes->src != NULL) { - pthread_mutex_lock(¬es->lock); - goto out_assign; - } - pthread_mutex_lock(¬es->lock); - if (symbol__alloc_hist(sym) < 0) { + if (!symbol__hists(sym, top->evlist->nr_entries)) { pthread_mutex_unlock(¬es->lock); pr_err("Not enough memory for annotating '%s' symbol!\n", sym->name); @@ -140,7 +135,6 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he) err = symbol__annotate(sym, map, evsel, 0, NULL); if (err == 0) { -out_assign: top->sym_filter_entry = he; } else { char msg[BUFSIZ]; diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 8be40fa903aa..3bfe17e176fe 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -410,7 +410,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, notes = symbol__annotation(dl->ops.target.sym); pthread_mutex_lock(¬es->lock); - if (notes->src == NULL && symbol__alloc_hist(dl->ops.target.sym) < 0) { + if (!symbol__hists(dl->ops.target.sym, evsel->evlist->nr_entries)) { pthread_mutex_unlock(¬es->lock); ui__warning("Not enough memory for annotating '%s' symbol!\n", dl->ops.target.sym->name); diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 7c194b04a2da..bcd5d3e17b85 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -689,7 +689,7 @@ static struct annotated_source *annotated_source__new(void) return src; } -static void annotated_source__delete(struct annotated_source *src) +static __maybe_unused void annotated_source__delete(struct annotated_source *src) { if (src == NULL) return; @@ -729,23 +729,6 @@ static int annotated_source__alloc_histograms(struct annotated_source *src, return src->histograms ? 0 : -1; } -int symbol__alloc_hist(struct symbol *sym) -{ - size_t size = symbol__size(sym); - struct annotation *notes = symbol__annotation(sym); - - notes->src = annotated_source__new(); - if (notes->src == NULL) - return -1; - - if (annotated_source__alloc_histograms(notes->src, size, symbol_conf.nr_events) < 0) { - annotated_source__delete(notes->src); - notes->src = NULL; - return -1; - } - return 0; -} - /* The cycles histogram is lazily allocated. */ static int symbol__alloc_hist_cycles(struct symbol *sym) { @@ -868,7 +851,7 @@ static struct cyc_hist *symbol__cycles_hist(struct symbol *sym) return notes->src->cycles_hist; } -static struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists) +struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists) { struct annotation *notes = symbol__annotation(sym); diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 2a73f9084930..7ad503fbff74 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -292,7 +292,7 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol *ams, int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample, struct perf_evsel *evsel, u64 addr); -int symbol__alloc_hist(struct symbol *sym); +struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists); void symbol__annotate_zero_histograms(struct symbol *sym); int symbol__annotate(struct symbol *sym, struct map *map, -- 2.14.3