Skip to contentSkip to conversation

libperf: Rename arguments of perf_thread_map APIs

PATCH In review Tzvetomir Stoyanov (VMware) 4 participants 5 messages Feb 21, 2022 – Feb 23, 2022 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libperf: Rename arguments of perf_thread_map APIs

The "int thread" input arguments of some perf_thead_map APIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent with perf_cpu_map APIs, those arguments are renamed to "int idx".

---
 tools/lib/perf/Documentation/libperf.txt |  6 +++---
 tools/lib/perf/include/perf/threadmap.h  |  6 +++---
 tools/lib/perf/threadmap.c               | 12 ++++++------
 3 files changed, 12 insertions(+), 12 deletions(-)
tools/lib/perf/Documentation/libperf.txt +3 -3
index 32c5051c24eb..a21f733b95b1 100644
@@ -63,10 +63,10 @@ SYNOPSIS
 
   struct perf_thread_map *perf_thread_map__new_dummy(void);
 
-  void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-  char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+  void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+  char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
   int perf_thread_map__nr(struct perf_thread_map *threads);
-  pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+  pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);
 
   struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
   void perf_thread_map__put(struct perf_thread_map *map);
tools/lib/perf/include/perf/threadmap.h +3 -3
index a7c50de8d010..58f7fbdce446 100644
@@ -9,10 +9,10 @@ struct perf_thread_map;
 
 LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void);
 
-LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
 LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads);
-LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);
 
 LIBPERF_API struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
 LIBPERF_API void perf_thread_map__put(struct perf_thread_map *map);
tools/lib/perf/threadmap.c +6 -6
index e92c368b0a6c..84fa07c79d00 100644
@@ -32,14 +32,14 @@ struct perf_thread_map *perf_thread_map__realloc(struct perf_thread_map *map, in
 
 #define thread_map__alloc(__nr) perf_thread_map__realloc(NULL, __nr)
 
-void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid)
+void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid)
 {
-	map->map[thread].pid = pid;
+	map->map[idx].pid = pid;
 }
 
-char *perf_thread_map__comm(struct perf_thread_map *map, int thread)
+char *perf_thread_map__comm(struct perf_thread_map *map, int idx)
 {
-	return map->map[thread].comm;
+	return map->map[idx].comm;
 }
 
 struct perf_thread_map *perf_thread_map__new_dummy(void)
@@ -85,7 +85,7 @@ int perf_thread_map__nr(struct perf_thread_map *threads)
 	return threads ? threads->nr : 1;
 }
 
-pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread)
+pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx)
 {
-	return map->map[thread].pid;
+	return map->map[idx].pid;
 }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 36 lines · Tzvetomir Stoyanov (VMware)

The "int thread" input arguments of some perf_thead_map APIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent with perf_cpu_map APIs, those arguments are renamed to "int idx".

---
 tools/lib/perf/Documentation/libperf.txt |  6 +++---
 tools/lib/perf/include/perf/threadmap.h  |  6 +++---
 tools/lib/perf/threadmap.c               | 12 ++++++------
 3 files changed, 12 insertions(+), 12 deletions(-)
tools/lib/perf/Documentation/libperf.txt +3 -3
index 32c5051c24eb..a21f733b95b1 100644
@@ -63,10 +63,10 @@ SYNOPSIS
 
   struct perf_thread_map *perf_thread_map__new_dummy(void);
 
-  void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-  char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+  void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+  char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
   int perf_thread_map__nr(struct perf_thread_map *threads);
-  pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+  pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);
 
   struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
   void perf_thread_map__put(struct perf_thread_map *map);
tools/lib/perf/include/perf/threadmap.h +0 -0
index a7c50de8d010..58f7fbdce446 100644

tools/lib/perf/include/perf/threadmap.h struct perf_thread_map; · line 15

Quoted 10 lines
tools/lib/perf/include/perf/threadmap.h +3 -3
@@ -9,10 +9,10 @@ struct perf_thread_map;
 
 LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void);
 
-LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
 LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads);
-LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);

does this argument name change break abi? do we care at this point? ;-) not sure if we already started to treat libperf properly in this regard

jirka

#2 lore raw
Quoted 40 lines · Jiri Olsa
Quoted 39 lines · Tzvetomir Stoyanov (VMware)

The "int thread" input arguments of some perf_thead_map APIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent with perf_cpu_map APIs, those arguments are renamed to "int idx".

---
 tools/lib/perf/Documentation/libperf.txt |  6 +++---
 tools/lib/perf/include/perf/threadmap.h  |  6 +++---
 tools/lib/perf/threadmap.c               | 12 ++++++------
 3 files changed, 12 insertions(+), 12 deletions(-)
tools/lib/perf/Documentation/libperf.txt +3 -3
index 32c5051c24eb..a21f733b95b1 100644
@@ -63,10 +63,10 @@ SYNOPSIS
 
   struct perf_thread_map *perf_thread_map__new_dummy(void);
 
