* [PATCH 1/2] Add the max_usage member on the res_counter
@ 2008-03-07 15:30 Pavel Emelyanov
[not found] ` <47D15FAF.3000204-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Emelyanov @ 2008-03-07 15:30 UTC (permalink / raw)
To: Balbir Singh, KAMEZAWA Hiroyuki, Paul Menage; +Cc: Linux Containers, Linux MM
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-GEFAQzZX7r8dnm+yROfE0A@public.gmane.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;
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,
--
1.5.3.4
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <47D15FAF.3000204-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 1/2] Add the max_usage member on the res_counter [not found] ` <47D15FAF.3000204-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> @ 2008-03-08 4:33 ` KAMEZAWA Hiroyuki [not found] ` <20080308133307.a2e02402.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org> 2008-03-08 5:39 ` Balbir Singh 1 sibling, 1 reply; 4+ messages in thread From: KAMEZAWA Hiroyuki @ 2008-03-08 4:33 UTC (permalink / raw) To: Pavel Emelyanov Cc: Linux MM, Linux-FOgKQjlUJ6BQetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Containers, Paul Menage, Balbir Singh On Fri, 07 Mar 2008 18:30:55 +0300 Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> 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. > Hm, I like this. Could you add a method to reset this counter ? Thanks, -Kame > Signed-off-by: Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.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; > 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, > -- > 1.5.3.4 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo-Bw31MaZKKs0EbZ0PF+XxCw@public.gmane.org For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: <a href=mailto:"dont-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org"> email-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20080308133307.a2e02402.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>]
* Re: [PATCH 1/2] Add the max_usage member on the res_counter [not found] ` <20080308133307.a2e02402.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org> @ 2008-03-11 8:41 ` Pavel Emelyanov 0 siblings, 0 replies; 4+ messages in thread From: Pavel Emelyanov @ 2008-03-11 8:41 UTC (permalink / raw) To: KAMEZAWA Hiroyuki, Balbir Singh; +Cc: Linux Containers, Linux MM, Paul Menage KAMEZAWA Hiroyuki wrote: > On Fri, 07 Mar 2008 18:30:55 +0300 > Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> 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. >> > Hm, I like this. Could you add a method to reset this counter ? OK. Sounds reasonable. > How about > > counter->max_usage = max(counter->usage, counter->max_usage); No, I prefer explicit checks :) > Looks very good, > > Acked-by: Balbir Singh <balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> OK. I'll push this change the the git at openvz.org then. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Add the max_usage member on the res_counter [not found] ` <47D15FAF.3000204-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org> 2008-03-08 4:33 ` KAMEZAWA Hiroyuki @ 2008-03-08 5:39 ` Balbir Singh 1 sibling, 0 replies; 4+ messages in thread From: Balbir Singh @ 2008-03-08 5:39 UTC (permalink / raw) To: Pavel Emelyanov; +Cc: Linux Containers, Linux MM, Paul Menage 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-GEFAQzZX7r8dnm+yROfE0A@public.gmane.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-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org> -- Warm Regards, Balbir Singh Linux Technology Center IBM, ISTL ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-03-11 8:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-07 15:30 [PATCH 1/2] Add the max_usage member on the res_counter Pavel Emelyanov
[not found] ` <47D15FAF.3000204-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2008-03-08 4:33 ` KAMEZAWA Hiroyuki
[not found] ` <20080308133307.a2e02402.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-03-11 8:41 ` Pavel Emelyanov
2008-03-08 5:39 ` Balbir Singh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox