Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp719553pxu; Thu, 26 Nov 2020 09:55:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjKy5b9YjlbQnb8/7XjSHx4jBOqA1+F96CItkCFznYXp+jp+/LOFGOs/c+YaoLBCq1k1EL X-Received: by 2002:a17:906:f94:: with SMTP id q20mr3780637ejj.22.1606413350576; Thu, 26 Nov 2020 09:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606413350; cv=none; d=google.com; s=arc-20160816; b=Fs8jUZsr9qTmkfozTlMnhZml591PlmyZmJZqVs2dp17g6bK8EvGIUurf2q7eC16uwY lG4V6VZJIerfKLNYN/9R5cvZ/YjPhcPBgHp1ybRf62Y6klj4criSbYy17lpmTL+6nZPg TboYyaNqWRYbUDIP9K8RsSaYn0noT0Q8V44BnL/b+6A9yhWwfoKeKsAgYD2oRElofvUv dH0aUxq+2gZ1L2sZ0LPQRdB5P5swXjTSd7QScYn9nTs//OdfdwdeVP+IpODFvwtdt8fc CH4MLx1ReXb/YDrdmW7s4O2lYOvx7UiwWD0ghgyGonidjfQjOyF3pffa5dXMqqxUUwMY lbpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tiik5S7HwJuZpDTMsd61lU7ILnyP/a5bmofGV0bzcvs=; b=XsRYyYL19K2WRIE/srZjTLpPLnnfi/lRAz9jBeq3HpeMxaZ1snx6Rbpt0GNXmcM6EP dNIOPb3AUEUk1MhKG3sVSdZPt7NEGcVFHEn5ajv7jS/4RAWU+Q1EsBpt5eesQE8OAB6y 04CHHpaHeRYhsuXe1jUmIV6uS7mt6xU5Z2EW/qvV8wEGnnshNHclJeb0lhqbURpzWpDp 75QjFQvNEy+ACDLQ0pgV0pkAW7pAZsRJOPVkIclomDRHmwTRAFIAuT3omImEf68GmkLy F4QOPRNSr+4QkFNM0ypy2/hR9321JjEcnk+EsROEjb8dONiIbQhr1vpIB+XW8hsAPClj M3lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="xq/2u4Yb"; 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 hp17si3486489ejc.31.2020.11.26.09.55.28; Thu, 26 Nov 2020 09:55:50 -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; dkim=pass header.i=@kernel.org header.s=default header.b="xq/2u4Yb"; 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 S2404137AbgKZRwe (ORCPT + 99 others); Thu, 26 Nov 2020 12:52:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:45596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404000AbgKZRwe (ORCPT ); Thu, 26 Nov 2020 12:52:34 -0500 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (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 0437A20665; Thu, 26 Nov 2020 17:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606413153; bh=jO8EQT3DTMJuuTlJ6zyo5W4RmBrH54UKTVGL0Cn1JZo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xq/2u4YbDGLe9XTYNPwEsX6jMVow5G1WqBSzo/RoJ9BafRnqWVlDoPmZAHvpgy0VF +Jm2c+OJM2OtiTnlMaEcoStb4t/BVUBsGgAhva2iw1HPeiN7xtokyS9l4f/4XDcJn4 Mn7LZ4AajWyEjLBNTgsbglUT98rrBgWKN+kQqz+Q= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id D13BA40E29; Thu, 26 Nov 2020 14:52:30 -0300 (-03) Date: Thu, 26 Nov 2020 14:52:30 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa 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: Re: [PATCH 18/25] perf tools: Use machine__for_each_dso in perf_session__cache_build_ids Message-ID: <20201126175230.GF70905@kernel.org> References: <20201126170026.2619053-1-jolsa@kernel.org> <20201126170026.2619053-19-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126170026.2619053-19-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Nov 26, 2020 at 06:00:19PM +0100, Jiri Olsa escreveu: > 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. Thanks, applied. - Arnaldo > 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 1fd58703c2d4..948a7f48d668 100644 > --- a/tools/perf/util/build-id.c > +++ b/tools/perf/util/build-id.c > @@ -859,12 +859,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; > @@ -873,43 +877,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 > -- - Arnaldo