lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 18 Jul 2012 14:36:12 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Wanpeng Li <liwanp@...ux.vnet.ibm.com>
Cc:	linux-mm@...ck.org, Michal Hocko <mhocko@...e.cz>,
	Johannes Weiner <hannes@...xchg.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	Gavin Shan <shangw@...ux.vnet.ibm.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/memcg: wrap mem_cgroup_from_css function

On Wed, 18 Jul 2012 11:05:30 +0800
Wanpeng Li <liwanp@...ux.vnet.ibm.com> wrote:

> wrap mem_cgroup_from_css function to clarify get mem cgroup
> from cgroup_subsys_state.

This certainly adds clarity.

But it also adds a little more type-safety - these container_of() calls
can be invoked against *any* struct which has a field called "css". 
With your patch, we add a check that the code is indeed using a
cgroup_subsys_state*.  A small thing, but it's all good.


I changed the patch title to the more idiomatic "memcg: add
mem_cgroup_from_css() helper" and rewrote the changelog to

: Add a mem_cgroup_from_css() helper to replace open-coded invokations of
: container_of().  To clarify the code and to add a little more type safety.

> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -396,6 +396,12 @@ static void mem_cgroup_put(struct mem_cgroup *memcg);
>  #include <net/sock.h>
>  #include <net/ip.h>
>  
> +static inline
> +struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s)
> +{
> +	return container_of(s, struct mem_cgroup, css);
> +}

And with great self-control, I avoided renaming this to
memcg_from_css().  Sigh.  I guess all that extra typing has cardio
benefits.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