Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1250763 > unrolled thread

Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test

Started byNamhyung Kim <namhyung@kernel.org>
First post2015-10-19 16:50 +0200
Last post2015-10-20 15:50 +0200
Articles 7 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test Namhyung Kim <namhyung@kernel.org> - 2015-10-19 16:50 +0200
    Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-10-19 17:00 +0200
      Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test Namhyung Kim <namhyung@kernel.org> - 2015-10-19 17:30 +0200
      Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-20 12:40 +0200
        Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-10-20 15:50 +0200
      Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test "Wangnan (F)" <wangnan0@huawei.com> - 2015-10-20 14:20 +0200
        Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test Arnaldo Carvalho de Melo <acme@redhat.com> - 2015-10-20 15:50 +0200

#1250763 — Re: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-19 16:50 +0200
SubjectRe: [PATCH 21/31] perf test: Enforce LLVM test, add kbuild test
Message-ID<qljV7-7oG-7@gated-at.bofh.it>
Hi,

On Wed, Oct 14, 2015 at 12:41:32PM +0000, Wang Nan wrote:
> This patch enforces existing LLVM test, makes it compile more than one
> BPF source file. The compiled results are stored, can be used for other
> testcases. Except the first testcase (named LLVM_TESTCASE_BASE), failures
> of other test cases are not considered as failure of the whole test.
> 
> Adds a kbuild testcase to check whether kernel headers can be correctly
> found.
> 
> For example:
> 
>  # perf test LLVM
> 
>    38: Test LLVM searching and compiling                        : (llvm.kbuild-dir can be fixed) Ok

IMHO it'd be better to keep the test result simply as either "Ok" or
"FAILED" and provide details with -v option.

Anyway I found the tracepoint error message is annoying in the current
perf test output.  Will send a fix soon.

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1250781

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2015-10-19 17:00 +0200
Message-ID<qlk4P-7Aj-39@gated-at.bofh.it>
In reply to#1250763
Em Mon, Oct 19, 2015 at 11:42:31PM +0900, Namhyung Kim escreveu:
> Hi,
> 
> On Wed, Oct 14, 2015 at 12:41:32PM +0000, Wang Nan wrote:
> > This patch enforces existing LLVM test, makes it compile more than one
> > BPF source file. The compiled results are stored, can be used for other
> > testcases. Except the first testcase (named LLVM_TESTCASE_BASE), failures
> > of other test cases are not considered as failure of the whole test.
> > 
> > Adds a kbuild testcase to check whether kernel headers can be correctly
> > found.
> > 
> > For example:
> > 
> >  # perf test LLVM
> > 
> >    38: Test LLVM searching and compiling                        : (llvm.kbuild-dir can be fixed) Ok
> 
> IMHO it'd be better to keep the test result simply as either "Ok" or
> "FAILED" and provide details with -v option.

"Skipped" looks more natural here, with the reason for it skipping being shown
only with -v.

Ingo made some comments about 'perf test' output recently, have you read that?

> Anyway I found the tracepoint error message is annoying in the current

You mean all these warnings:

[root@zoo ~]# perf test "parse event" 
 5: parse events tests                                       :  Warning: [sunrpc:xprt_lookup_rqst] function __builtin_constant_p not defined
  Warning: [sunrpc:xprt_transmit] function __builtin_constant_p not defined
  Warning: [sunrpc:xprt_complete_rqst] function __builtin_constant_p not defined
<SNIP>
  Warning: [xen:xen_mmu_set_pud] function sizeof not defined
  Warning: [xen:xen_mmu_set_pgd] function sizeof not defined
  Warning: [xen:xen_mmu_ptep_modify_prot_start] function sizeof not defined
  Warning: [xen:xen_mmu_ptep_modify_prot_commit] function sizeof not defined
 Ok
[root@zoo ~]# 

i.e. making those warnings appear only under 'perf test -v'? Cool!

> perf test output.  Will send a fix soon.
> 
> Thanks,
> Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1250826

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-19 17:30 +0200
Message-ID<qlkxP-8qb-9@gated-at.bofh.it>
In reply to#1250781
Hi Arnaldo,

