[Devel] Re: Re: [RFC][PATCH] memory controller per zone patches take 2 [4/10] calculate mapped ratio for memory cgroup

kamezawa.hiroyu at jp.fujitsu.com kamezawa.hiroyu at jp.fujitsu.com
Thu Nov 22 05:31:10 PST 2007


>> Ah, This is what I do now.
>> ==
>> +/*
>> + * Calculate mapped_ratio under memory controller. This will be used in
>> + * vmscan.c for deteremining we have to reclaim mapped pages.
>> + */
>> +int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem)
>> +{
>> +       long total, rss;
>> +
>> +       /*
>> +        * usage is recorded in bytes. But, here, we assume the number of
>> +        * physical pages can be represented by "long" on any arch.
>> +        */
>> +       total = (long) (mem->res.usage >> PAGE_SHIFT);
>> +       rss = (long)mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
>> +       return (int)((rss * 100L) / total);
>> +}
>> ==
>> 
>> maybe works well.
>> 
>> -Kame
>
>i meant that "/ total" can cause a division-by-zero exception.
>
ouch, ok, will fix.

-Kame

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list