linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: Igor Mammedov <imammedo@redhat.com>
Cc: linux-kernel@vger.kernel.org, kamezawa.hiroyu@jp.fujitsu.com,
	balbir@linux.vnet.ibm.com, akpm@linux-foundation.org,
	linux-mm@kvack.org, Paul Menage <menage@google.com>,
	Li Zefan <lizf@cn.fujitsu.com>,
	containers@lists.linux-foundation.org
Subject: Re: [PATCH] memcg: do not expose uninitialized mem_cgroup_per_node to world
Date: Wed, 1 Jun 2011 15:41:50 +0200	[thread overview]
Message-ID: <20110601134149.GD4266@tiehlicka.suse.cz> (raw)
In-Reply-To: <4DE6399C.8070802@redhat.com>

[Let's CC some cgroup people]

On Wed 01-06-11 15:07:40, Igor Mammedov wrote:
> On 06/01/2011 02:39 PM, Michal Hocko wrote:
> >On Wed 01-06-11 12:44:04, Igor Mammedov wrote:
> >>Freshly allocated 'mem_cgroup_per_node' list entries must be
> >>initialized before the rest of the kernel can see them. Otherwise
> >>zero initialized list fields can lead to race condition at
> >>mem_cgroup_force_empty_list:
> >>   pc = list_entry(list->prev, struct page_cgroup, lru);
> >>where 'pc' will be something like 0xfffffffc if list->prev is 0
> >>and cause page fault later when 'pc' is dereferenced.
> >
> >Have you ever seen such a race? I do not see how this could happen.
> >mem_cgroup_force_empty_list is called only from
> >mem_cgroup_force_empty_write (aka echo whatever>  group/force_empty)
> >or mem_cgroup_pre_destroy when the group is destroyed.
> >
> >The initialization code is, however, called before a group is
> >given for use AFAICS.
> >
> >I am not saying tha the change is bad, I like it, but I do not think it
> >is a fix for potential race condition.
> >
> 
> Yes I've seen it (RHBZ#700565). 

I am not subscribed so I will not get there.

> It causes random crashes in virt env ocasionally. It's easier to
> reproduce if you overcommit cpu.

Hmm, I have missed that cgroup_create calls create callback for all
subsystems that the group should be attached to. But this shouldn't be
any problem as cgroup_call_pre_destroy (called from cgroup_rmdir) cannot
be called before the directory is actually created. 
cgroup_create_dir is called after cgroup has been created for all
subsystems so the directory entry will show up only after everything is
initialized AFAICS.  So I still do not see how we can race.

Anyway, if you are able to reproduce the problem then I would say that
the problem is somewhere in the generic cgroup code rather than in
memory controler. The patch just papers over a real bug IMO. But I may
be wrong as I am not definitely an expert in the area.

> 
> >>Signed-off-by: Igor Mammedov<imammedo@redhat.com>
> >>---
> >>  mm/memcontrol.c |    2 +-
> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >>diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> >>index bd9052a..ee7cb4c 100644
> >>--- a/mm/memcontrol.c
> >>+++ b/mm/memcontrol.c
> >>@@ -4707,7 +4707,6 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *mem, int node)
> >>  	if (!pn)
> >>  		return 1;
> >>
> >>-	mem->info.nodeinfo[node] = pn;
> >>  	for (zone = 0; zone<  MAX_NR_ZONES; zone++) {
> >>  		mz =&pn->zoneinfo[zone];
> >>  		for_each_lru(l)
> >>@@ -4716,6 +4715,7 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *mem, int node)
> >>  		mz->on_tree = false;
> >>  		mz->mem = mem;
> >>  	}
> >>+	mem->info.nodeinfo[node] = pn;
> >>  	return 0;
> >>  }
> >>
> >>-- 
> >>1.7.1

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-06-01 13:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1306925044-2828-1-git-send-email-imammedo@redhat.com>
2011-06-01 12:39 ` Michal Hocko
2011-06-01 13:07   ` Igor Mammedov
2011-06-01 13:41     ` Michal Hocko [this message]
2011-06-01 14:39       ` Igor Mammedov
2011-06-01 15:20         ` Michal Hocko
2011-06-01 16:42           ` Igor Mammedov
2011-06-01 23:10             ` Hiroyuki Kamezawa
2011-06-03 12:35               ` Igor Mammedov
2011-06-03 13:00                 ` Hiroyuki Kamezawa
2011-06-07 13:25                   ` Igor Mammedov
2011-06-08  3:35                     ` KAMEZAWA Hiroyuki
2011-06-08 21:09                       ` Andrew Morton
2011-06-08 23:44                         ` KAMEZAWA Hiroyuki
2011-06-10 16:57                         ` Igor Mammedov
2011-07-26 21:17                           ` Andrew Morton
2011-07-27  7:58                             ` Michal Hocko
2011-07-27  9:30                               ` Igor Mammedov
2011-07-27  9:57                                 ` Michal Hocko
2011-06-09  8:11                       ` Igor Mammedov
2011-06-09 12:40                         ` Possible shadow bug (was: Re: [PATCH] memcg: do not expose uninitialized mem_cgroup_per_node to world) Stefano Stabellini
2011-06-09 15:01                           ` [Xen-devel] " Tim Deegan
2011-06-09 16:47                             ` [Xen-devel] Possible shadow bug Igor Mammedov
2011-06-10 10:01                               ` Tim Deegan
2011-06-10 10:10                                 ` Tim Deegan
2011-06-10 11:48                                   ` Pasi Kärkkäinen
2011-06-10 12:40                                     ` Tim Deegan
2011-06-10 15:38                                       ` Igor Mammedov
2011-06-10 13:55                                   ` Igor Mammedov
2011-06-01 13:49   ` [PATCH] memcg: do not expose uninitialized mem_cgroup_per_node to world Igor Mammedov

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=20110601134149.GD4266@tiehlicka.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=imammedo@redhat.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=menage@google.com \
    /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