On Mon, Oct 19, 2015 at 12:53:12PM -0200, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 19, 2015 at 11:42:31PM +0900, Namhyung Kim escreveu:
> > Hi,
> > 
> > On Wed, Oct 14, 2015 at 12:41:32PM +0000, Wang Nan wrote:
> > > This patch enforces existing LLVM test, makes it compile more than one
> > > BPF source file. The compiled results are stored, can be used for other
> > > testcases. Except the first testcase (named LLVM_TESTCASE_BASE), failures
> > > of other test cases are not considered as failure of the whole test.
> > > 
> > > Adds a kbuild testcase to check whether kernel headers can be correctly
> > > found.
> > > 
> > > For example:
> > > 
> > >  # perf test LLVM
> > > 
> > >    38: Test LLVM searching and compiling                        : (llvm.kbuild-dir can be fixed) Ok
> > 
> > IMHO it'd be better to keep the test result simply as either "Ok" or
> > "FAILED" and provide details with -v option.
> 
> "Skipped" looks more natural here, with the reason for it skipping being shown
> only with -v.

Agreed.

> 
> Ingo made some comments about 'perf test' output recently, have you read that?

Nop, sorry.  I'll check it (and it'd be great it you could give me the
link :)


> 
> > Anyway I found the tracepoint error message is annoying in the current
> 
> You mean all these warnings:
> 
> [root@zoo ~]# perf test "parse event" 
>  5: parse events tests                                       :  Warning: [sunrpc:xprt_lookup_rqst] function __builtin_constant_p not defined
>   Warning: [sunrpc:xprt_transmit] function __builtin_constant_p not defined
>   Warning: [sunrpc:xprt_complete_rqst] function __builtin_constant_p not defined
> <SNIP>
>   Warning: [xen:xen_mmu_set_pud] function sizeof not defined
>   Warning: [xen:xen_mmu_set_pgd] function sizeof not defined
>   Warning: [xen:xen_mmu_ptep_modify_prot_start] function sizeof not defined
>   Warning: [xen:xen_mmu_ptep_modify_prot_commit] function sizeof not defined
>  Ok
> [root@zoo ~]# 
> 
> i.e. making those warnings appear only under 'perf test -v'? Cool!

Will send the fix soon!

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1251571

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-10-20 12:40 +0200
Message-ID<qlCuK-13U-15@gated-at.bofh.it>
In reply to#1250781

On 2015/10/19 22:53, Arnaldo Carvalho de Melo wrote:
> Em Mon, Oct 19, 2015 at 11:42:31PM +0900, Namhyung Kim escreveu:
>> Hi,
>>
>> On Wed, Oct 14, 2015 at 12:41:32PM +0000, Wang Nan wrote:
>>> This patch enforces existing LLVM test, makes it compile more than one
>>> BPF source file. The compiled results are stored, can be used for other
>>> testcases. Except the first testcase (named LLVM_TESTCASE_BASE), failures
>>> of other test cases are not considered as failure of the whole test.
>>>
>>> Adds a kbuild testcase to check whether kernel headers can be correctly
>>> found.
>>>
>>> For example:
>>>
>>>   # perf test LLVM
>>>
>>>     38: Test LLVM searching and compiling                        : (llvm.kbuild-dir can be fixed) Ok
>> IMHO it'd be better to keep the test result simply as either "Ok" or
>> "FAILED" and provide details with -v option.

I have to say I'm not the first one to output things like this:

  #perf test dummy attr
  14: struct perf_event_attr setup                             : 
(omitted) Ok
  23: Test using a dummy software event to keep tracking       : (not 
supported) Ok

Do you think they also need to be fixed?

> "Skipped" looks more natural here, with the reason for it skipping being shown
> only with -v.

For this specific case, I will change the logic:

  1. When basic test failed (no clang, compiling error...), report failure;

  2. When basic test passed but kbuild test or later test cases failed, 
report
     Skip.

  3. Don't output any other information.

Thank you.

