From: Jiri Olsa <jolsa@redhat.com>
To: Denys Zagorui <dzagorui@cisco.com>
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
Date: Thu, 6 May 2021 15:54:37 +0200 [thread overview]
Message-ID: <YJP1HfjAd6hEirmg@krava> (raw)
In-Reply-To: <20210430133350.20504-1-dzagorui@cisco.com>
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 <dzagorui@cisco.com>
> ---
> 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
next prev parent reply other threads:[~2021-05-06 13:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-30 13:33 [PATCH v4 1/3] perf report: compile tips.txt in perf binary Denys Zagorui
2021-04-30 13:33 ` [PATCH v4 2/3] perf tests: avoid storing an absolute path " Denys Zagorui
2021-05-06 14:40 ` Jiri Olsa
2021-05-07 11:25 ` Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco)
2021-04-30 13:33 ` [PATCH v4 3/3] perf parse-events: add bison --file-prefix-map option Denys Zagorui
2021-05-06 15:15 ` Jiri Olsa
2021-05-07 5:27 ` Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco)
2021-05-06 13:54 ` Jiri Olsa [this message]
2021-05-07 5:46 ` [PATCH v4 1/3] perf report: compile tips.txt in perf binary Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YJP1HfjAd6hEirmg@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=dzagorui@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox