login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
June
»
20
Re: [PATCH 2/2] memcg: reduce usage at change limit
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Paul Menage
Subject:
Re: [PATCH 2/2] memcg: reduce usage at change limit
Date: Thursday, June 19, 2008 - 10:16 pm
On Mon, Jun 16, 2008 at 8:36 PM, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
quoted text
> Reduce the usage of res_counter at the change of limit. > > Changelog v4 -> v5. > - moved "feedback" alogrithm from res_counter to memcg.
FWIW, I really thought it was much better having it in the generic res_counter. Paul
quoted text
> > Background: > - Now, mem->usage is not reduced at limit change. So, the users will see > usage > limit case in memcg every time. This patch fixes it. > > Before: > - no usage change at setting limit. > - setting limit always returns 0 even if usage can never be less than zero. > (This can happen when memory is locked or there is no swap.) > - This is BUG, I think. > After: > - usage will be less than new limit at limit change. > - set limit returns -EBUSY when the usage cannot be reduced. > > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > --- > Documentation/controllers/memory.txt | 3 - > mm/memcontrol.c | 68 ++++++++++++++++++++++++++++------- > 2 files changed, 56 insertions(+), 15 deletions(-) > > Index: mm-2.6.26-rc5-mm3/mm/memcontrol.c > =================================================================== > --- mm-2.6.26-rc5-mm3.orig/mm/memcontrol.c > +++ mm-2.6.26-rc5-mm3/mm/memcontrol.c > @@ -852,18 +852,30 @@ out: > css_put(&mem->css); > return ret; > } > +/* > + * try to set limit and reduce usage if necessary. > + * returns 0 at success. > + * returns -EBUSY if memory cannot be dropped. > + */ > > -static int mem_cgroup_write_strategy(char *buf, unsigned long long *tmp) > +static inline int mem_cgroup_resize_limit(struct cgroup *cont, > + unsigned long long val) > { > - *tmp = memparse(buf, &buf); > - if (*buf != '__PLACEHOLDER__1_') > - return -EINVAL; > + struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); > + int retry_count = 0; > + int progress; > > - /* > - * Round up the value to the closest page size > - */ > - *tmp = ((*tmp + PAGE_SIZE - 1) >> PAGE_SHIFT) << PAGE_SHIFT; > - return 0; > +retry: > + if (!res_counter_set_limit(&memcg->res, val)) > + return 0; > + if (retry_count == MEM_CGROUP_RECLAIM_RETRIES) > + return -EBUSY; > + > + cond_resched(); > + progress = try_to_free_mem_cgroup_pages(memcg, GFP_KERNEL); > + if (!progress) > + retry_count++; > + goto retry; > } > > static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft) > @@ -874,11 +886,41 @@ static u64 mem_cgroup_read(struct cgroup > > static ssize_t mem_cgroup_write(struct cgroup *cont, struct cftype *cft, > struct file *file, const char __user *userbuf, > - size_t nbytes, loff_t *ppos) > + size_t bbytes, loff_t *ppos) > { > - return res_counter_write(&mem_cgroup_from_cont(cont)->res, > - cft->private, userbuf, nbytes, ppos, > - mem_cgroup_write_strategy); > + char *buf, *end; > + unsigned long long val; > + int ret; > + > + buf = kmalloc(bbytes + 1, GFP_KERNEL); > + if (!buf) > + return -ENOMEM; > + buf[bbytes] = '__PLACEHOLDER__1_'; > + ret = -EFAULT; > + if (copy_from_user(buf, userbuf, bbytes)) > + goto out; > + > + ret = -EINVAL; > + strstrip(buf); > + val = memparse(buf, &end); > + if (*end != '__PLACEHOLDER__1_') > + goto out; > + /* Round to page size */ > + val = ((val + PAGE_SIZE - 1) >> PAGE_SHIFT) << PAGE_SHIFT; > + > + switch(cft->private) { > + case RES_LIMIT: > + ret = mem_cgroup_resize_limit(cont, val); > + break; > + default: > + ret = -EINVAL; > + goto out; > + } > + if (!ret) > + ret = bbytes; > +out: > + kfree(buf); > + return ret; > } > > static int mem_cgroup_reset(struct cgroup *cont, unsigned int event) > Index: mm-2.6.26-rc5-mm3/Documentation/controllers/memory.txt > =================================================================== > --- mm-2.6.26-rc5-mm3.orig/Documentation/controllers/memory.txt > +++ mm-2.6.26-rc5-mm3/Documentation/controllers/memory.txt > @@ -242,8 +242,7 @@ rmdir() if there are no tasks. > 1. Add support for accounting huge pages (as a separate controller) > 2. Make per-cgroup scanner reclaim not-shared pages first > 3. Teach controller to account for shared-pages > -4. Start reclamation when the limit is lowered > -5. Start reclamation in the background when the limit is > +4. Start reclamation in the background when the limit is > not yet hit but the usage is getting closer > > Summary > >
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 0/2] memcg: Reduce usage at change limit
, KAMEZAWA Hiroyuki
, (Mon Jun 16, 8:31 pm)
[PATCH 1/2] memcg: res counter set limit
, KAMEZAWA Hiroyuki
, (Mon Jun 16, 8:33 pm)
[PATCH 2/2] memcg: reduce usage at change limit
, KAMEZAWA Hiroyuki
, (Mon Jun 16, 8:36 pm)
Re: [PATCH 1/2] memcg: res counter set limit
, Balbir Singh
, (Mon Jun 16, 8:40 pm)
Re: [PATCH 2/2] memcg: reduce usage at change limit
, Balbir Singh
, (Mon Jun 16, 8:46 pm)
Re: [PATCH 1/2] memcg: res counter set limit
, KAMEZAWA Hiroyuki
, (Mon Jun 16, 9:05 pm)
Re: [PATCH 2/2] memcg: reduce usage at change limit
, KAMEZAWA Hiroyuki
, (Mon Jun 16, 9:06 pm)
Re: [PATCH 2/2] memcg: reduce usage at change limit
, KAMEZAWA Hiroyuki
, (Tue Jun 17, 3:00 am)
Re: [PATCH 2/2] memcg: reduce usage at change limit
, Balbir Singh
, (Tue Jun 17, 3:14 am)
Re: Re: [PATCH 2/2] memcg: reduce usage at change limit
, kamezawa.hiroyu
, (Tue Jun 17, 5:03 am)
Re: [PATCH 2/2] memcg: reduce usage at change limit
, Paul Menage
, (Thu Jun 19, 10:16 pm)
Re: Re: [PATCH 2/2] memcg: reduce usage at change limit
, kamezawa.hiroyu
, (Thu Jun 19, 11:44 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Trent Waddington
Re: Gaming Interface
Takashi Iwai
Re: [PATCH] usb: usbmixer error path fix
Pekka Enberg
Re: latest -git: suspend: unable to handle kernel paging request (was Re: no_conso...
Dan Carpenter
Re: [patch] dma-debug: off by one issue
Jeremy Fitzhardinge
Re: [patch 1/6] Re-enable VDSO by default with PARAVIRT
git
:
Stephen R. van den Berg
Re: [RFC] origin link for cherry-pick and revert
Christian Stimming
git-gui: Fix broken revert confirmation.
Junio C Hamano
Re: git-svnimport
Mark Burton
Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk
Johannes Schindelin
Re: [PATCH] Fix approxidate("never") to always return 0
linux-netdev
:
Nick Piggin
Re: Kernel WARNING: at net/core/dev.c:1330 __netif_schedule+0x2c/0x98()
Daniel Lezcano
getsockopt(TCP_DEFER_ACCEPT) value change
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Ingo Molnar
Re: [regression] nf_iterate(), BUG: unable to handle kernel NULL pointer dereference
Gerrit Renker
[PATCH 37/37] dccp: Debugging functions for feature negotiation
openbsd-misc
:
Christophe Rioux
Implementation example of snmp
Ryan McBride
Re: Packets Per Second Limit?
Nick Holland
Re: booting openbsd on eee without cd-rom
Marco Peereboom
Re: Singularity OS
Otto Moerbeek
Re: Solved: cron - setusercontext failed for root
git-commits-head
:
Linux Kernel Mailing List
ath9k_htc: Allocate URBs properly
Linux Kernel Mailing List
bnx2x: Fan failure mechanism on additional design
Linux Kernel Mailing List
cpumask: make irq_set_affinity() take a const struct cpumask
Linux Kernel Mailing List
ARM: 5670/1: bcmring: add default configuration for bcmring arch
Linux Kernel Mailing List
ahci: Workaround HW bug for SB600/700 SATA controller PMP support
Colocation donated by:
Syndicate