Re: [PATCH 3/5] oom: oom-killer don't use proportion of system-ram internally

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

 



On Tue, May 24, 2011 at 10:14 AM, KOSAKI Motohiro
<kosaki.motohiro@xxxxxxxxxxxxxx> wrote:
> 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.
>

Thanks for explanation, KOSAKI.
I need sleeping. :(



-- 
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  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


[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]