[PATCH RFC 2/3] mm: memcontrol: record driver memory statistics
Qiang Yu
qiang.yu at amd.com
Mon Jan 13 15:35:42 UTC 2020
Signed-off-by: Qiang Yu <qiang.yu at amd.com>
---
include/linux/memcontrol.h | 1 +
mm/memcontrol.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index d76977943265..6518b4b5ee07 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -36,6 +36,7 @@ enum memcg_stat_item {
MEMCG_SOCK,
/* XXX: why are these zone and not node counters? */
MEMCG_KERNEL_STACK_KB,
+ MEMCG_DRV,
MEMCG_NR_STAT,
};
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 28595c276e6b..cdd3f3401598 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1413,6 +1413,9 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
seq_buf_printf(&s, "sock %llu\n",
(u64)memcg_page_state(memcg, MEMCG_SOCK) *
PAGE_SIZE);
+ seq_buf_printf(&s, "driver %llu\n",
+ (u64)memcg_page_state(memcg, MEMCG_DRV) *
+ PAGE_SIZE);
seq_buf_printf(&s, "shmem %llu\n",
(u64)memcg_page_state(memcg, NR_SHMEM) *
@@ -6947,6 +6950,9 @@ EXPORT_SYMBOL(mem_cgroup_driver_get_from_current);
int mem_cgroup_charge_drvmem(struct mem_cgroup *memcg, gfp_t gfp,
unsigned long nr_pages)
{
+ if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+ mod_memcg_state(memcg, MEMCG_DRV, nr_pages);
+
return try_charge(memcg, gfp, nr_pages);
}
EXPORT_SYMBOL(mem_cgroup_charge_drvmem);
@@ -6958,6 +6964,9 @@ EXPORT_SYMBOL(mem_cgroup_charge_drvmem);
*/
void mem_cgroup_uncharge_drvmem(struct mem_cgroup *memcg, unsigned long nr_pages)
{
+ if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
+ mod_memcg_state(memcg, MEMCG_DRV, -nr_pages);
+
refill_stock(memcg, nr_pages);
}
EXPORT_SYMBOL(mem_cgroup_uncharge_drvmem);
--
2.17.1
More information about the dri-devel
mailing list