Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1379703pxy; Thu, 6 May 2021 06:56:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxODPNhLiD89+CdakN3NC/cH3i0qA7IKuC2BLam0vVJPTM3xmKNZbZ7HD9S75g2WcpYCfF X-Received: by 2002:a05:6402:5111:: with SMTP id m17mr5367111edd.343.1620309367808; Thu, 06 May 2021 06:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620309367; cv=none; d=google.com; s=arc-20160816; b=us8MUbQYvJY8qxhTkiZZVqlrelKpMjNGcdH7n4Y0EQMmQK1ISC9R2m7TisZxLt2B+j 9j+E6TBujdGRoZ6bMNhdilPCtDnMNqnFwVKSjspbXVtPpOqeoHqdHLf+eOx1zMaq7msh smsRtsMe9VcgzBDPc9W0L7BneWrkkYJaa9Zn5e3UtShpWvl0+eWalV2KwxGe4iYDDXfh c8HPOueF5ZLW1FrAiZELfge+AGyvMgRwtnl1LIfvFfuW8DH+UU1wfG6Rlonl0yasUUy6 sdDKeKRjlyw1BjNBGHIn16b7DylwlpVGha2bYwo31q7c4mFHr20YwbaVIx68Weh4iA9s USPw== 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=BcQUfqyBxndJOtzyA1QLGzQ50JbXAyqeLeyUDhJzKlQ=; b=nphIonFZj7NKKpjvxX3/bWGeMiEiPs0epg5+L4PopblJY43my40BGfshB8JOrhzyAB OK4oLVDORBBe4zVG1y2Cwxxgrp+wj428ZMGI8snDla02Sd7yKAZqmGytQIHz4V2PSlU5 a7F5lS+zoIHYRFL64uO6nmCAfkG8wj92GYUtPQTHqVPB3H8XF/kInlZWvSp5Wgku2zSf DLVbHTXbj+X7cQ+WMXCFW7w7EGx6NFr9rF9Y/GOWtJRw5tVdcVS8/4aDXj+H/dP9/0/V 3YgYWJ5fZq8Fyv+H6sF3Gyxw3ZCOw4gQDzf6lQLATNutBDMN/fXRzZzOamK+E5GHgmcS iNAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fTQ6VuMZ; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si2520116ejp.14.2021.05.06.06.55.43; Thu, 06 May 2021 06:56:07 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=fTQ6VuMZ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234188AbhEFNzq (ORCPT + 99 others); Thu, 6 May 2021 09:55:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30436 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233982AbhEFNzq (ORCPT ); Thu, 6 May 2021 09:55:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620309287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BcQUfqyBxndJOtzyA1QLGzQ50JbXAyqeLeyUDhJzKlQ=; b=fTQ6VuMZZhw1XlaaO8y/VVaiOTxrzaFTeZSePsSsF3OmOolIr2QZYwwqCootnysHILHcfL jmRtd3guCMz4IgvyaMpw3IBEr2xQNFU099FAW67XFplJvnuNVQi59lkmox6h1vT34W6wu5 wExi+hyHQqDOXmLm8Ckm8MgSunvuEoc= 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-45-K7u6eQB1Pi-C-gtqhWUupA-1; Thu, 06 May 2021 09:54:43 -0400 X-MC-Unique: K7u6eQB1Pi-C-gtqhWUupA-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 9B94D8014D8; Thu, 6 May 2021 13:54:41 +0000 (UTC) Received: from krava (unknown [10.40.193.227]) by smtp.corp.redhat.com (Postfix) with SMTP id 9A69260862; Thu, 6 May 2021 13:54:38 +0000 (UTC) Date: Thu, 6 May 2021 15:54:37 +0200 From: Jiri Olsa To: Denys Zagorui Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org Subject: Re: [PATCH v4 1/3] perf report: compile tips.txt in perf binary Message-ID: References: <20210430133350.20504-1-dzagorui@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210430133350.20504-1-dzagorui@cisco.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 30, 2021 at 06:33:48AM -0700, Denys Zagorui wrote: > It seems there is some need to have an ability to invoke perf from > build directory without installation > (84cfac7f05e1: perf tools: Set and pass DOCDIR to builtin-report.c) > DOCDIR definition contains an absolute path to kernel source directory. > It is build machine related info and it makes perf binary unreproducible. > > This can be avoided by compiling tips.txt in perf directly. > > Signed-off-by: Denys Zagorui > --- > tools/perf/Build | 2 +- > tools/perf/Documentation/Build | 9 ++++++++ > tools/perf/builtin-report.c | 39 ++++++++++++++++++++++++++-------- > tools/perf/util/util.c | 28 ------------------------ > tools/perf/util/util.h | 2 -- > 5 files changed, 40 insertions(+), 40 deletions(-) > create mode 100644 tools/perf/Documentation/Build > > diff --git a/tools/perf/Build b/tools/perf/Build > index db61dbe2b543..3a2e768d7576 100644 > --- a/tools/perf/Build > +++ b/tools/perf/Build > @@ -45,12 +45,12 @@ CFLAGS_perf.o += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))" \ > -DPREFIX="BUILD_STR($(prefix_SQ))" > CFLAGS_builtin-trace.o += -DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))" > CFLAGS_builtin-report.o += -DTIPDIR="BUILD_STR($(tipdir_SQ))" > -CFLAGS_builtin-report.o += -DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)" > > perf-y += util/ > perf-y += arch/ > perf-y += ui/ > perf-y += scripts/ > perf-$(CONFIG_TRACE) += trace/beauty/ > +perf-y += Documentation/ > > gtk-y += ui/gtk/ > diff --git a/tools/perf/Documentation/Build b/tools/perf/Documentation/Build > new file mode 100644 > index 000000000000..83e16764caa4 > --- /dev/null > +++ b/tools/perf/Documentation/Build > @@ -0,0 +1,9 @@ > +perf-y += tips.o > + > +quiet_cmd_ld_tips = LD $@ > + cmd_ld_tips = $(LD) -r -b binary -o $@ $< > + > +$(OUTPUT)Documentation/tips.o: Documentation/tips.txt FORCE > + $(call rule_mkdir) > + $(call if_changed,ld_tips) nice, I had no idea ld could do it like this ;-) > + > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > index 2a845d6cac09..88375ed76d53 100644 > --- a/tools/perf/builtin-report.c > +++ b/tools/perf/builtin-report.c > @@ -47,7 +47,6 @@ > #include "util/time-utils.h" > #include "util/auxtrace.h" > #include "util/units.h" > -#include "util/util.h" // perf_tip() > #include "ui/ui.h" > #include "ui/progress.h" > #include "util/block-info.h" > @@ -107,6 +106,9 @@ struct report { > int nr_block_reports; > }; > > +extern char _binary_Documentation_tips_txt_start[]; > +extern char _binary_Documentation_tips_txt_end[]; > + > static int report__config(const char *var, const char *value, void *cb) > { > struct report *rep = cb; > @@ -604,19 +606,38 @@ static int report__gtk_browse_hists(struct report *rep, const char *help) > return hist_browser(rep->session->evlist, help, NULL, rep->min_percent); > } > > +#define MAX_TIPS 60 > + > +static const char *perf_tip(void) > +{ > + char *str[MAX_TIPS]; > + int i = 0; > + > + _binary_Documentation_tips_txt_start[_binary_Documentation_tips_txt_end - > + _binary_Documentation_tips_txt_start - 1] = 0; > + > + str[i] = strtok(_binary_Documentation_tips_txt_start, "\n"); > + if (!str[i]) > + return "Tips cannot be found!"; > + > + i++; > + > + while (i < MAX_TIPS) { > + str[i] = strtok(NULL, "\n"); > + if (!str[i]) > + break; > + i++; > + } I dont mind to keep static count of tips, but would be great to have some check when there are more tips in the tips.txt or perhaps pick tip with random index within the tips data size? you would just do strtok until you reach the string that has the random index inside.. you wouldn't need str pointers then jirka