mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 07:00:12 +01:00
intel/dump_gpu: further track mapping of BOs
We can go further in tracking what BOs are written to by the driver by tracking when a buffer in unmapped. A BO could be mmap, written, unmap and never be written to again. In such case we can just write the BO's content on the first exec buf after unmap and never write it again. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2201>
This commit is contained in:
parent
63c90acc9e
commit
c4bfa6dfbb
1 changed files with 31 additions and 5 deletions
|
|
@ -48,9 +48,11 @@
|
||||||
|
|
||||||
static int close_init_helper(int fd);
|
static int close_init_helper(int fd);
|
||||||
static int ioctl_init_helper(int fd, unsigned long request, ...);
|
static int ioctl_init_helper(int fd, unsigned long request, ...);
|
||||||
|
static int munmap_init_helper(void *addr, size_t length);
|
||||||
|
|
||||||
static int (*libc_close)(int fd) = close_init_helper;
|
static int (*libc_close)(int fd) = close_init_helper;
|
||||||
static int (*libc_ioctl)(int fd, unsigned long request, ...) = ioctl_init_helper;
|
static int (*libc_ioctl)(int fd, unsigned long request, ...) = ioctl_init_helper;
|
||||||
|
static int (*libc_munmap)(void *addr, size_t length) = munmap_init_helper;
|
||||||
|
|
||||||
static int drm_fd = -1;
|
static int drm_fd = -1;
|
||||||
static char *output_filename = NULL;
|
static char *output_filename = NULL;
|
||||||
|
|
@ -65,7 +67,12 @@ struct bo {
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
void *map;
|
void *map;
|
||||||
bool mapped;
|
/* Tracks userspace mmapping of the buffer */
|
||||||
|
bool user_mapped : 1;
|
||||||
|
/* Using the i915-gem mmapping ioctl & execbuffer ioctl, track whether a
|
||||||
|
* buffer has been updated.
|
||||||
|
*/
|
||||||
|
bool dirty : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct bo *bos;
|
static struct bo *bos;
|
||||||
|
|
@ -286,7 +293,7 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
|
||||||
else
|
else
|
||||||
data = bo->map;
|
data = bo->map;
|
||||||
|
|
||||||
if (bo->mapped) {
|
if (bo->dirty) {
|
||||||
if (bo == batch_bo) {
|
if (bo == batch_bo) {
|
||||||
aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_BATCH,
|
aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_BATCH,
|
||||||
GET_PTR(data), bo->size, bo->offset);
|
GET_PTR(data), bo->size, bo->offset);
|
||||||
|
|
@ -294,6 +301,9 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
|
||||||
aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_NOTYPE,
|
aub_write_trace_block(&aub_file, AUB_TRACE_TYPE_NOTYPE,
|
||||||
GET_PTR(data), bo->size, bo->offset);
|
GET_PTR(data), bo->size, bo->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bo->user_mapped)
|
||||||
|
bo->dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data != bo->map)
|
if (data != bo->map)
|
||||||
|
|
@ -334,7 +344,7 @@ add_new_bo(unsigned fd, int handle, uint64_t size, void *map)
|
||||||
|
|
||||||
bo->size = size;
|
bo->size = size;
|
||||||
bo->map = map;
|
bo->map = map;
|
||||||
bo->mapped = false;
|
bo->user_mapped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -346,7 +356,7 @@ remove_bo(int fd, int handle)
|
||||||
munmap(bo->map, bo->size);
|
munmap(bo->map, bo->size);
|
||||||
bo->size = 0;
|
bo->size = 0;
|
||||||
bo->map = NULL;
|
bo->map = NULL;
|
||||||
bo->mapped = false;
|
bo->user_mapped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__ ((visibility ("default"))) int
|
__attribute__ ((visibility ("default"))) int
|
||||||
|
|
@ -646,7 +656,8 @@ ioctl(int fd, unsigned long request, ...)
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
struct drm_i915_gem_mmap *mmap = argp;
|
struct drm_i915_gem_mmap *mmap = argp;
|
||||||
struct bo *bo = get_bo(fd, mmap->handle);
|
struct bo *bo = get_bo(fd, mmap->handle);
|
||||||
bo->mapped = true;
|
bo->user_mapped = true;
|
||||||
|
bo->dirty = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -664,6 +675,7 @@ init(void)
|
||||||
{
|
{
|
||||||
libc_close = dlsym(RTLD_NEXT, "close");
|
libc_close = dlsym(RTLD_NEXT, "close");
|
||||||
libc_ioctl = dlsym(RTLD_NEXT, "ioctl");
|
libc_ioctl = dlsym(RTLD_NEXT, "ioctl");
|
||||||
|
libc_munmap = dlsym(RTLD_NEXT, "munmap");
|
||||||
fail_if(libc_close == NULL || libc_ioctl == NULL,
|
fail_if(libc_close == NULL || libc_ioctl == NULL,
|
||||||
"failed to get libc ioctl or close\n");
|
"failed to get libc ioctl or close\n");
|
||||||
}
|
}
|
||||||
|
|
@ -689,6 +701,20 @@ ioctl_init_helper(int fd, unsigned long request, ...)
|
||||||
return libc_ioctl(fd, request, argp);
|
return libc_ioctl(fd, request, argp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
munmap_init_helper(void *addr, size_t length)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
for (uint32_t i = 0; i < MAX_FD_COUNT * MAX_BO_COUNT; i++) {
|
||||||
|
struct bo *bo = &bos[i];
|
||||||
|
if (bo->map == addr) {
|
||||||
|
bo->user_mapped = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return libc_munmap(addr, length);
|
||||||
|
}
|
||||||
|
|
||||||
static void __attribute__ ((destructor))
|
static void __attribute__ ((destructor))
|
||||||
fini(void)
|
fini(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue