lkml.org 
[lkml]   [2020]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH RESEND v1 02/11] perf mem: Introduce weak function perf_mem_events__ptr()
From
Date
Hi Leo,

On 06/08/2020 04:07, Leo Yan wrote:
>
> for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
> - if (!perf_mem_events[j].record)
> + e = perf_mem_events__ptr(j);
> + if (!e->record)
> continue;
>
> - if (!perf_mem_events[j].supported) {
> + if (!e->supported) {
> pr_err("failed: event '%s' not supported\n",
> - perf_mem_events[j].name);
> + perf_mem_events__name(j));
> free(rec_argv);
> return -1;

Does it make sense to do something like:

for(j = 0; e = perf_mem_events__ptr(j); j++) {
...
}

now that it's a weak function that returns NULL when the argument out of range. That way the caller
doesn't need to know about PERF_MEM_EVENTS__MAX as well and it could potentially be a different
value. I don't know if it would ever make sense to have a different number of events on different platforms?

James

\
 
 \ /
  Last update: 2020-08-28 17:41    [W:0.105 / U:0.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site