From: Andrew Morton <akpm@linux-foundation.org>
To: Andrey Vagin <avagin@openvz.org>
Cc: linux-mm@kvack.org, Glauber Costa <glommer@parallels.com>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Lameter <cl@linux-foundation.org>,
Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>,
Balbir Singh <bsingharora@gmail.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [PATCH] [RFC] kmemcg: remove union from memcg_params
Date: Mon, 12 Aug 2013 15:28:12 -0700 [thread overview]
Message-ID: <20130812152812.915d5e8ebe5467586a457eb0@linux-foundation.org> (raw)
In-Reply-To: <1375995086-15456-1-git-send-email-avagin@openvz.org>
On Fri, 9 Aug 2013 00:51:26 +0400 Andrey Vagin <avagin@openvz.org> wrote:
> struct memcg_cache_params {
> bool is_root_cache;
> union {
> struct kmem_cache *memcg_caches[0];
> struct {
> struct mem_cgroup *memcg;
> struct list_head list;
> struct kmem_cache *root_cache;
> bool dead;
> atomic_t nr_pages;
> struct work_struct destroy;
> };
> };
> };
>
> This union is a bit dangerous. //Andrew Morton
>
> The first problem was fixed in v3.10-rc5-67-gf101a94.
> The second problem is that the size of memory for root
> caches is calculated incorrectly:
>
> ssize_t size = memcg_caches_array_size(num_groups);
>
> size *= sizeof(void *);
> size += sizeof(struct memcg_cache_params);
>
> The last line should be fixed like this:
> size += offsetof(struct memcg_cache_params, memcg_caches)
>
> Andrew suggested to rework this code without union and
> this patch tries to do that.
hm, did I?
> This patch removes is_root_cache and union. The size of the
> memcg_cache_params structure is not changed.
>
It's a bit sad to consume more space because we're sucky programmers.
It would be better to retain the union and to stop writing buggy code
to handle it!
Maybe there are things we can do to reduce the likelihood of people
mishandling the union - don't use anonymous fields, name each member,
access it via helper functions, etc.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-08-12 22:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-08 20:51 Andrey Vagin
2013-08-12 22:28 ` Andrew Morton [this message]
2013-08-13 4:53 ` Andrey Wagin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130812152812.915d5e8ebe5467586a457eb0@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=avagin@openvz.org \
--cc=bsingharora@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=cl@linux-foundation.org \
--cc=glommer@parallels.com \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=mpm@selenic.com \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox