Skip to contentSkip to conversation

modified error code when perf_session__new() fail

PATCH In review taeung 3 participants 5 messages Sep 17, 2014 – Sep 23, 2014 perf events

lore
Share & tools
lore

taeung

author
#0 lore raw

PATCH 1/1 modified error code when perf_session__new() fail

Hi,

I modified error code for the requirement as below.

Author: taeung <[email protected]>
Date:   Sat Sep 13 16:22:53 2014 +0900

modified error code when perf_session__new() fail

Because perf_session__new() could fail
for more reasons than just ENOMEM,
I modified error code(ENOMEM or EINVAL)
into -1.

tools/perf/builtin-annotate.c +1 -1
index 1ec429f..81c9fda 100644
@@ -199,7 +199,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
 
     session = perf_session__new(&file, false, &ann->tool);
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     machines__set_symbol_filter(&session->machines, 

symbol__annotate_init);

tools/perf/builtin-diff.c +1 -1
index 9a5a035..3363dce 100644
@@ -683,7 +683,7 @@ static int __cmd_diff(void)
         d->session = perf_session__new(&d->file, false, &tool);
         if (!d->session) {
             pr_err("Failed to open %s\n", d->file.path);
-            ret = -ENOMEM;
+            ret = -1;
             goto out_delete;
         }
 
tools/perf/builtin-evlist.c +1 -1
index 66e12f5..0f93f85 100644
@@ -28,7 +28,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
 
     session = perf_session__new(&file, 0, NULL);
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     evlist__for_each(session->evlist, pos)
         perf_evsel__fprintf(pos, details, stdout);
tools/perf/builtin-inject.c +1 -1
index 9a02807..8dbdd13 100644
@@ -359,7 +359,7 @@ static int __cmd_inject(struct perf_inject *inject)
 
     session = perf_session__new(&file, true, &inject->tool);
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     if (inject->build_ids) {
         inject->tool.sample = perf_event__inject_buildid;
tools/perf/builtin-kmem.c +1 -1
index bef3376..b518f4b 100644
@@ -422,7 +422,7 @@ static int __cmd_kmem(void)
 
     session = perf_session__new(&file, false, &perf_kmem);
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     if (perf_session__create_kernel_maps(session) < 0)
         goto out_delete;
tools/perf/builtin-kvm.c +3 -3
index 43367eb..828e706 100644
@@ -1060,7 +1060,7 @@ static int read_events(struct perf_kvm_stat *kvm)
         .comm            = perf_event__process_comm,
         .ordered_samples    = true,
     };
