Re: [PATCH V3 2/7] Add per memcg reclaim watermarks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Thu, Apr 14, 2011 at 1:24 AM, Zhu Yanhai <zhu.yanhai@xxxxxxxxx> wrote:
Hi Ying,

2011/4/13 Ying Han <yinghan@xxxxxxxxxx>:
> +static void setup_per_memcg_wmarks(struct mem_cgroup *mem)
> +{
> +       u64 limit;
> +       unsigned long wmark_ratio;
> +
> +       wmark_ratio = get_wmark_ratio(mem);
> +       limit = mem_cgroup_get_limit(mem);

mem_cgroup_get_limit doesn't return the correct limit for you,
actually it's only for OOM killer.
You should use
limit = res_counter_read_u64(&mem->res, RES_LIMIT) directly.
Otherwise in the box which has swapon, you will get a huge
number here.
e.g.
 [root@zyh-fedora a]# echo 500m > memory.limit_in_bytes
[root@zyh-fedora a]# cat memory.limit_in_bytes
524288000
[root@zyh-fedora a]# cat memory.reclaim_wmarks
low_wmark 9114218496
high_wmark 9114218496

thank you~ will fix it next post.

--Ying 

Regards,
Zhu Yanhai


> +       if (wmark_ratio == 0) {
> +               res_counter_set_low_wmark_limit(&mem->res, limit);
> +               res_counter_set_high_wmark_limit(&mem->res, limit);
> +       } else {
> +               unsigned long low_wmark, high_wmark;
> +               unsigned long long tmp = (wmark_ratio * limit) / 100;
> +
> +               low_wmark = tmp;
> +               high_wmark = tmp - (tmp >> 8);
> +               res_counter_set_low_wmark_limit(&mem->res, low_wmark);
> +               res_counter_set_high_wmark_limit(&mem->res, high_wmark);
> +       }
> +}
> +
>  /*
>  * Following LRU functions are allowed to be used without PCG_LOCK.
>  * Operations are called by routine of global LRU independently from memcg.
> @@ -1195,6 +1219,16 @@ static unsigned int get_swappiness(struct mem_cgroup *memcg)
>        return memcg->swappiness;
>  }
>
> +static unsigned long get_wmark_ratio(struct mem_cgroup *memcg)
> +{
> +       struct cgroup *cgrp = memcg->css.cgroup;
> +
> +       VM_BUG_ON(!cgrp);
> +       VM_BUG_ON(!cgrp->parent);
> +
> +       return memcg->wmark_ratio;
> +}
> +
>  static void mem_cgroup_start_move(struct mem_cgroup *mem)
>  {
>        int cpu;
> @@ -3205,6 +3239,7 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
>                        else
>                                memcg->memsw_is_minimum = false;
>                }
> +               setup_per_memcg_wmarks(memcg);
>                mutex_unlock(&set_limit_mutex);
>
>                if (!ret)
> @@ -3264,6 +3299,7 @@ static int mem_cgroup_resize_memsw_limit(struct mem_cgroup *memcg,
>                        else
>                                memcg->memsw_is_minimum = false;
>                }
> +               setup_per_memcg_wmarks(memcg);
>                mutex_unlock(&set_limit_mutex);
>
>                if (!ret)
> @@ -4521,6 +4557,22 @@ static void __init enable_swap_cgroup(void)
>  }
>  #endif
>
> +int mem_cgroup_watermark_ok(struct mem_cgroup *mem,
> +                               int charge_flags)
> +{
> +       long ret = 0;
> +       int flags = CHARGE_WMARK_LOW | CHARGE_WMARK_HIGH;
> +
> +       VM_BUG_ON((charge_flags & flags) == flags);
> +
> +       if (charge_flags & CHARGE_WMARK_LOW)
> +               ret = res_counter_check_under_low_wmark_limit(&mem->res);
> +       if (charge_flags & CHARGE_WMARK_HIGH)
> +               ret = res_counter_check_under_high_wmark_limit(&mem->res);
> +
> +       return ret;
> +}
> +
>  static int mem_cgroup_soft_limit_tree_init(void)
>  {
>        struct mem_cgroup_tree_per_node *rtpn;
> --
> 1.7.3.1
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href="" href="mailto:dont@xxxxxxxxx">dont@xxxxxxxxx"> email@xxxxxxxxx </a>
>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]