mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: memset alloced buffers on free
When freeing kmalloc and vmalloc buffers memset them to zero before freeing them with the kernel APIs. This is only done if CONFIG_NVGPU_TRACK_MEM_USAGE is set since this adds obvious overhead to the driver. However, it is an incredibly useful debug tool, so it's nice to have. This could be done by enabling Linux kernel configs as well, but not all OSes may have such a feature so building it into nvgpu may prove quite useful. Change-Id: I7a6a9a6ab4f3606a73a90b354c5a4a7b9cd4d947 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1575565 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> Reviewed-by: Konsta Holtta <kholtta@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
fc5c787339
commit
50975dcf2a
@@ -301,6 +301,8 @@ static int __nvgpu_free_kmem_alloc(struct nvgpu_mem_alloc_tracker *tracker,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset((void *)alloc->addr, 0, alloc->size);
|
||||
|
||||
tracker->nr_frees++;
|
||||
tracker->bytes_freed += alloc->size;
|
||||
tracker->bytes_freed_real += alloc->real_size;
|
||||
@@ -415,9 +417,9 @@ void __nvgpu_track_vfree(struct gk20a *g, void *addr)
|
||||
if (!addr)
|
||||
return;
|
||||
|
||||
vfree(addr);
|
||||
|
||||
__nvgpu_free_kmem_alloc(g->vmallocs, (u64)(uintptr_t)addr);
|
||||
|
||||
vfree(addr);
|
||||
}
|
||||
|
||||
void __nvgpu_track_kfree(struct gk20a *g, void *addr)
|
||||
@@ -425,9 +427,9 @@ void __nvgpu_track_kfree(struct gk20a *g, void *addr)
|
||||
if (!addr)
|
||||
return;
|
||||
|
||||
kfree(addr);
|
||||
|
||||
__nvgpu_free_kmem_alloc(g->kmallocs, (u64)(uintptr_t)addr);
|
||||
|
||||
kfree(addr);
|
||||
}
|
||||
|
||||
static int __do_check_for_outstanding_allocs(
|
||||
|
||||
Reference in New Issue
Block a user