Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1297145

Re: [PATCH 2/4] mm: memcontrol: reign in the CONFIG space madness

From Johannes Weiner <hannes@cmpxchg.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/4] mm: memcontrol: reign in the CONFIG space madness
Date 2015-12-23 00:40 +0100
Message-ID <qIEH8-233-15@gated-at.bofh.it> (permalink)
References (1 earlier) <qEC1c-q7-9@gated-at.bofh.it> <qEVnb-4xa-13@gated-at.bofh.it> <qEW9A-542-7@gated-at.bofh.it> <qIEnL-1Tq-1@gated-at.bofh.it> <qIEnL-1Tq-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Dec 22, 2015 at 03:15:27PM -0800, Andrew Morton wrote:
> On Tue, 22 Dec 2015 15:11:38 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > What I have is
> 
> And after a bit of reject resolution in
> mm-memcontrol-clean-up-alloc-online-offline-free-functions.patch we
> have
> 
> 
> static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
> {
> 	struct mem_cgroup *memcg = mem_cgroup_from_css(css);
> 
> 	if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket)
> 		static_branch_dec(&memcg_sockets_enabled_key);
> 
> 	vmpressure_cleanup(&memcg->vmpressure);
> 	cancel_work_sync(&memcg->high_work);
> 	mem_cgroup_remove_from_trees(memcg);
> 	memcg_free_kmem(memcg);
> 
> 	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && memcg->tcpmem_active)
> 		static_branch_dec(&memcg_sockets_enabled_key);
> 
> 	mem_cgroup_free(memcg);
> }
> 
> code looks a bit strange.  Can we move the static_branch_dec's together
> and run cgroup_subsys_on_dfl just once?

Thanks for fixing it up. I think we can at least put the branches next
to each other. Here is what I have in my local tree:

static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
{
	struct mem_cgroup *memcg = mem_cgroup_from_css(css);

	if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket)
		static_branch_dec(&memcg_sockets_enabled_key);

	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && memcg->tcpmem_active)
		static_branch_dec(&memcg_sockets_enabled_key);

	vmpressure_cleanup(&memcg->vmpressure);
	cancel_work_sync(&memcg->high_work);
	mem_cgroup_remove_from_trees(memcg);
	memcg_free_kmem(memcg);
	mem_cgroup_free(memcg);
}

However, I don't think turning it into this would be an improvement:

	if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
		if (!cgroup_memory_nosocket)
			static_branch_dec(&memcg_sockets_enabled_key);
	} else if (memcg->tcpmem_active) {
		static_branch_dec(&memcg_sockets_enabled_key);
	}

Plus, I'm a little worried that conflating cgroup and cgroup2 blocks
will get us into trouble. Yeah, that code looks a little unusual, but
I can't help but think it's easier to follow the code flow for one
particular mode when the jump labels are always explicit. Then the
brain can easily pattern-match and ignore blocks of the other mode.
It doesn't work the same when we hide keywords in implicit else ifs.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH 2/4] mm: memcontrol: reign in the CONFIG space madness Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-12-12 17:40 +0100
  Re: [PATCH 2/4] mm: memcontrol: reign in the CONFIG space madness Johannes Weiner <hannes@cmpxchg.org> - 2015-12-12 18:30 +0100
    Re: [PATCH 2/4] mm: memcontrol: reign in the CONFIG space madness Andrew Morton <akpm@linux-foundation.org> - 2015-12-23 00:20 +0100
      Re: [PATCH 2/4] mm: memcontrol: reign in the CONFIG space madness Andrew Morton <akpm@linux-foundation.org> - 2015-12-23 00:20 +0100
        Re: [PATCH 2/4] mm: memcontrol: reign in the CONFIG space madness Johannes Weiner <hannes@cmpxchg.org> - 2015-12-23 00:40 +0100

csiph-web