From: Maxime Ripard Now that the dmem cgroup has been merged, we need to create memory regions for each allocator devices might allocate DMA memory from. Since CMA is one of these allocators, we need to create such a region. CMA can deal with multiple regions though, so we'll need to create a dmem region per CMA region. Signed-off-by: Maxime Ripard Signed-off-by: Eric Chanudet --- mm/cma.c | 13 ++++++++++++- mm/cma.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mm/cma.c b/mm/cma.c index 813e6dc7b0954864c9ef8cf7adc6a2293241de47..78016647d512868cd87bc2c1a52dd2295acaaf01 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -142,6 +143,15 @@ static void __init cma_activate_area(struct cma *cma) int allocrange, r; struct cma_memrange *cmr; unsigned long bitmap_count, count; + struct dmem_cgroup_region *region; + + region = dmem_cgroup_register_region(cma_get_size(cma), "cma/%s", cma->name); + if (IS_ERR(region)) + goto out; + +#ifdef CONFIG_CGROUP_DMEM + cma->dmem_cgrp_region = region; +#endif for (allocrange = 0; allocrange < cma->nranges; allocrange++) { cmr = &cma->ranges[allocrange]; @@ -183,7 +193,8 @@ static void __init cma_activate_area(struct cma *cma) cleanup: for (r = 0; r < allocrange; r++) bitmap_free(cma->ranges[r].bitmap); - + dmem_cgroup_unregister_region(region); +out: /* Expose all pages to the buddy, they are useless for CMA. */ if (!test_bit(CMA_RESERVE_PAGES_ON_ERROR, &cma->flags)) { for (r = 0; r < allocrange; r++) { diff --git a/mm/cma.h b/mm/cma.h index c70180c36559c295d837725e26596cf546cd8b7e..e91bedcb17be8c9e0d31aea1b67c0db36315536d 100644 --- a/mm/cma.h +++ b/mm/cma.h @@ -62,6 +62,9 @@ struct cma { unsigned long flags; /* NUMA node (NUMA_NO_NODE if unspecified) */ int nid; +#ifdef CONFIG_CGROUP_DMEM + struct dmem_cgroup_region *dmem_cgrp_region; +#endif }; enum cma_flags { -- 2.52.0