* [PATCH] libperf: Rename arguments of perf_thread_map APIs
@ 2022-02-21 10:26 Tzvetomir Stoyanov (VMware)
2022-02-21 19:46 ` Jiri Olsa
0 siblings, 1 reply; 5+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2022-02-21 10:26 UTC (permalink / raw)
To: acme, olsajiri, irogers; +Cc: linux-perf-users
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".
Suggested-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
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(-)
diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt
index 32c5051c24eb..a21f733b95b1 100644
--- a/tools/lib/perf/Documentation/libperf.txt
+++ b/tools/lib/perf/Documentation/libperf.txt
@@ -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);
diff --git a/tools/lib/perf/include/perf/threadmap.h b/tools/lib/perf/include/perf/threadmap.h
index a7c50de8d010..58f7fbdce446 100644
--- a/tools/lib/perf/include/perf/threadmap.h
+++ b/tools/lib/perf/include/perf/threadmap.h
@@ -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);
diff --git a/tools/lib/perf/threadmap.c b/tools/lib/perf/threadmap.c
index e92c368b0a6c..84fa07c79d00 100644
--- a/tools/lib/perf/threadmap.c
+++ b/tools/lib/perf/threadmap.c
@@ -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;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libperf: Rename arguments of perf_thread_map APIs
2022-02-21 10:26 [PATCH] libperf: Rename arguments of perf_thread_map APIs Tzvetomir Stoyanov (VMware)
@ 2022-02-21 19:46 ` Jiri Olsa
2022-02-21 20:02 ` Arnaldo Carvalho de Melo
2022-02-23 15:27 ` Arnaldo Carvalho de Melo
0 siblings, 2 replies; 5+ messages in thread
From: Jiri Olsa @ 2022-02-21 19:46 UTC (permalink / raw)
To: Tzvetomir Stoyanov (VMware); +Cc: acme, irogers, linux-perf-users
On Mon, Feb 21, 2022 at 12:26:12PM +0200, Tzvetomir Stoyanov (VMware) wrote:
> 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".
>
> Suggested-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
> 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(-)
>
> diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt
> index 32c5051c24eb..a21f733b95b1 100644
> --- a/tools/lib/perf/Documentation/libperf.txt
> +++ b/tools/lib/perf/Documentation/libperf.txt
> @@ -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);
> diff --git a/tools/lib/perf/include/perf/threadmap.h b/tools/lib/perf/include/perf/threadmap.h
> index a7c50de8d010..58f7fbdce446 100644
> --- a/tools/lib/perf/include/perf/threadmap.h
> +++ b/tools/lib/perf/include/perf/threadmap.h
> @@ -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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libperf: Rename arguments of perf_thread_map APIs
2022-02-21 19:46 ` Jiri Olsa
@ 2022-02-21 20:02 ` Arnaldo Carvalho de Melo
2022-02-23 15:27 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-02-21 20:02 UTC (permalink / raw)
To: Jiri Olsa, Tzvetomir Stoyanov (VMware); +Cc: acme, irogers, linux-perf-users
On February 21, 2022 4:46:40 PM GMT-03:00, Jiri Olsa <olsajiri@gmail.com> wrote:
>On Mon, Feb 21, 2022 at 12:26:12PM +0200, Tzvetomir Stoyanov (VMware) wrote:
>> 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".
>>
>> Suggested-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
>> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
>> ---
>> 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(-)
>>
>> diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt
>> index 32c5051c24eb..a21f733b95b1 100644
>> --- a/tools/lib/perf/Documentation/libperf.txt
>> +++ b/tools/lib/perf/Documentation/libperf.txt
>> @@ -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);
>> diff --git a/tools/lib/perf/include/perf/threadmap.h b/tools/lib/perf/include/perf/threadmap.h
>> index a7c50de8d010..58f7fbdce446 100644
>> --- a/tools/lib/perf/include/perf/threadmap.h
>> +++ b/tools/lib/perf/include/perf/threadmap.h
>> @@ -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?
I don't think so, this is just a clarification, it's not even a semantic change, those are indices from the get go.
> do we care at this point? ;-)
Of course we care, this isn't even a deprecation! 8-)
>not sure if we already started to treat libperf properly in this regard
We better, it's in tools/lib/.
- Arnaldo
>
>jirka
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libperf: Rename arguments of perf_thread_map APIs
2022-02-21 19:46 ` Jiri Olsa
2022-02-21 20:02 ` Arnaldo Carvalho de Melo
@ 2022-02-23 15:27 ` Arnaldo Carvalho de Melo
2022-02-23 17:14 ` Jiri Olsa
1 sibling, 1 reply; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-02-23 15:27 UTC (permalink / raw)
To: Jiri Olsa; +Cc: Tzvetomir Stoyanov (VMware), irogers, linux-perf-users
Em Mon, Feb 21, 2022 at 08:46:40PM +0100, Jiri Olsa escreveu:
> On Mon, Feb 21, 2022 at 12:26:12PM +0200, Tzvetomir Stoyanov (VMware) wrote:
> > 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".
> >
> > Suggested-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
> > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> > ---
> > 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(-)
> >
> > diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt
> > index 32c5051c24eb..a21f733b95b1 100644
> > --- a/tools/lib/perf/Documentation/libperf.txt
> > +++ b/tools/lib/perf/Documentation/libperf.txt
> > @@ -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);
> > diff --git a/tools/lib/perf/include/perf/threadmap.h b/tools/lib/perf/include/perf/threadmap.h
> > index a7c50de8d010..58f7fbdce446 100644
> > --- a/tools/lib/perf/include/perf/threadmap.h
> > +++ b/tools/lib/perf/include/perf/threadmap.h
> > @@ -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
So, I don't think this changes the ABI, no semantic change, just a
clarification.
Are you ok with it?
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libperf: Rename arguments of perf_thread_map APIs
2022-02-23 15:27 ` Arnaldo Carvalho de Melo
@ 2022-02-23 17:14 ` Jiri Olsa
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Olsa @ 2022-02-23 17:14 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Tzvetomir Stoyanov (VMware), irogers, linux-perf-users
On Wed, Feb 23, 2022 at 12:27:34PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Feb 21, 2022 at 08:46:40PM +0100, Jiri Olsa escreveu:
> > On Mon, Feb 21, 2022 at 12:26:12PM +0200, Tzvetomir Stoyanov (VMware) wrote:
> > > 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".
> > >
> > > Suggested-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
> > > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> > > ---
> > > 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(-)
> > >
> > > diff --git a/tools/lib/perf/Documentation/libperf.txt b/tools/lib/perf/Documentation/libperf.txt
> > > index 32c5051c24eb..a21f733b95b1 100644
> > > --- a/tools/lib/perf/Documentation/libperf.txt
> > > +++ b/tools/lib/perf/Documentation/libperf.txt
> > > @@ -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);
> > > diff --git a/tools/lib/perf/include/perf/threadmap.h b/tools/lib/perf/include/perf/threadmap.h
> > > index a7c50de8d010..58f7fbdce446 100644
> > > --- a/tools/lib/perf/include/perf/threadmap.h
> > > +++ b/tools/lib/perf/include/perf/threadmap.h
> > > @@ -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
>
> 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
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-23 17:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-21 10:26 [PATCH] libperf: Rename arguments of perf_thread_map APIs Tzvetomir Stoyanov (VMware)
2022-02-21 19:46 ` Jiri Olsa
2022-02-21 20:02 ` Arnaldo Carvalho de Melo
2022-02-23 15:27 ` Arnaldo Carvalho de Melo
2022-02-23 17:14 ` Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.