mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 09:10:12 +01:00
intel/tools/aub: print better error message when mmap fails
Aubinator creates lots of 4k mappings, so for large traces it's possible to hit system limit on the number of mappings created by a single process. Ideally, aubinator should merge those mappings, but that's tricky and I'm not sure it's worth spending time on. Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8988>
This commit is contained in:
parent
93824b6451
commit
0893f6f03f
1 changed files with 24 additions and 8 deletions
|
|
@ -21,6 +21,7 @@
|
|||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
|
@ -136,6 +137,23 @@ cmp_phys_mem(const struct rb_node *node, const void *addr)
|
|||
return cmp_uint64(mem->phys_addr, *(uint64_t *)addr);
|
||||
}
|
||||
|
||||
static void
|
||||
check_mmap_result(const void *res)
|
||||
{
|
||||
if (res != MAP_FAILED)
|
||||
return;
|
||||
|
||||
if (errno == ENOMEM) {
|
||||
fprintf(stderr,
|
||||
"Not enough memory available or maximum number of mappings reached. "
|
||||
"Consider increasing sysctl vm.max_map_count.\n");
|
||||
} else {
|
||||
perror("mmap");
|
||||
}
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
static struct phys_mem *
|
||||
ensure_phys_mem(struct aub_mem *mem, uint64_t phys_addr)
|
||||
{
|
||||
|
|
@ -151,7 +169,7 @@ ensure_phys_mem(struct aub_mem *mem, uint64_t phys_addr)
|
|||
|
||||
new_mem->data = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
mem->mem_fd, new_mem->fd_offset);
|
||||
assert(new_mem->data != MAP_FAILED);
|
||||
check_mmap_result(new_mem->data);
|
||||
|
||||
rb_tree_insert_at(&mem->mem, node, &new_mem->node, cmp < 0);
|
||||
node = &new_mem->node;
|
||||
|
|
@ -268,7 +286,7 @@ aub_mem_get_ggtt_bo(void *_mem, uint64_t address)
|
|||
bo.addr = MIN2(address, start->virt_addr);
|
||||
bo.size = last->virt_addr - bo.addr + 4096;
|
||||
bo.map = mmap(NULL, bo.size, PROT_READ, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
||||
assert(bo.map != MAP_FAILED);
|
||||
check_mmap_result(bo.map);
|
||||
|
||||
for (struct ggtt_entry *i = start;
|
||||
i;
|
||||
|
|
@ -280,10 +298,9 @@ aub_mem_get_ggtt_bo(void *_mem, uint64_t address)
|
|||
continue;
|
||||
|
||||
uint32_t map_offset = i->virt_addr - address;
|
||||
ASSERTED void *res =
|
||||
mmap((uint8_t *)bo.map + map_offset, 4096, PROT_READ,
|
||||
void *res = mmap((uint8_t *)bo.map + map_offset, 4096, PROT_READ,
|
||||
MAP_SHARED | MAP_FIXED, mem->mem_fd, phys_mem->fd_offset);
|
||||
assert(res != MAP_FAILED);
|
||||
check_mmap_result(res);
|
||||
}
|
||||
|
||||
add_gtt_bo_map(mem, bo, false, true);
|
||||
|
|
@ -346,10 +363,9 @@ aub_mem_get_ppgtt_bo(void *_mem, uint64_t address)
|
|||
for (uint64_t page = address; page < end; page += 4096) {
|
||||
struct phys_mem *phys_mem = ppgtt_walk(mem, mem->pml4, page);
|
||||
|
||||
ASSERTED void *res =
|
||||
mmap((uint8_t *)bo.map + (page - bo.addr), 4096, PROT_READ,
|
||||
void *res = mmap((uint8_t *)bo.map + (page - bo.addr), 4096, PROT_READ,
|
||||
MAP_SHARED | MAP_FIXED, mem->mem_fd, phys_mem->fd_offset);
|
||||
assert(res != MAP_FAILED);
|
||||
check_mmap_result(res);
|
||||
}
|
||||
|
||||
add_gtt_bo_map(mem, bo, true, true);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue