linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: Pavel Emelyanov <xemul@openvz.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Paul Menage <menage@google.com>,
	Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
	Linux Containers <containers@lists.osdl.org>,
	Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH 1/2] Add the max_usage member on the res_counter
Date: Sat, 08 Mar 2008 11:09:14 +0530	[thread overview]
Message-ID: <47D22682.6060108@linux.vnet.ibm.com> (raw)
In-Reply-To: <47D15FAF.3000204@openvz.org>

Pavel Emelyanov wrote:
> This is a very usefull feature. E.g. one may set the
> limit to "unlimited" value and check for the memory
> requirements of a new container.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
> 
> ---
>  include/linux/res_counter.h |    5 +++++
>  kernel/res_counter.c        |    4 ++++
>  mm/memcontrol.c             |    5 +++++
>  3 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
> index 8cb1ecd..2c4deb5 100644
> --- a/include/linux/res_counter.h
> +++ b/include/linux/res_counter.h
> @@ -25,6 +25,10 @@ struct res_counter {
>  	 */
>  	unsigned long long usage;
>  	/*
> +	 * the maximal value of the usage from the counter creation
> +	 */
> +	unsigned long long max_usage;
> +	/*
>  	 * the limit that usage cannot exceed
>  	 */
>  	unsigned long long limit;
> @@ -67,6 +71,7 @@ ssize_t res_counter_write(struct res_counter *counter, int member,
> 
>  enum {
>  	RES_USAGE,
> +	RES_MAX_USAGE,
>  	RES_LIMIT,
>  	RES_FAILCNT,
>  };
> diff --git a/kernel/res_counter.c b/kernel/res_counter.c
> index 791ff2b..f1f20c2 100644
> --- a/kernel/res_counter.c
> +++ b/kernel/res_counter.c
> @@ -27,6 +27,8 @@ int res_counter_charge_locked(struct res_counter *counter, unsigned long val)
>  	}
> 
>  	counter->usage += val;
> +	if (counter->usage > counter->max_usage)
> +		counter->max_usage = counter->usage;

How about

	counter->max_usage = max(counter->usage, counter->max_usage);

>  	return 0;
>  }
> 
> @@ -65,6 +67,8 @@ res_counter_member(struct res_counter *counter, int member)
>  	switch (member) {
>  	case RES_USAGE:
>  		return &counter->usage;
> +	case RES_MAX_USAGE:
> +		return &counter->max_usage;
>  	case RES_LIMIT:
>  		return &counter->limit;
>  	case RES_FAILCNT:
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 2d59163..e5c741a 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -911,6 +911,11 @@ static struct cftype mem_cgroup_files[] = {
>  		.read_u64 = mem_cgroup_read,
>  	},
>  	{
> +		.name = "max_usage_in_bytes",
> +		.private = RES_MAX_USAGE,
> +		.read_u64 = mem_cgroup_read,
> +	},
> +	{
>  		.name = "limit_in_bytes",
>  		.private = RES_LIMIT,
>  		.write = mem_cgroup_write,

Looks very good,

Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>

-- 
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL

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

      parent reply	other threads:[~2008-03-08  5:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-07 15:30 [PATCH 1/2] Add the max_usage member on the res_counter Pavel Emelyanov
2008-03-08  4:33 ` KAMEZAWA Hiroyuki
2008-03-11  8:41   ` Pavel Emelyanov
2008-03-08  5:39 ` Balbir Singh [this message]

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=47D22682.6060108@linux.vnet.ibm.com \
    --to=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.osdl.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=menage@google.com \
    --cc=nishimura@mxp.nes.nec.co.jp \
    --cc=xemul@openvz.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;
as well as URLs for NNTP newsgroup(s).