lkml.org 
[lkml]   [2011]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/5] oom: oom-killer don't use proportion of system-ram internally
Hi


>> @@ -476,14 +476,17 @@ static const struct file_operations proc_lstats_operations = {
>>
>> static int proc_oom_score(struct task_struct *task, char *buffer)
>> {
>> - unsigned long points = 0;
>> + unsigned long points;
>> + unsigned long ratio = 0;
>> + unsigned long totalpages = totalram_pages + total_swap_pages + 1;
>
> Does we need +1?
> oom_badness does have the check.

"ratio = points * 1000 / totalpages;" need to avoid zero divide.

>> /*
>> * Root processes get 3% bonus, just like the __vm_enough_memory()
>> * implementation used by LSMs.
>> + *
>> + * XXX: Too large bonus, example, if the system have tera-bytes memory..
>> */
>> - if (has_capability_noaudit(p, CAP_SYS_ADMIN))
>> - points -= 30;
>> + if (has_capability_noaudit(p, CAP_SYS_ADMIN)) {
>> + if (points>= totalpages / 32)
>> + points -= totalpages / 32;
>> + else
>> + points = 0;
>
> Odd. Why do we initialize points with 0?
>
> I think the idea is good.

The points is unsigned. It's common technique to avoid underflow.




\
 
 \ /
  Last update: 2011-05-24 03:17    [W:0.100 / U:1.216 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site