linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco)"  <dzagorui@cisco.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"acme@kernel.org" <acme@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"alexander.shishkin@linux.intel.com" 
	<alexander.shishkin@linux.intel.com>,
	"namhyung@kernel.org" <namhyung@kernel.org>
Subject: Re: [PATCH v3] perf: build reproducibility improvements
Date: Mon, 12 Apr 2021 10:13:02 +0000	[thread overview]
Message-ID: <BY5PR11MB4024A363D492D6B444C661B0D9709@BY5PR11MB4024.namprd11.prod.outlook.com> (raw)
In-Reply-To: <YHBgmopzUg4cMQhs@krava>

> > +
> > +int perf_src_doc(const char *exec_path, char **strp)
> > +{
> > +     FILE *file;
> > +     char *line = NULL;
> > +     size_t line_len = 0;
> > +     ssize_t nread;
> > +     int ret = -1;
> > +     char *config_detected = NULL;
> > +     static const char srcdir[] = "srcdir_SQ";
> > +
> > +     if (asprintf(&config_detected, "%s.config-detected", exec_path) < 0)
> > +             return -1;
> > +
> > +     file = fopen(config_detected, "r");
> > +     if (!file)
> > +             goto out;
> > +
> > +     while (!feof(file)) {
> > +             nread = getline(&line, &line_len, file);
> > +             if (nread < 0)
> > +                     break;
> > +
> > +             if (!strncmp(line, srcdir, sizeof(srcdir) - 1)) {
> > +
> > +                     if (line[nread - 1] == '\n')
> > +                             line[nread - 1] = 0;
> > +
> > +                     if (asprintf(strp, "%s/Documentation", &line[sizeof(srcdir)]) != -1)
> > +                             ret = 0;
> > +
> > +                     break;
> > +             }
> > +     }
> > +
> > +     fclose(file);
> > +out:
> > +     free(line);
> > +     free(config_detected);
> > +     return ret;
> > +}
>
> it's lot of tricky code because of one file, how about we compile
> tips.txt in perf binary directly? it might be even less code changes

I'm not sure about changes size, but anyway i agree that it makes more
sense to compile tips.txt in perf binary.

________________________________________
From: Jiri Olsa <jolsa@redhat.com>
Sent: 09 April 2021 17:11
To: Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco)
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 v3] perf: build reproducibility improvements

On Thu, Apr 08, 2021 at 05:51:35AM -0700, Denys Zagorui wrote:
> This patch helps to make perf build more reproducible
>
> 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 contains an absolute path to kernel source directory.
> This path can be read from .config-detected that is stored in the
> same dir as perf executable.
>
> There is also python binding test where PYTHONPATH is used to store
> absolute path to python/perf.so library. This path can be
> also determined in runtime.
>
> bison stores full paths in generated files. This can be
> remapped by using --file-prefix-map option that is available
> starting from version 3.7.1.
>
> Signed-off-by: Denys Zagorui <dzagorui@cisco.com>
> ---
>  tools/perf/Build              |  1 -
>  tools/perf/Makefile.config    |  9 +++++
>  tools/perf/builtin-report.c   | 13 +++++++-
>  tools/perf/tests/Build        |  2 +-
>  tools/perf/tests/python-use.c | 14 +++++++-
>  tools/perf/util/Build         |  6 ++--
>  tools/perf/util/util.c        | 62 +++++++++++++++++++++++++++++++++++
>  tools/perf/util/util.h        |  5 +++
>  8 files changed, 105 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/Build b/tools/perf/Build
> index db61dbe2b543..56d0189f1029 100644
> --- a/tools/perf/Build
> +++ b/tools/perf/Build
> @@ -45,7 +45,6 @@ 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/
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index d8e59d31399a..2035bae6d5c5 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -195,6 +195,12 @@ ifeq ($(call get-executable,$(BISON)),)
>    dummy := $(error Error: $(BISON) is missing on this system, please install it)
>  endif
>
> +ifneq ($(OUTPUT),)
> +  ifeq ($(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\).\([0-9]\+\)/\1\2\3/g') \>\= 371), 1)
> +    BISON_FILE_PREFIX_MAP := --file-prefix-map=$(OUTPUT)=
> +  endif
> +endif

please move all the flex, tips and python changes into separate patches

SNIP

> index 98c6d474aa6f..930aa4c6264e 100644
> --- a/tools/perf/tests/python-use.c
> +++ b/tools/perf/tests/python-use.c
> @@ -8,16 +8,28 @@
>  #include <linux/compiler.h>
>  #include "tests.h"
>  #include "util/debug.h"
> +#include "util/util.h"
>
>  int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused)
>  {
>       char *cmd;
>       int ret;
> +     char *exec_path;
> +     char *pythonpath;
> +
> +     exec_path = perf_exe_path();
> +     if (exec_path == NULL)
> +             return -1;
> +
> +     if (asprintf(&pythonpath, "%spython", exec_path) < 0)
> +             return -1;

please check if the pythonpath exists and don't use it if does not..
with perf from rpm and python perf.so module the path is already there
so we don't care

SNIP

> +
> +int perf_src_doc(const char *exec_path, char **strp)
> +{
> +     FILE *file;
> +     char *line = NULL;
> +     size_t line_len = 0;
> +     ssize_t nread;
> +     int ret = -1;
> +     char *config_detected = NULL;
> +     static const char srcdir[] = "srcdir_SQ";
> +
> +     if (asprintf(&config_detected, "%s.config-detected", exec_path) < 0)
> +             return -1;
> +
> +     file = fopen(config_detected, "r");
> +     if (!file)
> +             goto out;
> +
> +     while (!feof(file)) {
> +             nread = getline(&line, &line_len, file);
> +             if (nread < 0)
> +                     break;
> +
> +             if (!strncmp(line, srcdir, sizeof(srcdir) - 1)) {
> +
> +                     if (line[nread - 1] == '\n')
> +                             line[nread - 1] = 0;
> +
> +                     if (asprintf(strp, "%s/Documentation", &line[sizeof(srcdir)]) != -1)
> +                             ret = 0;
> +
> +                     break;
> +             }
> +     }
> +
> +     fclose(file);
> +out:
> +     free(line);
> +     free(config_detected);
> +     return ret;
> +}

it's lot of tricky code because of one file, how about we compile
tips.txt in perf binary directly? it might be even less code changes

thanks,
jirka


      reply	other threads:[~2021-04-12 10:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 12:51 [PATCH v3] perf: build reproducibility improvements Denys Zagorui
2021-04-09 14:11 ` Jiri Olsa
2021-04-12 10:13   ` Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco) [this message]

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=BY5PR11MB4024A363D492D6B444C661B0D9709@BY5PR11MB4024.namprd11.prod.outlook.com \
    --to=dzagorui@cisco.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.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;
as well as URLs for NNTP newsgroup(s).