-    struct perf_data_file file = {
+    struct perf_data_file file = {
         .path = kvm->file_name,
         .mode = PERF_DATA_MODE_READ,
     };
@@ -1069,7 +1069,7 @@ static int read_events(struct perf_kvm_stat *kvm)
     kvm->session = perf_session__new(&file, false, &kvm->tool);
     if (!kvm->session) {
         pr_err("Initializing perf session failed\n");
-        return -EINVAL;
+        return -1;
     }
 
     if (!perf_session__has_traces(kvm->session, "kvm record"))
@@ -1369,7 +1369,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
      */
     kvm->session = perf_session__new(&file, false, &kvm->tool);
     if (kvm->session == NULL) {
-        err = -ENOMEM;
+        err = -1;
         goto out;
     }
     kvm->session->evlist = kvm->evlist;
tools/perf/builtin-lock.c +1 -1
index 6148afc..49f1e30 100644
@@ -862,7 +862,7 @@ static int __cmd_report(bool display_info)
     session = perf_session__new(&file, false, &eops);
     if (!session) {
         pr_err("Initializing perf session failed\n");
-        return -ENOMEM;
+        return -1;
     }
 
     if (!perf_session__has_traces(session, "lock record"))
tools/perf/builtin-mem.c +1 -1
index 4a1a6c9..75976ce 100644
@@ -124,7 +124,7 @@ static int report_raw_events(struct perf_mem *mem)
                              &mem->tool);
 
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     if (mem->cpu_list) {
         ret = perf_session__cpu_bitmap(session, mem->cpu_list,
tools/perf/builtin-report.c +1 -1
index 21d830b..1a7abac 100644
@@ -712,7 +712,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 repeat:
     session = perf_session__new(&file, false, &report.tool);
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     report.session = session;
 
tools/perf/builtin-script.c +1 -1
index f57035b..77cef60 100644
@@ -1725,7 +1725,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 
     session = perf_session__new(&file, false, &script.tool);
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     if (header || header_only) {
         perf_session__fprintf_info(session, stdout, show_full_info);
tools/perf/builtin-timechart.c +1 -1
index 2f1a522..dc9a465 100644
@@ -1605,7 +1605,7 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
     int ret = -EINVAL;
 
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     (void)perf_header__process_sections(&session->header,
                         perf_data_file__fd(session->file),
tools/perf/builtin-top.c +1 -1
index 377971d..8217b5d 100644
@@ -911,7 +911,7 @@ static int __cmd_top(struct perf_top *top)
 
     top->session = perf_session__new(NULL, false, NULL);
     if (top->session == NULL)
-        return -ENOMEM;
+        return -1;
 
     machines__set_symbol_filter(&top->session->machines, symbol_filter);
 
tools/perf/builtin-trace.c +1 -1
index a6c3752..9e23293 100644
@@ -2220,7 +2220,7 @@ static int trace__replay(struct trace *trace)
 
     session = perf_session__new(&file, false, &trace->tool);
     if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
     trace->host = &session->machines.host;
 

Thanks,

Signature · 1 line
taeung
maintainer
#1 lore raw

Hi Taeung,

Please CC perf maintainers when you send a perf patch. I'm adding Arnaldo who maintains tooling part and Jiri who suggested this change.

2014-09-17 (수), 17:31 +0900, taeung:

Quoted 7 lines

Hi,

I modified error code for the requirement as below.

Author: taeung <[email protected]>
Date:   Sat Sep 13 16:22:53 2014 +0900
Quoted 6 lines

modified error code when perf_session__new() fail

Because perf_session__new() could fail
for more reasons than just ENOMEM,
I modified error code(ENOMEM or EINVAL)
into -1.

Hmm.. this seems you copied output of "git show" and send it via an email client. I recommend you to use "git format-patch" and "git send-email" later.

In addition, you forgot to add your Signed-off-by.

That being said I'm okay with the patch itself. Jiri, this is what you wanted to do, right?

Thanks,
Namhyung

Quoted 196 lines
tools/perf/builtin-annotate.c +1 -1
index 1ec429f..81c9fda 100644
@@ -199,7 +199,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
 
      session = perf_session__new(&file, false, &ann->tool);
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      machines__set_symbol_filter(&session->machines, 
 symbol__annotate_init);
tools/perf/builtin-diff.c +1 -1
index 9a5a035..3363dce 100644
@@ -683,7 +683,7 @@ static int __cmd_diff(void)
          d->session = perf_session__new(&d->file, false, &tool);
          if (!d->session) {
              pr_err("Failed to open %s\n", d->file.path);
-            ret = -ENOMEM;
+            ret = -1;
              goto out_delete;
          }
 
tools/perf/builtin-evlist.c +0 -0
index 66e12f5..0f93f85 100644
@@ -28,7 +28,7 @@ static int __cmd_evlist(const char *file_name, struct 

perf_attr_details *details

      session = perf_session__new(&file, 0, NULL);
      if (session == NULL)
tools/perf/builtin-evlist.c +1 -1
-        return -ENOMEM;
+        return -1;
 
      evlist__for_each(session->evlist, pos)
          perf_evsel__fprintf(pos, details, stdout);
tools/perf/builtin-inject.c +1 -1
index 9a02807..8dbdd13 100644
@@ -359,7 +359,7 @@ static int __cmd_inject(struct perf_inject *inject)
 
      session = perf_session__new(&file, true, &inject->tool);
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      if (inject->build_ids) {
          inject->tool.sample = perf_event__inject_buildid;
tools/perf/builtin-kmem.c +1 -1
index bef3376..b518f4b 100644
@@ -422,7 +422,7 @@ static int __cmd_kmem(void)
 
      session = perf_session__new(&file, false, &perf_kmem);
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      if (perf_session__create_kernel_maps(session) < 0)
          goto out_delete;
tools/perf/builtin-kvm.c +3 -3
index 43367eb..828e706 100644
@@ -1060,7 +1060,7 @@ static int read_events(struct perf_kvm_stat *kvm)
          .comm            = perf_event__process_comm,
          .ordered_samples    = true,
      };
-    struct perf_data_file file = {
+    struct perf_data_file file = {
          .path = kvm->file_name,
          .mode = PERF_DATA_MODE_READ,
      };
@@ -1069,7 +1069,7 @@ static int read_events(struct perf_kvm_stat *kvm)
      kvm->session = perf_session__new(&file, false, &kvm->tool);
      if (!kvm->session) {
          pr_err("Initializing perf session failed\n");
-        return -EINVAL;
+        return -1;
      }
 
      if (!perf_session__has_traces(kvm->session, "kvm record"))
@@ -1369,7 +1369,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
       */
      kvm->session = perf_session__new(&file, false, &kvm->tool);
      if (kvm->session == NULL) {
-        err = -ENOMEM;
+        err = -1;
          goto out;
      }
      kvm->session->evlist = kvm->evlist;
tools/perf/builtin-lock.c +1 -1
index 6148afc..49f1e30 100644
@@ -862,7 +862,7 @@ static int __cmd_report(bool display_info)
      session = perf_session__new(&file, false, &eops);
      if (!session) {
          pr_err("Initializing perf session failed\n");
-        return -ENOMEM;
+        return -1;
      }
 
      if (!perf_session__has_traces(session, "lock record"))
tools/perf/builtin-mem.c +1 -1
index 4a1a6c9..75976ce 100644
@@ -124,7 +124,7 @@ static int report_raw_events(struct perf_mem *mem)
                               &mem->tool);
 
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      if (mem->cpu_list) {
          ret = perf_session__cpu_bitmap(session, mem->cpu_list,
tools/perf/builtin-report.c +1 -1
index 21d830b..1a7abac 100644
@@ -712,7 +712,7 @@ int cmd_report(int argc, const char **argv, const 
 char *prefix __maybe_unused)
  repeat:
      session = perf_session__new(&file, false, &report.tool);
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      report.session = session;
tools/perf/builtin-script.c +1 -1
index f57035b..77cef60 100644
@@ -1725,7 +1725,7 @@ int cmd_script(int argc, const char **argv, const 
 char *prefix __maybe_unused)
 
      session = perf_session__new(&file, false, &script.tool);
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      if (header || header_only) {
          perf_session__fprintf_info(session, stdout, show_full_info);
tools/perf/builtin-timechart.c +1 -1
index 2f1a522..dc9a465 100644
@@ -1605,7 +1605,7 @@ static int __cmd_timechart(struct timechart 
 *tchart, const char *output_name)
      int ret = -EINVAL;
 
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      (void)perf_header__process_sections(&session->header,
                          perf_data_file__fd(session->file),
tools/perf/builtin-top.c +1 -1
index 377971d..8217b5d 100644
@@ -911,7 +911,7 @@ static int __cmd_top(struct perf_top *top)
 
      top->session = perf_session__new(NULL, false, NULL);
      if (top->session == NULL)
-        return -ENOMEM;
+        return -1;
 
      machines__set_symbol_filter(&top->session->machines, symbol_filter);
 
tools/perf/builtin-trace.c +1 -1
index a6c3752..9e23293 100644
@@ -2220,7 +2220,7 @@ static int trace__replay(struct trace *trace)
 
      session = perf_session__new(&file, false, &trace->tool);
      if (session == NULL)
-        return -ENOMEM;
+        return -1;
 
      trace->host = &session->machines.host;
 

Thanks,

#2 lore raw
Quoted 16 lines · Namhyung Kim

Hi Taeung,

Please CC perf maintainers when you send a perf patch. I'm adding Arnaldo who maintains tooling part and Jiri who suggested this change.

2014-09-17 (수), 17:31 +0900, taeung:

Quoted 9 lines

Hi,

I modified error code for the requirement as below.

Author: taeung <[email protected]>
Date:   Sat Sep 13 16:22:53 2014 +0900

modified error code when perf_session__new() fail

Quoted 8 lines
Quoted 4 lines

Because perf_session__new() could fail
for more reasons than just ENOMEM,
I modified error code(ENOMEM or EINVAL)
into -1.

Hmm.. this seems you copied output of "git show" and send it via an email client. I recommend you to use "git format-patch" and "git send-email" later.

yep, the patch is mangled.. also following doc might be useful:
Documentation/email-clients.txt

Quoted 5 lines

In addition, you forgot to add your Signed-off-by.

That being said I'm okay with the patch itself. Jiri, this is what you wanted to do, right?

I have some vague memories about this.. any link to refresh my memory? ;-) but right, the change seems ok

jirka

maintainer
#3 lore raw

Hi Jiri,

2014-09-22 (월), 15:46 +0200, Jiri Olsa:

Quoted 5 lines · Namhyung Kim
Quoted 2 lines

That being said I'm okay with the patch itself. Jiri, this is what you wanted to do, right?

I have some vague memories about this.. any link to refresh my memory? ;-)

This is it: https://lkml.org/lkml/2014/8/13/331

Thanks,
Namhyung

Quoted 3 lines

but right, the change seems ok

jirka

author
#4 lore raw

I forwarded the email according to 'git format-patch'. Sorry for my terrible patch format. :-) Because I didn't know how to send patch, I did it.

Thanks,
Taeung

Quoted 18 lines · Namhyung Kim

Hi Jiri,

2014-09-22 (월), 15:46 +0200, Jiri Olsa:

Quoted 4 lines · Namhyung Kim
Quoted 2 lines

That being said I'm okay with the patch itself. Jiri, this is what you wanted to do, right?

I have some vague memories about this.. any link to refresh my memory? ;-)

This is it: https://lkml.org/lkml/2014/8/13/331

Thanks,
Namhyung

Quoted 3 lines

but right, the change seems ok

jirka