> Ingo made some comments about 'perf test' output recently, have you read that?
>
>> Anyway I found the tracepoint error message is annoying in the current
> You mean all these warnings:
>
> [root@zoo ~]# perf test "parse event"
>   5: parse events tests                                       :  Warning: [sunrpc:xprt_lookup_rqst] function __builtin_constant_p not defined
>    Warning: [sunrpc:xprt_transmit] function __builtin_constant_p not defined
>    Warning: [sunrpc:xprt_complete_rqst] function __builtin_constant_p not defined
> <SNIP>
>    Warning: [xen:xen_mmu_set_pud] function sizeof not defined
>    Warning: [xen:xen_mmu_set_pgd] function sizeof not defined
>    Warning: [xen:xen_mmu_ptep_modify_prot_start] function sizeof not defined
>    Warning: [xen:xen_mmu_ptep_modify_prot_commit] function sizeof not defined
>   Ok
> [root@zoo ~]#
>
> i.e. making those warnings appear only under 'perf test -v'? Cool!
>
>> perf test output.  Will send a fix soon.
>>
>> Thanks,
>> Namhyung


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1251700

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2015-10-20 15:50 +0200
Message-ID<qlFsC-5kZ-9@gated-at.bofh.it>
In reply to#1251571
Em Tue, Oct 20, 2015 at 06:36:33PM +0800, Wangnan (F) escreveu:
> On 2015/10/19 22:53, Arnaldo Carvalho de Melo wrote:
> >Em Mon, Oct 19, 2015 at 11:42:31PM +0900, Namhyung Kim escreveu:
> >>On Wed, Oct 14, 2015 at 12:41:32PM +0000, Wang Nan wrote:
> >>>This patch enforces existing LLVM test, makes it compile more than one
> >>>BPF source file. The compiled results are stored, can be used for other
> >>>testcases. Except the first testcase (named LLVM_TESTCASE_BASE), failures
> >>>of other test cases are not considered as failure of the whole test.

> >>>Adds a kbuild testcase to check whether kernel headers can be correctly
> >>>found.

> >>>For example:
> >>>  # perf test LLVM
> >>>    38: Test LLVM searching and compiling                        : (llvm.kbuild-dir can be fixed) Ok

> >>IMHO it'd be better to keep the test result simply as either "Ok" or
> >>"FAILED" and provide details with -v option.
> 
> I have to say I'm not the first one to output things like this:
> 
>  #perf test dummy attr
>  14: struct perf_event_attr setup                             :
> (omitted) Ok
>  23: Test using a dummy software event to keep tracking       : (not
> supported) Ok
> 
> Do you think they also need to be fixed?

yes
 
> >"Skipped" looks more natural here, with the reason for it skipping being shown
> >only with -v.
> 
> For this specific case, I will change the logic:
> 
>  1. When basic test failed (no clang, compiling error...), report failure;
> 
>  2. When basic test passed but kbuild test or later test cases
> failed, report
>     Skip.
> 
>  3. Don't output any other information.
> 
> Thank you.
> 
> >Ingo made some comments about 'perf test' output recently, have you read that?
> >
> >>Anyway I found the tracepoint error message is annoying in the current
> >You mean all these warnings:
> >
> >[root@zoo ~]# perf test "parse event"
> >  5: parse events tests                                       :  Warning: [sunrpc:xprt_lookup_rqst] function __builtin_constant_p not defined
> >   Warning: [sunrpc:xprt_transmit] function __builtin_constant_p not defined
> >   Warning: [sunrpc:xprt_complete_rqst] function __builtin_constant_p not defined
> ><SNIP>
> >   Warning: [xen:xen_mmu_set_pud] function sizeof not defined
> >   Warning: [xen:xen_mmu_set_pgd] function sizeof not defined
> >   Warning: [xen:xen_mmu_ptep_modify_prot_start] function sizeof not defined
> >   Warning: [xen:xen_mmu_ptep_modify_prot_commit] function sizeof not defined
> >  Ok
> >[root@zoo ~]#
> >
> >i.e. making those warnings appear only under 'perf test -v'? Cool!
> >
> >>perf test output.  Will send a fix soon.
> >>
> >>Thanks,
> >>Namhyung
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1251626

From"Wangnan (F)" <wangnan0@huawei.com>
Date2015-10-20 14:20 +0200
Message-ID<qlE3w-3rm-17@gated-at.bofh.it>
In reply to#1250781
Hi Namhyung and Arnaldo,

I changed my testing related patches in my local git tree. All
changed combined together is at the end of this mail. I remove
all stderr output, and improve debug message. Please have a look
at it.

Thank you.


diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 5a6290a..453eff8 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -49,7 +49,7 @@ static struct bpf_object *prepare_bpf(const char 
*name, void *obj_buf,

      obj = bpf__prepare_load_buffer(obj_buf, obj_buf_sz, name);
      if (IS_ERR(obj)) {
-        fprintf(stderr, " (compile failed)");
+        pr_debug("Compile BPF program failed.\n");
          return NULL;
      }
      return obj;
@@ -82,7 +82,7 @@ static int do_test(struct bpf_object *obj, int 
(*func)(void), int expect)

      err = parse_events_load_bpf_obj(&parse_evlist, &parse_evlist.list, 
obj);
      if (err || list_empty(&parse_evlist.list)) {
-        fprintf(stderr, " (Failed to add events selected by BPF)");
+        pr_debug("Failed to add events selected by BPF\n");
          if (!err)
              err = -EINVAL;
          goto out;
@@ -140,7 +140,7 @@ static int do_test(struct bpf_object *obj, int 
(*func)(void), int expect)
      }

      if (count != expect) {
-        fprintf(stderr, " (filter result incorrect: %d != %d)", count, 
expect);
+        pr_debug("BPF filter result incorrect: %d != %d\n", count, expect);
          err = -EBADF;
      }

@@ -164,16 +164,14 @@ static int __test__bpf(int index, const char *name,

      test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz, index);
      if (!obj_buf || !obj_buf_sz) {
-        if (verbose == 0)
-            fprintf(stderr, " (%s)", message_compile);
+        pr_debug("Failed to compile: %s\n", message_compile);
          return TEST_SKIP;
      }

      obj = prepare_bpf(name, obj_buf, obj_buf_sz);
      if (!obj) {
          err = -EINVAL;
-        if ((verbose == 0) && (message_load[0] != '\0'))
-            fprintf(stderr, " (%s)", message_load);
+        pr_debug("Failed to load: %s", message_load);
          goto out;
      }

@@ -192,7 +190,7 @@ int test__bpf(void)
      int err;

      if (geteuid() != 0) {
-        fprintf(stderr, " (try run as root)");
+        pr_debug("Only root can run BPF test\n");
          return TEST_SKIP;
      }

@@ -214,7 +212,7 @@ int test__bpf(void)
                (NR_ITERS + 1) / 4);
      return err;
  #else
-    fprintf(stderr, " (skip BPF prologue test)");
+    pr_debug("BPF prologue is disabled when compiling, skip this test\n");
      return TEST_OK;
  #endif
  }
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index e722e8a..7c3b2c3 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -13,19 +13,23 @@
  struct llvm_testcase {
      const char *source;
      const char *errmsg;
+    const char *hintmsg;
      struct test_llvm__bpf_result *result;
      bool tried;
  } llvm_testcases[NR_LLVM_TESTCASES + 1] = {
      [LLVM_TESTCASE_BASE]    = {.source = test_llvm__bpf_prog,
                     .errmsg = "Basic LLVM compiling failed",
+                   .hintmsg = "Check llvm.clang-path option in 
~/.perfconfig",
                     .tried = false},
      [LLVM_TESTCASE_KBUILD]    = {.source = 
test_llvm__bpf_test_kbuild_prog,
-                   .errmsg = "llvm.kbuild-dir can be fixed",
+                   .errmsg = "Unable to find usable kbuild dir",
+                   .hintmsg = "Check llvm.kbuild-dir option in 
~/.perfconfig",
                     .tried = false},
      /* Don't output if this one fail. */
      [LLVM_TESTCASE_BPF_PROLOGUE]    = {
                     .source = test_llvm__bpf_test_prologue_prog,
-                   .errmsg = "failed for unknown reason",
+                   .errmsg = "Unable to compile BPF prologue testing 
program",
+                   .hintmsg = "This is an internal error, please report 
it",
                     .tried = false},
      {.source = NULL}
  };
@@ -43,16 +47,16 @@ static int test__bpf_parsing(void *obj_buf, size_t 
obj_buf_sz)

      obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, NULL);
      if (!obj)
-        return -1;
+        return TEST_FAIL;
      bpf_object__close(obj);
-    return 0;
+    return TEST_OK;
  }
  #else
  static int test__bpf_parsing(void *obj_buf __maybe_unused,
                   size_t obj_buf_sz __maybe_unused)
  {
-    fprintf(stderr, " (skip bpf parsing)");
-    return 0;
+    pr_debug("BPF support is not compiled, skip BPF parsing\n");
+    return TEST_SKIP;
  }
  #endif

