@@ -727,6 +727,8 @@ EXPORT_SYMBOL_GPL(of_css);
727
727
; \
728
728
else
729
729
730
+ static struct kmem_cache * cgrp_cset_link_pool ;
731
+
730
732
/*
731
733
* The default css_set - used by init and its children prior to any
732
734
* hierarchies being mounted. It contains a pointer to the root state
@@ -957,7 +959,7 @@ void put_css_set_locked(struct css_set *cset)
957
959
list_del (& link -> cgrp_link );
958
960
if (cgroup_parent (link -> cgrp ))
959
961
cgroup_put (link -> cgrp );
960
- kfree ( link );
962
+ kmem_cache_free ( cgrp_cset_link_pool , link );
961
963
}
962
964
963
965
if (css_set_threaded (cset )) {
@@ -1107,7 +1109,7 @@ static void free_cgrp_cset_links(struct list_head *links_to_free)
1107
1109
1108
1110
list_for_each_entry_safe (link , tmp_link , links_to_free , cset_link ) {
1109
1111
list_del (& link -> cset_link );
1110
- kfree ( link );
1112
+ kmem_cache_free ( cgrp_cset_link_pool , link );
1111
1113
}
1112
1114
}
1113
1115
@@ -1127,7 +1129,7 @@ static int allocate_cgrp_cset_links(int count, struct list_head *tmp_links)
1127
1129
INIT_LIST_HEAD (tmp_links );
1128
1130
1129
1131
for (i = 0 ; i < count ; i ++ ) {
1130
- link = kzalloc ( sizeof ( * link ) , GFP_KERNEL );
1132
+ link = kmem_cache_zalloc ( cgrp_cset_link_pool , GFP_KERNEL );
1131
1133
if (!link ) {
1132
1134
free_cgrp_cset_links (tmp_links );
1133
1135
return - ENOMEM ;
@@ -1339,7 +1341,7 @@ static void cgroup_destroy_root(struct cgroup_root *root)
1339
1341
list_for_each_entry_safe (link , tmp_link , & cgrp -> cset_links , cset_link ) {
1340
1342
list_del (& link -> cset_link );
1341
1343
list_del (& link -> cgrp_link );
1342
- kfree ( link );
1344
+ kmem_cache_free ( cgrp_cset_link_pool , link );
1343
1345
}
1344
1346
1345
1347
spin_unlock_irq (& css_set_lock );
@@ -5732,6 +5734,8 @@ int __init cgroup_init(void)
5732
5734
struct cgroup_subsys * ss ;
5733
5735
int ssid ;
5734
5736
5737
+ cgrp_cset_link_pool = KMEM_CACHE (cgrp_cset_link , SLAB_HWCACHE_ALIGN | SLAB_PANIC );
5738
+
5735
5739
BUILD_BUG_ON (CGROUP_SUBSYS_COUNT > 16 );
5736
5740
BUG_ON (cgroup_init_cftypes (NULL , cgroup_base_files ));
5737
5741
BUG_ON (cgroup_init_cftypes (NULL , cgroup1_base_files ));
0 commit comments