@@ -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,
};
@@ -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);
Signed-off-by: Qiang Yu <qiang.yu@amd.com> --- include/linux/memcontrol.h | 1 + mm/memcontrol.c | 9 +++++++++ 2 files changed, 10 insertions(+)