Home » Mailing lists » Devel » [PATCH v5 00/14] kmem controller for memcg.
[PATCH v5 01/14] memcg: Make it possible to use the stock for more than one page. [message #48395 is a reply to message #48393] |
Tue, 16 October 2012 10:16 |
Glauber Costa
Messages: 916 Registered: October 2011
|
Senior Member |
|
|
From: Suleiman Souhlal <ssouhlal@FreeBSD.org>
We currently have a percpu stock cache scheme that charges one page at a
time from memcg->res, the user counter. When the kernel memory
controller comes into play, we'll need to charge more than that.
This is because kernel memory allocations will also draw from the user
counter, and can be bigger than a single page, as it is the case with
the stack (usually 2 pages) or some higher order slabs.
[ glommer@parallels.com: added a changelog ]
Signed-off-by: Suleiman Souhlal <suleiman@google.com>
Signed-off-by: Glauber Costa <glommer@parallels.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
CC: Tejun Heo <tj@kernel.org>
---
mm/memcontrol.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7acf43b..47cb019 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2028,20 +2028,28 @@ struct memcg_stock_pcp {
static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock);
static DEFINE_MUTEX(percpu_charge_mutex);
-/*
- * Try to consume stocked charge on this cpu. If success, one page is consumed
- * from local stock and true is returned. If the stock is 0 or charges from a
- * cgroup which is not current target, returns false. This stock will be
- * refilled.
+/**
+ * consume_stock: Try to consume stocked charge on this cpu.
+ * @memcg: memcg to consume from.
+ * @nr_pages: how many pages to charge.
+ *
+ * The charges will only happen if @memcg matches the current cpu's memcg
+ * stock, and at least @nr_pages are available in that stock. Failure to
+ * service an allocation will refill the stock.
+ *
+ * returns true if succesfull, false otherwise.
*/
-static bool consume_stock(struct mem_cgroup *memcg)
+static bool consume_stock(struct mem_cgroup *memcg, int nr_pages)
{
struct memcg_stock_pcp *stock;
bool ret = true;
+ if (nr_pages > CHARGE_BATCH)
+ return false;
+
stock = &get_cpu_var(memcg_stock);
- if (memcg == stock->cached && stock->nr_pages)
- stock->nr_pages--;
+ if (memcg == stock->cached && stock->nr_pages >= nr_pages)
+ stock->nr_pages -= nr_pages;
else /* need to call res_counter_charge */
ret = false;
put_cpu_var(memcg_stock);
@@ -2340,7 +2348,7 @@ again:
VM_BUG_ON(css_is_removed(&memcg->css));
if (mem_cgroup_is_root(memcg))
goto done;
- if (nr_pages == 1 && consume_stock(memcg))
+ if (consume_stock(memcg, nr_pages))
goto done;
css_get(&memcg->css);
} else {
@@ -2365,7 +2373,7 @@ again:
rcu_read_unlock();
goto done;
}
- if (nr_pages == 1 && consume_stock(memcg)) {
+ if (consume_stock(memcg, nr_pages)) {
/*
* It seems dagerous to access memcg without css_get().
* But considering how consume_stok works, it's not
--
1.7.11.7
|
|
|
|
|
[PATCH v5 00/14] kmem controller for memcg.
|
|
|
[PATCH v5 03/14] memcg: change defines to an enum
|
|
|
Re: [PATCH v5 03/14] memcg: change defines to an enum
|
|
|
[PATCH v5 01/14] memcg: Make it possible to use the stock for more than one page.
|
|
|
Re: [PATCH v5 01/14] memcg: Make it possible to use the stock for more than one page.
By: akpm on Wed, 17 October 2012 22:11
|
|
|
Re: [PATCH v5 01/14] memcg: Make it possible to use the stock for more than one page.
|
|
|
[PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 04/14] kmem accounting basic infrastructure
|
|
|
[PATCH v5 11/14] memcg: allow a memcg with kmem charges to be destructed.
|
|
|
Re: [PATCH v5 11/14] memcg: allow a memcg with kmem charges to be destructed.
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 11/14] memcg: allow a memcg with kmem charges to be destructed.
|
|
|
[PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
Re: [PATCH v5 06/14] memcg: kmem controller infrastructure
|
|
|
[PATCH v5 05/14] Add a __GFP_KMEMCG flag
|
|
|
Re: [PATCH v5 05/14] Add a __GFP_KMEMCG flag
|
|
|
Re: [PATCH v5 05/14] Add a __GFP_KMEMCG flag
|
|
|
[PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
Re: [PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
Re: [PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
Re: [PATCH v5 09/14] memcg: kmem accounting lifecycle management
|
|
|
[PATCH v5 10/14] memcg: use static branches when code not in use
|
|
|
[PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 14/14] Add documentation about the kmem controller
|
|
|
[PATCH v5 13/14] protect architectures where THREAD_SIZE >= PAGE_SIZE against fork bombs
|
|
|
Re: [PATCH v5 13/14] protect architectures where THREAD_SIZE >= PAGE_SIZE against fork bombs
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 13/14] protect architectures where THREAD_SIZE >= PAGE_SIZE against fork bombs
|
|
|
[PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
By: akpm on Wed, 17 October 2012 22:12
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
By: akpm on Thu, 18 October 2012 20:44
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 07/14] mm: Allocate kernel pages to the right memcg
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
By: akpm on Wed, 17 October 2012 22:11
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
By: akpm on Thu, 18 October 2012 19:21
|
|
|
Re: [PATCH v5 00/14] kmem controller for memcg.
|
Goto Forum:
Current Time: Mon May 20 04:03:31 GMT 2024
Total time taken to generate the page: 0.00490 seconds
|