[PATCH 2/2 V6] lib/show_mem.c: Add dma-buf counter to show_mem dump.

From: Peter Enderborg
Date: Tue Apr 20 2021 - 04:23:03 EST


On system where dma-buf is used it can be many clients that adds up
to a lot of memory. This can be relevant for OOM handling when
running out of memory or how system handle this memory. It may be to free
with a kill.

Suggested-by: Michal Hocko <mhocko@xxxxxxxx>
Signed-off-by: Peter Enderborg <peter.enderborg@xxxxxxxx>
---
lib/show_mem.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/lib/show_mem.c b/lib/show_mem.c
index 1c26c14ffbb9..ec4748c64353 100644
--- a/lib/show_mem.c
+++ b/lib/show_mem.c
@@ -7,6 +7,7 @@

#include <linux/mm.h>
#include <linux/cma.h>
+#include <linux/dma-buf.h>

void show_mem(unsigned int filter, nodemask_t *nodemask)
{
@@ -41,4 +42,8 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
#ifdef CONFIG_MEMORY_FAILURE
printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
#endif
+#ifdef CONFIG_DMA_SHARED_BUFFER
+ printk("%lu pages dma-buf\n", dma_buf_allocated_pages());
+#endif
+
}
--
2.17.1