-  void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-  char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+  void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+  char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
   int perf_thread_map__nr(struct perf_thread_map *threads);
-  pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+  pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);
 
   struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
   void perf_thread_map__put(struct perf_thread_map *map);
tools/lib/perf/include/perf/threadmap.h +0 -0
index a7c50de8d010..58f7fbdce446 100644
@@ -9,10 +9,10 @@ struct perf_thread_map;
 
 LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void);
 
Quoted 9 lines

tools/lib/perf/include/perf/threadmap.h struct perf_thread_map; · line 15

Quoted 7 lines
tools/lib/perf/include/perf/threadmap.h +3 -3
-LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
 LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads);
-LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);

does this argument name change break abi?

I don't think so, this is just a clarification, it's not even a semantic change, those are indices from the get go.

Quoted 1 line

do we care at this point? ;-)

Of course we care, this isn't even a deprecation! 8-)

Quoted 1 line

not sure if we already started to treat libperf properly in this regard

We better, it's in tools/lib/.

- Arnaldo

Quoted 2 lines

jirka

#3 lore raw
In reply to Jiri Olsa

Em Mon, Feb 21, 2022 at 08:46:40PM +0100, Jiri Olsa escreveu:

Quoted 40 lines · Tzvetomir Stoyanov (VMware)
Quoted 39 lines

The "int thread" input arguments of some perf_thead_map APIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent with perf_cpu_map APIs, those arguments are renamed to "int idx".

---
 tools/lib/perf/Documentation/libperf.txt |  6 +++---
 tools/lib/perf/include/perf/threadmap.h  |  6 +++---
 tools/lib/perf/threadmap.c               | 12 ++++++------
 3 files changed, 12 insertions(+), 12 deletions(-)
tools/lib/perf/Documentation/libperf.txt +3 -3
index 32c5051c24eb..a21f733b95b1 100644
@@ -63,10 +63,10 @@ SYNOPSIS
 
   struct perf_thread_map *perf_thread_map__new_dummy(void);
 
-  void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-  char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+  void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+  char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
   int perf_thread_map__nr(struct perf_thread_map *threads);
-  pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+  pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);
 
   struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
   void perf_thread_map__put(struct perf_thread_map *map);
tools/lib/perf/include/perf/threadmap.h +0 -0
index a7c50de8d010..58f7fbdce446 100644
@@ -9,10 +9,10 @@ struct perf_thread_map;
 
 LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void);
 
Quoted 10 lines

tools/lib/perf/include/perf/threadmap.h struct perf_thread_map; · line 15

Quoted 7 lines
tools/lib/perf/include/perf/threadmap.h +3 -3
-LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
 LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads);
-LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);

does this argument name change break abi? do we care at this point? ;-) not sure if we already started to treat libperf properly in this regard

So, I don't think this changes the ABI, no semantic change, just a clarification.

Are you ok with it?

- Arnaldo

Acked-by
#4 lore raw
Quoted 52 lines · Arnaldo Carvalho de Melo

Em Mon, Feb 21, 2022 at 08:46:40PM +0100, Jiri Olsa escreveu:

Quoted 40 lines · Tzvetomir Stoyanov (VMware)
Quoted 39 lines

The "int thread" input arguments of some perf_thead_map APIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent with perf_cpu_map APIs, those arguments are renamed to "int idx".

---
 tools/lib/perf/Documentation/libperf.txt |  6 +++---
 tools/lib/perf/include/perf/threadmap.h  |  6 +++---
 tools/lib/perf/threadmap.c               | 12 ++++++------
 3 files changed, 12 insertions(+), 12 deletions(-)
tools/lib/perf/Documentation/libperf.txt +3 -3
index 32c5051c24eb..a21f733b95b1 100644
@@ -63,10 +63,10 @@ SYNOPSIS
 
   struct perf_thread_map *perf_thread_map__new_dummy(void);
 
-  void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-  char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+  void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+  char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
   int perf_thread_map__nr(struct perf_thread_map *threads);
-  pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+  pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);
 
   struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
   void perf_thread_map__put(struct perf_thread_map *map);
tools/lib/perf/include/perf/threadmap.h +0 -0
index a7c50de8d010..58f7fbdce446 100644
@@ -9,10 +9,10 @@ struct perf_thread_map;
 
 LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void);
 
Quoted 10 lines

tools/lib/perf/include/perf/threadmap.h struct perf_thread_map; · line 15

Quoted 7 lines
tools/lib/perf/include/perf/threadmap.h +3 -3
-LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
-LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid);
+LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int idx);
 LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads);
-LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
+LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int idx);

does this argument name change break abi? do we care at this point? ;-) not sure if we already started to treat libperf properly in this regard

Quoted 4 lines

So, I don't think this changes the ABI, no semantic change, just a clarification.

Are you ok with it?

yes, I think it's ok

thanks,
jirka