lkml.org 
[lkml]   [2010]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 38 of 66] memcontrol: try charging huge pages from stock
    Date
    From
    From: Johannes Weiner <hannes@cmpxchg.org>

    The stock unit is just bytes, there is no reason to only take normal
    pages from it.

    Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
    Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
    ---

    diff --git a/mm/memcontrol.c b/mm/memcontrol.c
    --- a/mm/memcontrol.c
    +++ b/mm/memcontrol.c
    @@ -1658,19 +1658,19 @@ static DEFINE_PER_CPU(struct memcg_stock
    static atomic_t memcg_drain_count;

    /*
    - * Try to consume stocked charge on this cpu. If success, PAGE_SIZE is consumed
    + * Try to consume stocked charge on this cpu. If success, @val 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.
    */
    -static bool consume_stock(struct mem_cgroup *mem)
    +static bool consume_stock(struct mem_cgroup *mem, int val)
    {
    struct memcg_stock_pcp *stock;
    bool ret = true;

    stock = &get_cpu_var(memcg_stock);
    - if (mem == stock->cached && stock->charge)
    - stock->charge -= PAGE_SIZE;
    + if (mem == stock->cached && stock->charge >= val)
    + stock->charge -= val;
    else /* need to call res_counter_charge */
    ret = false;
    put_cpu_var(memcg_stock);
    @@ -1915,7 +1915,7 @@ again:
    VM_BUG_ON(css_is_removed(&mem->css));
    if (mem_cgroup_is_root(mem))
    goto done;
    - if (page_size == PAGE_SIZE && consume_stock(mem))
    + if (consume_stock(mem, page_size))
    goto done;
    css_get(&mem->css);
    } else {
    @@ -1939,7 +1939,7 @@ again:
    rcu_read_unlock();
    goto done;
    }
    - if (page_size == PAGE_SIZE && consume_stock(mem)) {
    + if (consume_stock(mem, page_size)) {
    /*
    * It seems dagerous to access memcg without css_get().
    * But considering how consume_stok works, it's not

    \
     
     \ /
      Last update: 2010-11-03 16:35    [W:2.891 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site