@@ -70,8 +74,8 @@ compose_source(const char *raw_source)
      err = sscanf(utsname.release, "%d.%d.%d",
               &version, &patchlevel, &sublevel);
      if (err != 3) {
-        fprintf(stderr, " (Can't get kernel version from uname '%s')",
-            utsname.release);
+        pr_debug("Unablt to get kernel version from uname '%s'\n",
+             utsname.release);
          return NULL;
      }

@@ -104,7 +108,7 @@ static int __test__llvm(int i)
       * and clang is not found in $PATH, and this is not perf test -v
       */
      if (verbose == 0 && !llvm_param.user_set_param && 
llvm__search_clang()) {
-        fprintf(stderr, " (no clang, try 'perf test -v LLVM')");
+        pr_debug("Unable to find workable clang\n");
          return TEST_SKIP;
      }

@@ -155,7 +159,7 @@ static int __test__llvm(int i)

      verbose = old_verbose;
      if (err)
-        return -1;
+        return TEST_FAIL;

      err = test__bpf_parsing(obj_buf, obj_buf_sz);
      if (!err && result) {
@@ -181,13 +185,12 @@ int test__llvm(void)
               * First testcase tests basic LLVM compiling. If it
               * fails, no need to check others.
               */
-            if (!verbose)
-                fprintf(stderr, " (use -v to see error message)");
-            return ret;
+            return TEST_FAIL;
          } else if (ret) {
-            if (!verbose && llvm_testcases[i].errmsg)
-                fprintf(stderr, " (%s)", llvm_testcases[i].errmsg);
-            return 0;
+            pr_debug("%s\n", llvm_testcases[i].errmsg);
+            if (llvm_testcases[i].hintmsg)
+                pr_debug("Hint:\t%s\n", llvm_testcases[i].hintmsg);
+            return TEST_SKIP;
          }
      }
      return 0;
