Skip to content

Commit

Permalink
mm/memcg: Use the node id in mem_cgroup_update_tree()
Browse files Browse the repository at this point in the history
By using the node id in mem_cgroup_update_tree(), we can delete
soft_limit_tree_from_page() and mem_cgroup_page_nodeinfo().  Saves 42
bytes of kernel text on my config.

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: David Howells <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) committed Sep 27, 2021
1 parent 6e0110c commit 658b69c
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,28 +456,12 @@ ino_t page_cgroup_ino(struct page *page)
return ino;
}

static struct mem_cgroup_per_node *
mem_cgroup_page_nodeinfo(struct mem_cgroup *memcg, struct page *page)
{
int nid = page_to_nid(page);

return memcg->nodeinfo[nid];
}

static struct mem_cgroup_tree_per_node *
soft_limit_tree_node(int nid)
{
return soft_limit_tree.rb_tree_per_node[nid];
}

static struct mem_cgroup_tree_per_node *
soft_limit_tree_from_page(struct page *page)
{
int nid = page_to_nid(page);

return soft_limit_tree.rb_tree_per_node[nid];
}

static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz,
struct mem_cgroup_tree_per_node *mctz,
unsigned long new_usage_in_excess)
Expand Down Expand Up @@ -548,21 +532,21 @@ static unsigned long soft_limit_excess(struct mem_cgroup *memcg)
return excess;
}

static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page)
static void mem_cgroup_update_tree(struct mem_cgroup *memcg, int nid)
{
unsigned long excess;
struct mem_cgroup_per_node *mz;
struct mem_cgroup_tree_per_node *mctz;

mctz = soft_limit_tree_from_page(page);
mctz = soft_limit_tree_node(nid);
if (!mctz)
return;
/*
* Necessary to update all ancestors when hierarchy is used.
* because their event counter is not touched.
*/
for (; memcg; memcg = parent_mem_cgroup(memcg)) {
mz = mem_cgroup_page_nodeinfo(memcg, page);
mz = memcg->nodeinfo[nid];
excess = soft_limit_excess(memcg);
/*
* We have to update the tree if mz is on RB-tree or
Expand Down Expand Up @@ -852,7 +836,7 @@ static void memcg_check_events(struct mem_cgroup *memcg, struct page *page)
MEM_CGROUP_TARGET_SOFTLIMIT);
mem_cgroup_threshold(memcg);
if (unlikely(do_softlimit))
mem_cgroup_update_tree(memcg, page);
mem_cgroup_update_tree(memcg, page_to_nid(page));
}
}

Expand Down

0 comments on commit 658b69c

Please sign in to comment.