lkml.org 
[lkml]   [2009]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[RFC][PATCH 4/5] memcg softlimit_priority
    From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

    An iterface to set/read softlimit priority of cgroup.

    Changelog: v2->v3
    - removed complicated handling of hierarchy.
    i.e. Changes in priority doesn't affect children.

    Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    ---
    mm/memcontrol.c | 31 +++++++++++++++++++++++++++++--
    1 file changed, 29 insertions(+), 2 deletions(-)

    Index: mmotm-2.6.29-Mar10/mm/memcontrol.c
    ===================================================================
    --- mmotm-2.6.29-Mar10.orig/mm/memcontrol.c
    +++ mmotm-2.6.29-Mar10/mm/memcontrol.c
    @@ -217,6 +217,8 @@ pcg_default_flags[NR_CHARGE_TYPE] = {
    #define MEMFILE_TYPE(val) (((val) >> 16) & 0xffff)
    #define MEMFILE_ATTR(val) ((val) & 0xffff)

    +#define MEM_SOFTLIMIT_PRIO (0x10)
    +
    static void mem_cgroup_get(struct mem_cgroup *mem);
    static void mem_cgroup_put(struct mem_cgroup *mem);
    static struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem);
    @@ -2187,7 +2189,14 @@ static u64 mem_cgroup_read(struct cgroup
    name = MEMFILE_ATTR(cft->private);
    switch (type) {
    case _MEM:
    - val = res_counter_read_u64(&mem->res, name);
    + switch (name) {
    + case MEM_SOFTLIMIT_PRIO:
    + val = mem->softlimit_priority;
    + break;
    + default:
    + val = res_counter_read_u64(&mem->res, name);
    + break;
    + }
    break;
    case _MEMSWAP:
    if (do_swap_account)
    @@ -2290,6 +2299,18 @@ static int mem_cgroup_reset(struct cgrou
    return 0;
    }

    +static int mem_cgroup_write_softlimit_priority(struct cgroup *cgrp,
    + struct cftype *cft,
    + u64 val)
    +{
    + struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
    + int priority = (int)val;
    +
    + if ((priority < 0) || (priority > SOFTLIMIT_MAXPRI))
    + return -EINVAL;
    + memcg_softlimit_requeue(memcg, priority);
    + return 0;
    +}

    /* For read statistics */
    enum {
    @@ -2485,6 +2506,12 @@ static struct cftype mem_cgroup_files[]
    .read_u64 = mem_cgroup_read,
    },
    {
    + .name = "softlimit_priority",
    + .private = MEMFILE_PRIVATE(_MEM, MEM_SOFTLIMIT_PRIO),
    + .write_u64 = mem_cgroup_write_softlimit_priority,
    + .read_u64 = mem_cgroup_read,
    + },
    + {
    .name = "failcnt",
    .private = MEMFILE_PRIVATE(_MEM, RES_FAILCNT),
    .trigger = mem_cgroup_reset,
    @@ -2711,8 +2738,8 @@ mem_cgroup_create(struct cgroup_subsys *
    res_counter_init(&mem->res, NULL);
    res_counter_init(&mem->memsw, NULL);
    }
    - mem->last_scanned_child = 0;
    mem->softlimit_priority = SOFTLIMIT_MAXPRI;
    + mem->last_scanned_child = 0;
    mutex_init(&mem->softlimit_mutex);
    spin_lock_init(&mem->reclaim_param_lock);



    \
     
     \ /
      Last update: 2009-03-12 02:03    [W:0.023 / U:60.080 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site