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]
Message-Id: <20120229101549.1d4ef3f3.kamezawa.hiroyu@jp.fujitsu.com>
Date:	Wed, 29 Feb 2012 10:15:49 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Fengguang Wu <fengguang.wu@...el.com>,
	Greg Thelen <gthelen@...gle.com>, Jan Kara <jack@...e.cz>,
	Ying Han <yinghan@...gle.com>,
	"hannes@...xchg.org" <hannes@...xchg.org>,
	Rik van Riel <riel@...hat.com>,
	Linux Memory Management List <linux-mm@...ck.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/9] memcg: dirty page accounting support routines

On Tue, 28 Feb 2012 14:45:07 -0800
Andrew Morton <akpm@...ux-foundation.org> wrote:

> On Tue, 28 Feb 2012 22:00:26 +0800
> Fengguang Wu <fengguang.wu@...el.com> wrote:
> 
> > From: Greg Thelen <gthelen@...gle.com>
> > 
> > Added memcg dirty page accounting support routines.  These routines are
> > used by later changes to provide memcg aware writeback and dirty page
> > limiting.  A mem_cgroup_dirty_info() tracepoint is is also included to
> > allow for easier understanding of memcg writeback operation.
> > 
> > ...
> >
> > +/*
> > + * Return the number of additional pages that the @memcg cgroup could allocate.
> > + * If use_hierarchy is set, then this involves checking parent mem cgroups to
> > + * find the cgroup with the smallest free space.
> > + */
> 
> Comment needs revisting - use_hierarchy does not exist.
> 
> > +static unsigned long
> > +mem_cgroup_hierarchical_free_pages(struct mem_cgroup *memcg)
> > +{
> > +	u64 free;
> > +	unsigned long min_free;
> > +
> > +	min_free = global_page_state(NR_FREE_PAGES);
> > +
> > +	while (memcg) {
> > +		free = mem_cgroup_margin(memcg);
> > +		min_free = min_t(u64, min_free, free);
> > +		memcg = parent_mem_cgroup(memcg);
> > +	}
> > +
> > +	return min_free;
> > +}
> > +
> > +/*
> > + * mem_cgroup_page_stat() - get memory cgroup file cache statistics
> > + * @memcg:     memory cgroup to query
> > + * @item:      memory statistic item exported to the kernel
> > + *
> > + * Return the accounted statistic value.
> > + */
> > +unsigned long mem_cgroup_page_stat(struct mem_cgroup *memcg,
> > +				   enum mem_cgroup_page_stat_item item)
> > +{
> > +	struct mem_cgroup *iter;
> > +	s64 value;
> > +
> > +	/*
> > +	 * If we're looking for dirtyable pages we need to evaluate free pages
> > +	 * depending on the limit and usage of the parents first of all.
> > +	 */
> > +	if (item == MEMCG_NR_DIRTYABLE_PAGES)
> > +		value = mem_cgroup_hierarchical_free_pages(memcg);
> > +	else
> > +		value = 0;
> > +
> > +	/*
> > +	 * Recursively evaluate page statistics against all cgroup under
> > +	 * hierarchy tree
> > +	 */
> > +	for_each_mem_cgroup_tree(iter, memcg)
> > +		value += mem_cgroup_local_page_stat(iter, item);
> 
> What's the locking rule for for_each_mem_cgroup_tree()?  It's unobvious
> from the code and isn't documented?
> 

Because for_each_mem_cgroup_tree() uses rcu_read_lock() and referernce counting
internally, it's not required to take any lock in callers.
One rule is the caller shoud call mem_cgroup_iter_break() if he want to break
the loop.

Thanks,
-Kame






--
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