Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7429223imu; Tue, 22 Jan 2019 06:01:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN6IrdTl3lOnfi8/sCaqCkV90ist2pbnYZMfVQnShAJ9Z8Lrs5cS0/8USR24u2ChTufFYrkq X-Received: by 2002:a63:ee0e:: with SMTP id e14mr31269361pgi.8.1548165712124; Tue, 22 Jan 2019 06:01:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548165711; cv=none; d=google.com; s=arc-20160816; b=PThth/ZXhEWLYHZLodEM/ETILDi74coHCuFCitHQfXnfh1p9eofgo7i1jg3sqC+DAx VyAT4JrcfnUpNgj7+yU/sTKr/k6gq3/8hA1eSTNvpi8Brj+ZsJ8fDOO+V8DRSOFaBHZJ hZaHosHlT5OA7GNlSlLYmWSii2u6/fq1HPJz36C3+fmOKVPia3icERGJ1DnFBZczD/W7 0rKg5F//Ft92z6NHnToQ0n1/xoe8lsFA5+QgRZ5czoYON5tVNlsJ8QV6JpUcw1CKsY7A wuTHQF3Cn7ERS+UnFNYXFXEWWFoAwpua1Lrbdfunmi8I94qnlqj1aRwXaIfFzZjgzLba ja8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hMseRtJhRm+11ktugtcMJgFdVHoAD4cC0odRGXHam+8=; b=pwlW3YcBItrLbEttyLD0y279Nhwn+wR97IbCx/cY4dYT9qp+uPX2cXqGjfPvj+xzW9 RV8f8Q0b/7de7SqDXaOeUucPNMz8xBD6WCGnBOxWH5szBmWJ1iz19UUPgX/0zlFnSqq2 ryzwk6o5pOACgfA+HUH2aWe/FAMmZciHSOkc/ZohLAOlGDSZH+JV6m23klCHWOLhcPZl goh4qfVInUNrCdYyLQGnIYUClYPEgZe/QwISfQDDWtAYIoZCELY+/SGV0UtGa7pw+Yz7 i2wYqmXuATcY6duZKCf/dHaR0pBv7jnzvCJ1/+OMqPCyRAEkEdo9SBHXItDBYSiGkiZD M5fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tdmvdvwN; 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 h191si10138258pgc.302.2019.01.22.06.01.35; Tue, 22 Jan 2019 06:01:51 -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=@kernel.org header.s=default header.b=tdmvdvwN; 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 S1728697AbfAVN7F (ORCPT + 99 others); Tue, 22 Jan 2019 08:59:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:41782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbfAVN7F (ORCPT ); Tue, 22 Jan 2019 08:59:05 -0500 Received: from quaco.ghostprotocols.net (unknown [189.16.122.195]) (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 0094721019; Tue, 22 Jan 2019 13:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548165544; bh=eFCV2I0SuRanve7T87d5UFTNQZX8eA+dD9s9Tx4QdpU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tdmvdvwNbowWClLwsVn3B9pXPeFKiDH7YIgiUD8QcPleunfnSbH7wr9eRXdgc1yrh W73Og8b3CT4EAtLQBnFRpewN1UeeeziWAzeEA4pCWP9FaFQitv/BYjxv25FEZfMtAh ppv0lHMAmqX6COgtrazhmyMnpz5KWdnHS5+cS9hE= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2D60140355; Tue, 22 Jan 2019 11:59:01 -0200 (-02) Date: Tue, 22 Jan 2019 11:59:01 -0200 From: Arnaldo Carvalho de Melo To: Davidlohr Bueso Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 6/7] perf hist: Use cached rbtrees Message-ID: <20190122135901.GE14973@kernel.org> References: <20181206191819.30182-1-dave@stgolabs.net> <20181206191819.30182-7-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181206191819.30182-7-dave@stgolabs.net> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Dec 06, 2018 at 11:18:18AM -0800, Davidlohr Bueso escreveu: > At the cost of an extra pointer, we can avoid the O(logN) cost > of finding the first element in the tree (smallest node), which > is something heavily required for histograms. Specifically, the > following are converted to rb_root_cached, and users accordingly: > > hist::entries_in_array > hist::entries_in > hist::entries > hist::entries_collapsed > hist_entry::hroot_in > hist_entry::hroot_out CC /tmp/build/perf/util/hist.o ui/browsers/hists.c: In function ‘hierarchy_set_folding’: ui/browsers/hists.c:511:21: error: passing argument 1 of ‘rb_first’ from incompatible pointer type [-Werror=incompatible-pointer-types] for (nd = rb_first(&he->hroot_out); nd; nd = rb_next(nd)) { ^~~~~~~~~~~~~~ In file included from ui/browsers/hists.c:8: /home/acme/git/perf/tools/include/linux/rbtree.h:83:24: note: expected ‘const struct rb_root *’ but argument is of type ‘struct rb_root_cached *’ extern struct rb_node *rb_first(const struct rb_root *); ^~~~~~~~ ui/browsers/hists.c: In function ‘__hist_browser__set_folding’: ui/browsers/hists.c:569:16: error: passing argument 1 of ‘rb_first’ from incompatible pointer type [-Werror=incompatible-pointer-types] nd = rb_first(&browser->hists->entries); ^~~~~~~~~~~~~~~~~~~~~~~~ So I added this on top, please check: diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index f8913723a99a..85790a4d1842 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -508,7 +508,7 @@ static int hierarchy_set_folding(struct hist_browser *hb, struct hist_entry *he, struct hist_entry *child; int n = 0; - for (nd = rb_first(&he->hroot_out); nd; nd = rb_next(nd)) { + for (nd = rb_first_cached(&he->hroot_out); nd; nd = rb_next(nd)) { child = rb_entry(nd, struct hist_entry, rb_node); percent = hist_entry__get_percent_limit(child); if (!child->filtered && percent >= hb->min_pcnt) @@ -566,7 +566,7 @@ __hist_browser__set_folding(struct hist_browser *browser, bool unfold) struct rb_node *nd; struct hist_entry *he; - nd = rb_first(&browser->hists->entries); + nd = rb_first_cached(&browser->hists->entries); while (nd) { he = rb_entry(nd, struct hist_entry, rb_node); @@ -1738,7 +1738,7 @@ static void ui_browser__hists_init_top(struct ui_browser *browser) struct hist_browser *hb; hb = container_of(browser, struct hist_browser, b); - browser->top = rb_first(&hb->hists->entries); + browser->top = rb_first_cached(&hb->hists->entries); } } @@ -2649,7 +2649,7 @@ add_socket_opt(struct hist_browser *browser, struct popup_action *act, static void hist_browser__update_nr_entries(struct hist_browser *hb) { u64 nr_entries = 0; - struct rb_node *nd = rb_first(&hb->hists->entries); + struct rb_node *nd = rb_first_cached(&hb->hists->entries); if (hb->min_pcnt == 0 && !symbol_conf.report_hierarchy) { hb->nr_non_filtered_entries = hb->hists->nr_non_filtered_entries; @@ -2669,7 +2669,7 @@ static void hist_browser__update_percent_limit(struct hist_browser *hb, double percent) { struct hist_entry *he; - struct rb_node *nd = rb_first(&hb->hists->entries); + struct rb_node *nd = rb_first_cached(&hb->hists->entries); u64 total = hists__total_period(hb->hists); u64 min_callchain_hits = total * (percent / 100); diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index dfab3deef028..74414ccd8c84 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c @@ -401,7 +401,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, } static void perf_gtk__add_hierarchy_entries(struct hists *hists, - struct rb_root *root, + struct rb_root_cached *root, GtkTreeStore *store, GtkTreeIter *parent, struct perf_hpp *hpp, @@ -415,7 +415,7 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists, u64 total = hists__total_period(hists); int size; - for (node = rb_first(root); node; node = rb_next(node)) { + for (node = rb_first_cached(root); node; node = rb_next(node)) { GtkTreeIter iter; float percent; char *bf; @@ -578,7 +578,7 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists, gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); g_object_unref(GTK_TREE_MODEL(store)); - perf_gtk__add_hierarchy_entries(hists, &hists->entries.rb_root, store, + perf_gtk__add_hierarchy_entries(hists, &hists->entries, store, NULL, &hpp, min_pcnt); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);