@@ -199,12 +202,15 @@ void test__llvm_prepare(void)

      for (i = 0; llvm_testcases[i].source; i++) {
          struct test_llvm__bpf_result *result;
+        void *p;

-        result = mmap(NULL, SHARED_BUF_INIT_SIZE,
-                  PROT_READ | PROT_WRITE,
-                  MAP_SHARED | MAP_ANONYMOUS, -1, 0);
-        if (!result)
+        p = mmap(NULL, SHARED_BUF_INIT_SIZE,
+             PROT_READ | PROT_WRITE,
+             MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+        if (p == MAP_FAILED)
              return;
+
+        result = p;
          memset((void *)result, '\0', SHARED_BUF_INIT_SIZE);

          llvm_testcases[i].result = result;
diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c
index e4adb18..36093d9 100644
--- a/tools/perf/util/bpf-prologue.c
+++ b/tools/perf/util/bpf-prologue.c
@@ -337,8 +337,10 @@ int bpf__gen_prologue(struct probe_trace_arg *args, 
int nargs,
          return 0;
      }

-    if (nargs > BPF_PROLOGUE_MAX_ARGS)
+    if (nargs > BPF_PROLOGUE_MAX_ARGS) {
+        pr_warning("bpf: prologue: too many arguments\n");
          nargs = BPF_PROLOGUE_MAX_ARGS;
+    }
      if (cnt_space > BPF_MAXINSNS)
          cnt_space = BPF_MAXINSNS;



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1251698

FromArnaldo Carvalho de Melo <acme@redhat.com>
Date2015-10-20 15:50 +0200
Message-ID<qlFsB-5kZ-3@gated-at.bofh.it>
In reply to#1251626
Em Tue, Oct 20, 2015 at 08:06:54PM +0800, Wangnan (F) escreveu:
> Hi Namhyung and Arnaldo,
> 
> I changed my testing related patches in my local git tree. All
> changed combined together is at the end of this mail. I remove
> all stderr output, and improve debug message. Please have a look
> at it.
> 
> Thank you.

Yeah, from a quick look it looks sane, i.e. 'perf test' should state
just 'Ok', "FAIL" or "Skip", -v provides a reason, -vv will provide more
detail and so on, i.e. a verbosity level, for that we have 'pr_debug(),
pr_debug2(), pr_debug3(), etc, and can always, for some specialized use,
like grouping multiple warnings or deciding if we need to call some
other function only when the verbosity level is greater than some level,
check the 'verbose' variable value.

- Arnaldo
 
> 
> diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
> index 5a6290a..453eff8 100644
> --- a/tools/perf/tests/bpf.c
> +++ b/tools/perf/tests/bpf.c
> @@ -49,7 +49,7 @@ static struct bpf_object *prepare_bpf(const char
> *name, void *obj_buf,
> 
>      obj = bpf__prepare_load_buffer(obj_buf, obj_buf_sz, name);
>      if (IS_ERR(obj)) {
> -        fprintf(stderr, " (compile failed)");
> +        pr_debug("Compile BPF program failed.\n");
>          return NULL;
>      }
>      return obj;
> @@ -82,7 +82,7 @@ static int do_test(struct bpf_object *obj, int
> (*func)(void), int expect)
> 
>      err = parse_events_load_bpf_obj(&parse_evlist,
> &parse_evlist.list, obj);
>      if (err || list_empty(&parse_evlist.list)) {
> -        fprintf(stderr, " (Failed to add events selected by BPF)");
> +        pr_debug("Failed to add events selected by BPF\n");
>          if (!err)
>              err = -EINVAL;
>          goto out;
> @@ -140,7 +140,7 @@ static int do_test(struct bpf_object *obj, int
> (*func)(void), int expect)
>      }
> 
>      if (count != expect) {
> -        fprintf(stderr, " (filter result incorrect: %d != %d)",
> count, expect);
> +        pr_debug("BPF filter result incorrect: %d != %d\n", count, expect);
>          err = -EBADF;
>      }
> 
> @@ -164,16 +164,14 @@ static int __test__bpf(int index, const char *name,
> 
>      test_llvm__fetch_bpf_obj(&obj_buf, &obj_buf_sz, index);
>      if (!obj_buf || !obj_buf_sz) {
> -        if (verbose == 0)
> -            fprintf(stderr, " (%s)", message_compile);
> +        pr_debug("Failed to compile: %s\n", message_compile);
>          return TEST_SKIP;
>      }
> 
>      obj = prepare_bpf(name, obj_buf, obj_buf_sz);
>      if (!obj) {
>          err = -EINVAL;
> -        if ((verbose == 0) && (message_load[0] != '\0'))
> -            fprintf(stderr, " (%s)", message_load);
> +        pr_debug("Failed to load: %s", message_load);
>          goto out;
>      }
> 
> @@ -192,7 +190,7 @@ int test__bpf(void)
>      int err;
> 
>      if (geteuid() != 0) {
> -        fprintf(stderr, " (try run as root)");
> +        pr_debug("Only root can run BPF test\n");
>          return TEST_SKIP;
>      }
> 
> @@ -214,7 +212,7 @@ int test__bpf(void)
>                (NR_ITERS + 1) / 4);
>      return err;
>  #else
> -    fprintf(stderr, " (skip BPF prologue test)");
> +    pr_debug("BPF prologue is disabled when compiling, skip this test\n");
>      return TEST_OK;
>  #endif
>  }
> diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
> index e722e8a..7c3b2c3 100644
> --- a/tools/perf/tests/llvm.c
> +++ b/tools/perf/tests/llvm.c
> @@ -13,19 +13,23 @@
>  struct llvm_testcase {
>      const char *source;
>      const char *errmsg;
> +    const char *hintmsg;
>      struct test_llvm__bpf_result *result;
>      bool tried;
>  } llvm_testcases[NR_LLVM_TESTCASES + 1] = {
>      [LLVM_TESTCASE_BASE]    = {.source = test_llvm__bpf_prog,
>                     .errmsg = "Basic LLVM compiling failed",
> +                   .hintmsg = "Check llvm.clang-path option in
> ~/.perfconfig",
>                     .tried = false},
>      [LLVM_TESTCASE_KBUILD]    = {.source =
> test_llvm__bpf_test_kbuild_prog,
> -                   .errmsg = "llvm.kbuild-dir can be fixed",
> +                   .errmsg = "Unable to find usable kbuild dir",
> +                   .hintmsg = "Check llvm.kbuild-dir option in
> ~/.perfconfig",
>                     .tried = false},
>      /* Don't output if this one fail. */
>      [LLVM_TESTCASE_BPF_PROLOGUE]    = {
>                     .source = test_llvm__bpf_test_prologue_prog,
> -                   .errmsg = "failed for unknown reason",
> +                   .errmsg = "Unable to compile BPF prologue
> testing program",
> +                   .hintmsg = "This is an internal error, please
> report it",
>                     .tried = false},
>      {.source = NULL}
>  };
> @@ -43,16 +47,16 @@ static int test__bpf_parsing(void *obj_buf,
> size_t obj_buf_sz)
> 
>      obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, NULL);
>      if (!obj)
> -        return -1;
> +        return TEST_FAIL;
>      bpf_object__close(obj);
> -    return 0;
> +    return TEST_OK;
>  }
>  #else
>  static int test__bpf_parsing(void *obj_buf __maybe_unused,
>                   size_t obj_buf_sz __maybe_unused)
>  {
> -    fprintf(stderr, " (skip bpf parsing)");
> -    return 0;
> +    pr_debug("BPF support is not compiled, skip BPF parsing\n");
> +    return TEST_SKIP;
>  }
>  #endif
> 
> @@ -70,8 +74,8 @@ compose_source(const char *raw_source)
>      err = sscanf(utsname.release, "%d.%d.%d",
>               &version, &patchlevel, &sublevel);
>      if (err != 3) {
> -        fprintf(stderr, " (Can't get kernel version from uname '%s')",
> -            utsname.release);
> +        pr_debug("Unablt to get kernel version from uname '%s'\n",
> +             utsname.release);
>          return NULL;
>      }
> 
> @@ -104,7 +108,7 @@ static int __test__llvm(int i)
>       * and clang is not found in $PATH, and this is not perf test -v
>       */
>      if (verbose == 0 && !llvm_param.user_set_param &&
> llvm__search_clang()) {
> -        fprintf(stderr, " (no clang, try 'perf test -v LLVM')");
> +        pr_debug("Unable to find workable clang\n");
>          return TEST_SKIP;
>      }
> 
> @@ -155,7 +159,7 @@ static int __test__llvm(int i)
> 
>      verbose = old_verbose;
>      if (err)
> -        return -1;
> +        return TEST_FAIL;
> 
>      err = test__bpf_parsing(obj_buf, obj_buf_sz);
>      if (!err && result) {
> @@ -181,13 +185,12 @@ int test__llvm(void)
>               * First testcase tests basic LLVM compiling. If it
>               * fails, no need to check others.
>               */
> -            if (!verbose)
> -                fprintf(stderr, " (use -v to see error message)");
> -            return ret;
> +            return TEST_FAIL;
>          } else if (ret) {
> -            if (!verbose && llvm_testcases[i].errmsg)
> -                fprintf(stderr, " (%s)", llvm_testcases[i].errmsg);
> -            return 0;
> +            pr_debug("%s\n", llvm_testcases[i].errmsg);
> +            if (llvm_testcases[i].hintmsg)
> +                pr_debug("Hint:\t%s\n", llvm_testcases[i].hintmsg);
> +            return TEST_SKIP;
>          }
>      }
>      return 0;
> @@ -199,12 +202,15 @@ void test__llvm_prepare(void)
> 
>      for (i = 0; llvm_testcases[i].source; i++) {
>          struct test_llvm__bpf_result *result;
> +        void *p;
> 
> -        result = mmap(NULL, SHARED_BUF_INIT_SIZE,
> -                  PROT_READ | PROT_WRITE,
> -                  MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> -        if (!result)
> +        p = mmap(NULL, SHARED_BUF_INIT_SIZE,
> +             PROT_READ | PROT_WRITE,
> +             MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> +        if (p == MAP_FAILED)
>              return;
> +
> +        result = p;
>          memset((void *)result, '\0', SHARED_BUF_INIT_SIZE);
> 
>          llvm_testcases[i].result = result;
> diff --git a/tools/perf/util/bpf-prologue.c b/tools/perf/util/bpf-prologue.c
> index e4adb18..36093d9 100644
> --- a/tools/perf/util/bpf-prologue.c
> +++ b/tools/perf/util/bpf-prologue.c
> @@ -337,8 +337,10 @@ int bpf__gen_prologue(struct probe_trace_arg
> *args, int nargs,
>          return 0;
>      }
> 
> -    if (nargs > BPF_PROLOGUE_MAX_ARGS)
> +    if (nargs > BPF_PROLOGUE_MAX_ARGS) {
> +        pr_warning("bpf: prologue: too many arguments\n");
>          nargs = BPF_PROLOGUE_MAX_ARGS;
> +    }
>      if (cnt_space > BPF_MAXINSNS)
>          cnt_space = BPF_MAXINSNS;
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web