summaryrefslogtreecommitdiff
path: root/lib/intel_os.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-04-10 13:16:16 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-04-10 22:11:17 +0100
commite5829165c2ef96140c222429c0f174fb72c4324b (patch)
tree249791a398a5afbae305364b3a46f4796bb00da2 /lib/intel_os.c
parent7c474e011548d35df6b80ceed81d3e6ca560c71d (diff)
lib: Dump meminfo and slabinfo if we complain about insufficient memory
All too frequently, we fail our memory checks to a leak in the driver. While we give every opportunity for the driver to release the memory before we fail, if we do dump the meminfo and slabinfo, if available, so we can assign blame^W^W resolve the problem quickly. References: https://bugs.freedesktop.org/show_bug.cgi?id=105967 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Martin Peres <martin.peres@linux.intel.com> Cc: Tomi Sarvela <tomi.p.sarvela@intel.com> Reviewed-by: Antonio Argenziano <antonio.argenziano@intel.com>
Diffstat (limited to 'lib/intel_os.c')
-rw-r--r--lib/intel_os.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/intel_os.c b/lib/intel_os.c
index bb2c16bf..f7ad05ac 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -51,6 +51,7 @@
#include "drmtest.h"
#include "igt_aux.h"
#include "igt_debugfs.h"
+#include "igt_sysfs.h"
/**
* intel_get_total_ram_mb:
@@ -280,9 +281,32 @@ int __intel_check_memory(uint64_t count, uint64_t size, unsigned mode,
void intel_require_memory(uint64_t count, uint64_t size, unsigned mode)
{
uint64_t required, total;
+ bool sufficient_memory;
+
+ sufficient_memory = __intel_check_memory(count, size, mode,
+ &required, &total);
+ if (!sufficient_memory) {
+ int dir = open("/proc", O_RDONLY);
+ char *info;
+
+ info = igt_sysfs_get(dir, "meminfo");
+ if (info) {
+ igt_debug("Insufficient free memory; /proc/meminfo:\n%s",
+ info);
+ free(info);
+ }
+
+ info = igt_sysfs_get(dir, "slabinfo");
+ if (info) {
+ igt_debug("Insuffucient free memory; /proc/slabinfo:\n%s",
+ info);
+ free(info);
+ }
+
+ close(dir);
+ }
- igt_require_f(__intel_check_memory(count, size, mode,
- &required, &total),
+ igt_require_f(sufficient_memory,
"Estimated that we need %'llu objects and %'llu MiB for the test, but only have %'llu MiB available (%s%s) and a maximum of %'llu objects\n",
(long long)count,
(long long)((required + ((1<<20) - 1)) >> 20),