Skip to contentSkip to conversation

cgroup: fold struct cg_cgroup_link into struct css_set

RFC PATCH In review Lai Jiangshan 2 participants 4 messages Sep 11, 2008 – Sep 15, 2008 cgroup

lore
Share & tools
lore
#0 lore raw

RFC PATCH 2/2 cgroup: fold struct cg_cgroup_link into struct css_set

one struct cg_cgroup_link per link is very waste.
This way need to allocate struct cg_cgroup_link for (css_set_count * hierarchy_count) times. And it will bring fragments for memory allocation.

This patch fold struct cg_cgroup_link into struct css_set, use cgroup_link[hierarchy_id] for every hierarchy's cgroup's link.

This patch removes lots of line of code. remove struct cg_cgroup_link and corresponding code.

---

include/linux/cgroup.h +7 -7
index 4f281c5..f4ec055 100644
@@ -173,18 +173,18 @@ struct css_set {
 	struct list_head tasks;
 
 	/*
-	 * List of cg_cgroup_link objects on link chains from
-	 * cgroups referenced from this css_set. Protected by
-	 * css_set_lock
-	 */
-	struct list_head cg_links;
-
-	/*
 	 * Set of subsystem states, one for each subsystem. This array
 	 * is immutable after creation apart from the init_css_set
 	 * during subsystem registration (at boot time).
 	 */
 	struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
+
+	/*
+	 * List running through cgroup_link[hierarchy_id] associated with a
+	 * cgroup of the corresponding hierarchy, anchored on
+	 * cgroup->css_sets. Protected by css_set_lock.
+	 */
+	struct list_head cgroup_link[CGROUP_SUBSYS_COUNT];
 };
 
 /*
kernel/cgroup.c +24 -134

293 lines not on this page · raw message

#1 lore raw

sorry for not send to Andrew Morton and send to Paul Menage tiwce.

add [To: Andrew Morton <[email protected]>]

Thanks, Lai

Quoted 5 lines · Lai Jiangshan

one struct cg_cgroup_link per link is very waste.
This way need to allocate struct cg_cgroup_link for (css_set_count * hierarchy_count) times. And it will bring fragments for memory allocation.

#2 lore raw
In reply to Lai Jiangshan
Quoted 4 lines · Lai Jiangshan

one struct cg_cgroup_link per link is very waste. This way need to allocate struct cg_cgroup_link for (css_set_count * hierarchy_count) times.

Correct - but in the common case, hierarchy_count==1. So it's 7 pointers (two list_heads and a pointer in the cg_cgroup_link, and a list_head in the css_set) per css_set. Each additional hierarchy introduces 5 pointers per css_set with the new cg_cgroup_link. (So overall, 2 + 5*H)

We're up to 9 cgroup subsystems in -mm right now, so your approach consumes 18 pointers (9 list heads) per css_set, regardless of how many hierarchies are mounted.

So I think that the current solution saves memory when there are fewer than four hierarchies mounted. As the number of cgroup subsystems increases, the break-even point will increase. I expect that the most common number of mounted hierarchies will be 0 (but there's only one css_set in that case, so the overhead is irrelevant) or 1.

Quoted 3 lines

This patch removes lots of line of code. remove struct cg_cgroup_link and corresponding code.

Yes, the code is definitely simpler after your patch. It's pretty much how it was *before* I introduced the cg_cgroup_link structures to allow an arbitrary number of hierarchies without bloating the css_set structure. I'm not convinced that we want to go back to the original way.

Paul

#3 lore raw
Quoted 6 lines · Paul Menage

Yes, the code is definitely simpler after your patch. It's pretty much how it was *before* I introduced the cg_cgroup_link structures to allow an arbitrary number of hierarchies without bloating the css_set structure. I'm not convinced that we want to go back to the original way.

I didn't know this history. Thank you.

Lai