Skip to content

Commit

Permalink
Fix for perfmon_init_maps if already initialized. Proper error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTheBear committed Sep 12, 2024
1 parent 8278e2e commit ba8b2dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/luawid.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,11 @@ lua_likwid_getEventsAndCounters(lua_State* L)
affinity_init();
affinity_isInitialized = 1;
}
perfmon_init_maps();
int err = perfmon_init_maps();
if (err != 0)
{
return 0;
}
perfmon_check_counter_map(0);
char** archTypeNames = getArchRegisterTypeNames();
lua_newtable(L);
Expand Down
5 changes: 4 additions & 1 deletion src/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,10 @@ perfmon_init_maps(void)
{
int err = 0;
if (eventHash != NULL && counter_map != NULL && box_map != NULL && perfmon_numCounters > 0 && perfmon_numArchEvents > 0)
return -EINVAL;
{
// Already initialized
return 0;
}
switch ( cpuid_info.family )
{
case P6_FAMILY:
Expand Down
6 changes: 5 additions & 1 deletion src/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ power_init(int cpuId)
break;
}

perfmon_init_maps();
err = perfmon_init_maps();
if (err != 0)
{
return err;
}
if (!HPMinitialized())
{
HPMinit();
Expand Down

0 comments on commit ba8b2dc

Please sign in to comment.