mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
cgroup: Use kmem_cache pool for struct cgrp_cset_link
These get allocated and freed millions of times on Android. Use a dedicated kmem_cache pool and avoid costly dynamic memory allocations. Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com> Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
This commit is contained in:
parent
23a25dce69
commit
733de52458
@ -665,6 +665,8 @@ EXPORT_SYMBOL_GPL(of_css);
|
||||
; \
|
||||
else
|
||||
|
||||
static struct kmem_cache *cgrp_cset_link_pool;
|
||||
|
||||
/*
|
||||
* The default css_set - used by init and its children prior to any
|
||||
* hierarchies being mounted. It contains a pointer to the root state
|
||||
@ -893,7 +895,7 @@ void put_css_set_locked(struct css_set *cset)
|
||||
list_del(&link->cgrp_link);
|
||||
if (cgroup_parent(link->cgrp))
|
||||
cgroup_put(link->cgrp);
|
||||
kfree(link);
|
||||
kmem_cache_free(cgrp_cset_link_pool, link);
|
||||
}
|
||||
|
||||
if (css_set_threaded(cset)) {
|
||||
@ -1043,7 +1045,7 @@ static void free_cgrp_cset_links(struct list_head *links_to_free)
|
||||
|
||||
list_for_each_entry_safe(link, tmp_link, links_to_free, cset_link) {
|
||||
list_del(&link->cset_link);
|
||||
kfree(link);
|
||||
kmem_cache_free(cgrp_cset_link_pool, link);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1063,7 +1065,7 @@ static int allocate_cgrp_cset_links(int count, struct list_head *tmp_links)
|
||||
INIT_LIST_HEAD(tmp_links);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
link = kzalloc(sizeof(*link), GFP_KERNEL);
|
||||
link = kmem_cache_zalloc(cgrp_cset_link_pool, GFP_KERNEL);
|
||||
if (!link) {
|
||||
free_cgrp_cset_links(tmp_links);
|
||||
return -ENOMEM;
|
||||
@ -1275,7 +1277,7 @@ static void cgroup_destroy_root(struct cgroup_root *root)
|
||||
list_for_each_entry_safe(link, tmp_link, &cgrp->cset_links, cset_link) {
|
||||
list_del(&link->cset_link);
|
||||
list_del(&link->cgrp_link);
|
||||
kfree(link);
|
||||
kmem_cache_free(cgrp_cset_link_pool, link);
|
||||
}
|
||||
|
||||
spin_unlock_irq(&css_set_lock);
|
||||
@ -5485,6 +5487,8 @@ int __init cgroup_init(void)
|
||||
struct cgroup_subsys *ss;
|
||||
int ssid;
|
||||
|
||||
cgrp_cset_link_pool = KMEM_CACHE(cgrp_cset_link, SLAB_HWCACHE_ALIGN | SLAB_PANIC);
|
||||
|
||||
BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16);
|
||||
BUG_ON(percpu_init_rwsem(&cgroup_threadgroup_rwsem));
|
||||
BUG_ON(cgroup_init_cftypes(NULL, cgroup_base_files));
|
||||
|
Loading…
x
Reference in New Issue
Block a user