libperf: Rename arguments of perf_thread_map APIs
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
@@ -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
@@ -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
@@ -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
Quoted 36 lines · Tzvetomir Stoyanov (VMware)
The "int thread" input arguments of some
perf_thead_mapAPIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent withperf_cpu_mapAPIs, those arguments are renamed to "int idx".Suggested-by Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>--- 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@@ -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
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
Quoted 40 lines · Jiri Olsa
Quoted 39 lines · Tzvetomir Stoyanov (VMware)
The "int thread" input arguments of some
perf_thead_mapAPIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent withperf_cpu_mapAPIs, those arguments are renamed to "int idx".Suggested-by Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>--- 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@@ -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@@ -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
Arnaldo Carvalho de Melo
maintainerEm 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_mapAPIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent withperf_cpu_mapAPIs, those arguments are renamed to "int idx".Suggested-by Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>--- 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@@ -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@@ -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
Jiri Olsa
Acked-byQuoted 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_mapAPIs are index of the thread in the thread map. In order to avoid confusion and to make the APIs consistent withperf_cpu_mapAPIs, those arguments are renamed to "int idx".Suggested-by Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>--- 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@@ -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@@ -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