[RFC PATCH bpf-next 04/10] mm, memcg: Make obj_cgroup_{charge, uncharge}_pages public

Yafang Shao
2022-06-19T15:50:53Z

Make these two helpers public for later use.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/linux/memcontrol.h | 4 ++++
mm/memcontrol.c | 11 ++++-------
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 402b42670bcd..ec4637687d6a 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1709,6 +1709,10 @@ struct obj_cgroup *get_obj_cgroup_from_page(struct page *page);

int obj_cgroup_charge(struct obj_cgroup *objcg, gfp_t gfp, size_t size);
void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size);
+int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
+ unsigned int nr_pages);
+void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
+ unsigned int nr_pages);

extern struct static_key_false memcg_kmem_enabled_key;

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 350a7849dac3..0ba321afba3b 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -260,9 +260,6 @@ bool mem_cgroup_kmem_disabled(void)
return cgroup_memory_nokmem;
}

-static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
- unsigned int nr_pages);
-
static void obj_cgroup_release(struct percpu_ref *ref)
{
struct obj_cgroup *objcg = container_of(ref, struct obj_cgroup, refcnt);
@@ -2991,8 +2988,8 @@ static void memcg_account_kmem(struct mem_cgroup *memcg, int nr_pages)
* @objcg: object cgroup to uncharge
* @nr_pages: number of pages to uncharge
*/
-static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
- unsigned int nr_pages)
+void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
+ unsigned int nr_pages)
{
struct mem_cgroup *memcg;

@@ -3012,8 +3009,8 @@ static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
*
* Returns 0 on success, an error code on failure.
*/
-static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
- unsigned int nr_pages)
+int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
+ unsigned int nr_pages)
{
struct mem_cgroup *memcg;
int ret;
--
2.17.1