[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACnwZYcUEmEStT7uwN3O3=m34uLi9YnJSYWFPZafuzCy_t4uaw@mail.gmail.com>
Date: Mon, 12 Nov 2012 20:14:40 -0200
From: Thiago Farina <tfransosi@...il.com>
To: Michal Hocko <mhocko@...e.cz>
Cc: David Rientjes <rientjes@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Anton Vorontsov <anton.vorontsov@...aro.org>,
Oleg Nesterov <oleg@...hat.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [patch 2/2] mm, oom: fix race when specifying a thread as the oom origin
On Thu, Nov 8, 2012 at 1:51 PM, Michal Hocko <mhocko@...e.cz> wrote:
> On Thu 08-11-12 01:27:00, David Rientjes wrote:
>> test_set_oom_score_adj() and compare_swap_oom_score_adj() are used to
>> specify that current should be killed first if an oom condition occurs in
>> between the two calls.
>>
>> The usage is
>>
>> short oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX);
>> ...
>> compare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX, oom_score_adj);
>>
>> to store the thread's oom_score_adj, temporarily change it to the maximum
>> score possible, and then restore the old value if it is still the same.
>>
>> This happens to still be racy, however, if the user writes
>> OOM_SCORE_ADJ_MAX to /proc/pid/oom_score_adj in between the two calls.
>> The compare_swap_oom_score_adj() will then incorrectly reset the old
>> value prior to the write of OOM_SCORE_ADJ_MAX.
>>
>> To fix this, introduce a new oom_flags_t member in struct signal_struct
>> that will be used for per-thread oom killer flags. KSM and swapoff can
>> now use a bit in this member to specify that threads should be killed
>> first in oom conditions without playing around with oom_score_adj.
>>
>> This also allows the correct oom_score_adj to always be shown when
>> reading /proc/pid/oom_score.
>>
>> Signed-off-by: David Rientjes <rientjes@...gle.com>
>
> I didn't like the previous playing with the oom_score_adj and what you
> propose looks much nicer.
> Maybe s/oom_task_origin/task_oom_origin/ would be a better fit
May be s/oom_task_origin/is_task_origin_oom? Just my 2 cents.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists