hulk inclusion category: performance bugzilla: https://gitee.com/openeuler/kernel/issues/I8QP0D
--------------------------------
Signed-off-by: Zeng Heng zengheng4@huawei.com --- mm/memcontrol.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c9ffc793e42b..42ed5778062a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6261,6 +6261,11 @@ static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) kfree(pn); }
+struct mem_cgroup_padding { + u64 padding[6]; + struct mem_cgroup memcg; +} __attribute__((__packed__)); + static void __mem_cgroup_free(struct mem_cgroup *memcg) { int node; @@ -6269,7 +6274,8 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg) free_mem_cgroup_per_node_info(memcg, node); free_percpu(memcg->vmstats_percpu); memcg_free_swap_device(memcg); - kfree(memcg); + + kfree(container_of(memcg, struct mem_cgroup_padding, memcg)); }
static void mem_cgroup_free(struct mem_cgroup *memcg) @@ -6280,19 +6286,22 @@ static void mem_cgroup_free(struct mem_cgroup *memcg)
static struct mem_cgroup *mem_cgroup_alloc(void) { + struct mem_cgroup_padding *memcg_padding; struct mem_cgroup *memcg; unsigned int size; int node; int __maybe_unused i; long error = -ENOMEM;
- size = sizeof(struct mem_cgroup); + size = sizeof(struct mem_cgroup_padding); size += nr_node_ids * sizeof(struct mem_cgroup_per_node *);
- memcg = kzalloc(size, GFP_KERNEL); - if (!memcg) + memcg_padding = kzalloc(size, GFP_KERNEL); + if (!memcg_padding) return ERR_PTR(error);
+ memcg = &memcg_padding->memcg; + if (memcg_alloc_swap_device(memcg)) goto fail;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/3540 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/X...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/3540 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/X...