Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3535719pxb; Mon, 9 Nov 2020 13:58:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpRTy7BzK6HZ9B3n3L7PW4uyX6GG5ajWvlRwSH7lQ9Blzu8VQgXc6dAqVgah1+FcqVmlau X-Received: by 2002:a17:907:c05:: with SMTP id ga5mr11958826ejc.212.1604959080615; Mon, 09 Nov 2020 13:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604959080; cv=none; d=google.com; s=arc-20160816; b=BUHLhA8Nd4/cg/4UuiBhG0L4ZUHoQ11YApepIzoW7tIF95YL5Jm12LUFsurXCAEGNR LiN+5U0KVhcnRMrw+rNdv8g5SjINIvYGc5z9YqXuFIN48c4a29mhAEc3tiUpSiRkPH5L eeVemKTTZi0kt16482I3bJGQYGPAb0byiTJIEepj+qR3I5me/bJ9xTSU23P6MU5lDpCT CSPt7OcC5yZXVwnzD//0y5BSpqZk7CDAq/73ePtVLPTO5xKNYQ8icJgC/lx84Mu7FOi6 KzqIg6E4Hikie2F37/uq16d7wKBOEE6hbBJaN+BFtl/K1G5zwLEEDWIJ4P/6W3S5/nJl uJuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=v3dfMeBA07Uxk7gqBY4kFAIJEZnBiVK3hs9jGLK6H9o=; b=JlLxqOE8V9j5ynSXUHPLMCcUAY1uVEI+C73QI9OAqoR8PVt6nHrSTYyGpHvGp6aE/G gf3TLEklogNpkJu7xj3ZeSJ7mMuW/MjSrbUBp5hqwn9I4MusaP2rqSlxdmjmfF3WCZzP dzw7rE5HlesBQGpYL5VQsh4AZLZElXoSFUS2f+AjKOglfJEdZu2r9RUpL9WaGQ8w//NB py3KgN001TqE7aimYrsTqAqoNly1O5SZYAoqbxwp5oXDpM6NhvueFnnwmGYHUcYJcb6H wF7/Rf7mIZnRHYAck0t8FdFY9mxyMoysKHDGPRQvqOtdAf5t39oBJ4DlS0gOZkycrY8z F8ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id m8si8168531edj.357.2020.11.09.13.57.38; Mon, 09 Nov 2020 13:58:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1731801AbgKIVzf convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Nov 2020 16:55:35 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:58125 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731664AbgKIVzd (ORCPT ); Mon, 9 Nov 2020 16:55:33 -0500 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-425-uP69NJ75MIKZq2hgDzSQZQ-1; Mon, 09 Nov 2020 16:55:26 -0500 X-MC-Unique: uP69NJ75MIKZq2hgDzSQZQ-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 CBE6F1074652; Mon, 9 Nov 2020 21:55:23 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id C60F76EF51; Mon, 9 Nov 2020 21:55:20 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 17/24] perf tools: Use machine__for_each_dso in perf_session__cache_build_ids Date: Mon, 9 Nov 2020 22:54:08 +0100 Message-Id: <20201109215415.400153-18-jolsa@kernel.org> In-Reply-To: <20201109215415.400153-1-jolsa@kernel.org> References: <20201109215415.400153-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using machine__for_each_dso in perf_session__cache_build_ids, so we can reuse perf_session__cache_build_ids with different callback in following changes. Signed-off-by: Jiri Olsa --- tools/perf/util/build-id.c | 41 +++++++++++++++----------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 2755d7b37a44..9f14d5851bb5 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -854,12 +854,16 @@ int build_id_cache__remove_s(const char *sbuild_id) return err; } -static int dso__cache_build_id(struct dso *dso, struct machine *machine) +static int dso__cache_build_id(struct dso *dso, struct machine *machine, + void *priv __maybe_unused) { bool is_kallsyms = dso__is_kallsyms(dso); bool is_vdso = dso__is_vdso(dso); const char *name = dso->long_name; + if (!dso->has_build_id) + return 0; + if (dso__is_kcore(dso)) { is_kallsyms = true; name = machine->mmap_name; @@ -868,43 +872,30 @@ static int dso__cache_build_id(struct dso *dso, struct machine *machine) is_kallsyms, is_vdso); } -static int __dsos__cache_build_ids(struct list_head *head, - struct machine *machine) +static int +machines__for_each_dso(struct machines *machines, machine__dso_t fn, void *priv) { - struct dso *pos; - int err = 0; - - dsos__for_each_with_build_id(pos, head) - if (dso__cache_build_id(pos, machine)) - err = -1; + int ret = machine__for_each_dso(&machines->host, fn, priv); + struct rb_node *nd; - return err; -} + for (nd = rb_first_cached(&machines->guests); nd; + nd = rb_next(nd)) { + struct machine *pos = rb_entry(nd, struct machine, rb_node); -static int machine__cache_build_ids(struct machine *machine) -{ - return __dsos__cache_build_ids(&machine->dsos.head, machine); + ret |= machine__for_each_dso(pos, fn, priv); + } + return ret ? -1 : 0; } int perf_session__cache_build_ids(struct perf_session *session) { - struct rb_node *nd; - int ret; - if (no_buildid_cache) return 0; if (mkdir(buildid_dir, 0755) != 0 && errno != EEXIST) return -1; - ret = machine__cache_build_ids(&session->machines.host); - - for (nd = rb_first_cached(&session->machines.guests); nd; - nd = rb_next(nd)) { - struct machine *pos = rb_entry(nd, struct machine, rb_node); - ret |= machine__cache_build_ids(pos); - } - return ret ? -1 : 0; + return machines__for_each_dso(&session->machines, dso__cache_build_id, NULL) ? -1 : 0; } static bool machine__read_build_ids(struct machine *machine, bool with_hits) -- 2.26.2