linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Greg Thelen <gthelen@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
	Wu Fengguang <fengguang.wu@intel.com>,
	Minchan Kim <minchan.kim@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] memcg: make mem_cgroup_page_stat() return value unsigned
Date: Fri, 19 Nov 2010 12:39:10 +0100	[thread overview]
Message-ID: <20101119113910.GD24635@cmpxchg.org> (raw)
In-Reply-To: <xr937hgixok4.fsf@ninji.mtv.corp.google.com>

On Fri, Nov 12, 2010 at 12:41:15PM -0800, Greg Thelen wrote:
> >> mem_cgroup_page_stat() has changed so it never returns
> >> error so convert the return value to the traditional page
> >> count type (unsigned long).
> >
> > This changelog feels a bit beside the point.
> >
> > What's really interesting is that we now don't consider negative sums
> > to be invalid anymore, but just assume zero!  There is a real
> > semantical change here.
> 
> Prior to this patch series mem_cgroup_page_stat() returned a negative
> value (specifically -EINVAL) to indicate that the current task was in
> the root_cgroup and thus the per-cgroup usage and limit counter were
> invalid.  Callers treated all negative values as an indication of
> root-cgroup message.
> 
> Unfortunately there was another way that mem_cgroup_page_stat() could
> return a negative value even when current was not in the root cgroup.
> Negative sums were a possibility due to summing of unsynchronized
> per-cpu counters.  These occasional negative sums would fool callers
> into thinking that the current task was in the root cgroup.
> 
> Would adding this description to the commit message address your
> concerns?

I'd just describe that summing per-cpu counters is racy, that we can
end up with negative results, and the only sensible handling of that
is to assume zero.

> > That the return type can then be changed to unsigned long is a nice
> > follow-up cleanup that happens to be folded into this patch.
> 
> Good point.  I can separate the change into two sub-patches:
> 1. use zero for a min-value (as described above)
> 2. change return value to unsigned

Sounds good.  You can just fold the previous patch (adjusting the
callsites) into 2, which should take care of the ordering problem.

--
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 policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2010-11-19 11:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-09  9:24 [PATCH 0/6] *** memcg: make throttle_vm_writeout() cgroup aware *** Greg Thelen
2010-11-09  9:24 ` [PATCH 1/6] memcg: add mem_cgroup parameter to mem_cgroup_page_stat() Greg Thelen
2010-11-09 22:53   ` Minchan Kim
2010-11-10  0:51   ` Minchan Kim
2010-11-16  3:50   ` KAMEZAWA Hiroyuki
2010-11-22  6:40   ` Balbir Singh
2010-11-09  9:24 ` [PATCH 2/6] memcg: pass mem_cgroup to mem_cgroup_dirty_info() Greg Thelen
2010-11-09 23:09   ` Minchan Kim
2010-11-16  3:51   ` KAMEZAWA Hiroyuki
2010-11-22  6:41   ` Balbir Singh
2010-11-09  9:24 ` [PATCH 3/6] memcg: make throttle_vm_writeout() memcg aware Greg Thelen
2010-11-09 23:22   ` Minchan Kim
2010-11-12  8:17   ` Johannes Weiner
2010-11-12 20:39     ` Greg Thelen
2010-11-16  3:57       ` KAMEZAWA Hiroyuki
2010-11-19 11:16         ` Johannes Weiner
2010-11-09  9:24 ` [PATCH 4/6] memcg: simplify mem_cgroup_page_stat() Greg Thelen
2010-11-09 23:36   ` Minchan Kim
2010-11-12  8:19   ` Johannes Weiner
2010-11-12 20:40     ` Greg Thelen
2010-11-19 11:22       ` Johannes Weiner
2010-11-16  3:58   ` KAMEZAWA Hiroyuki
2010-11-09  9:24 ` [PATCH 5/6] memcg: simplify mem_cgroup_dirty_info() Greg Thelen
2010-11-10  1:01   ` Minchan Kim
2010-11-12  8:21   ` Johannes Weiner
2010-11-12 20:40     ` Greg Thelen
2010-11-09  9:24 ` [PATCH 6/6] memcg: make mem_cgroup_page_stat() return value unsigned Greg Thelen
2010-11-09 12:15   ` Wu Fengguang
2010-11-10  1:04   ` Minchan Kim
2010-11-12  8:29   ` Johannes Weiner
2010-11-12 20:41     ` Greg Thelen
2010-11-19 11:39       ` Johannes Weiner [this message]
2010-11-16  4:00   ` KAMEZAWA Hiroyuki

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=20101119113910.GD24635@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=fengguang.wu@intel.com \
    --cc=gthelen@google.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /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