Free resources when dlclose is called
When the Thunk is initialized multiple times in the lifetime of a single process
, some global resources are leaked. This can happen when dlopen and dlclose are
used to load the library at runtime, rather than linking the runtime against
the Thunk. This patch adds the destructor to release global resources when
dlclose is called.
Change-Id: Ia00da0d41f095d0b2706f98c0e75effedd596f49
[ROCm/ROCR-Runtime commit: 582b70f9c3]
这个提交包含在:
1 父节点
f01386b61c
当前提交
4dd9dbb128
2 个文件已更改
+27
没有与搜索条件相匹配的文件
@@ -139,6 +139,7 @@ static void __fmm_release(void *address,
|
||||
static int _fmm_unmap_from_gpu_scratch(uint32_t gpu_id,
|
||||
manageble_aperture_t *aperture,
|
||||
void *address);
|
||||
void __attribute__ ((destructor)) fmm_release_global_resources(void);
|
||||
|
||||
static vm_area_t *vm_create_and_init_area(void *start, void *end)
|
||||
{
|
||||
@@ -1544,3 +1545,16 @@ bool fmm_get_handle(void *address, uint64_t *handle)
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
void fmm_release_global_resources(void)
|
||||
{
|
||||
uint64_t len;
|
||||
|
||||
if (dgpu_shared_aperture_base) {
|
||||
len = (uint64_t)dgpu_shared_aperture_limit
|
||||
- (uint64_t)dgpu_shared_aperture_base + 1;
|
||||
munmap(dgpu_shared_aperture_base, len);
|
||||
}
|
||||
dgpu_shared_aperture_base = NULL;
|
||||
dgpu_shared_aperture_limit = NULL;
|
||||
}
|
||||
@@ -48,6 +48,8 @@ extern int amd_hsa_thunk_lock_fd;
|
||||
|
||||
static HsaCounterProperties *counter_props[MAX_NODES] = {NULL};
|
||||
|
||||
void __attribute__ ((destructor)) perfctr_release_global_resources(void);
|
||||
|
||||
static int blockid2uuid(enum perf_block_id block_id, HSA_UUID *uuid)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -368,3 +370,14 @@ hsaKmtPmcStopTrace(
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void perfctr_release_global_resources(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<MAX_NODES; i++)
|
||||
if (counter_props[i] != NULL) {
|
||||
free(counter_props[i]);
|
||||
counter_props[i] = NULL;
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户