Re: [resend][PATCH 4/4] oom: don't ignore rss in nascent mm

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: pageexec
Date: Monday, October 25, 2010 - 4:28 am

On 25 Oct 2010 at 12:29, KOSAKI Motohiro wrote:

hi,

i've got a few comments/questions about the whole approach, see them inline.


what happens when two (or more) threads in the same process call execve? the
above set_exec_mm calls will race (de_thread doesn't happen until much later
in execve) and overwrite each other's ->in_exec_mm which will still lead to
problems since there will be at most one temporary mm accounted for in the
oom killer.

[update: since i don't seem to have been cc'd on the other patch that
serializes execve, the above point is moot ;)]

worse, even if each temporary mm was tracked separately there'd still be a
race where the oom killer can get triggered with the culprit thread long
gone (and reset ->in_exec_mm) and never to be found, so the oom killer would
find someone else as guilty.

now all this leads me to suggest a simpler solution, at least for the first
problem mentioned above (i don't know what to do with the second one yet as
it seems to be a generic issue with the oom killer, probably it should verify
the oom situation once again after it took the task_list lock).

[update: while the serialized execve solves the first problem, i still think
that my idea is simpler and worth considering, so i leave it here even if for
just documentation purposes ;)]

given that all the oom killer needs from the mm struct is either ->total_pages
(in .35 and before, so be careful with the stable backport) or some ->rss_stat
counters, wouldn't it be much easier to simply transfer the bprm->mm counters
into current->mm for the duration of the execve (say, add them in get_arg_page
and remove them when bprm->mm is mmput in the do_execve failure path, etc)? the
transfer can be either to the existing counters or to new ones (obviously in
the latter case the oom code needs a small change to take the new counters into
account as well).

cheers,

 PaX Team

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[resend][PATCH 4/4] oom: don't ignore rss in nascent mm, KOSAKI Motohiro, (Sun Oct 24, 8:29 pm)
Re: [resend][PATCH 4/4] oom: don't ignore rss in nascent mm, pageexec, (Mon Oct 25, 4:28 am)
Re: [resend][PATCH 4/4] oom: don't ignore rss in nascent mm, KOSAKI Motohiro, (Tue Oct 26, 12:25 am)
[patch] oom: document obsolete oom_adj tunable, David Rientjes, (Tue Nov 9, 4:55 pm)
Re: [patch] oom: document obsolete oom_adj tunable, KOSAKI Motohiro, (Sun Nov 14, 5:22 pm)
Re: [patch] oom: document obsolete oom_adj tunable, David Rientjes, (Mon Nov 15, 3:38 am)
Re: [patch] oom: document obsolete oom_adj tunable, KOSAKI Motohiro, (Tue Nov 23, 12:16 am)
Re: [resend][PATCH 4/4] oom: don't ignore rss in nascent mm, KOSAKI Motohiro, (Tue Nov 23, 5:24 pm)
Re: [resend][PATCH 4/4] oom: don't ignore rss in nascent mm, KOSAKI Motohiro, (Thu Nov 25, 4:06 am)
Re: [resend][PATCH 4/4] oom: don't ignore rss in nascent mm, KOSAKI Motohiro, (Sun Nov 28, 10:25 pm)
Re: [resend][PATCH 4/4] oom: don't ignore rss in nascent mm, KOSAKI Motohiro, (Mon Nov 29, 5:06 pm)
[PATCH 0/4] exec: unify compat/non-compat code, Oleg Nesterov, (Tue Nov 30, 1:00 pm)
[PATCH 1/4] exec: introduce get_arg_ptr() helper, Oleg Nesterov, (Tue Nov 30, 1:00 pm)
[PATCH 3/4] exec: unify compat_do_execve() code, Oleg Nesterov, (Tue Nov 30, 1:01 pm)
Re: [PATCH 0/4] exec: unify compat/non-compat code, KOSAKI Motohiro, (Tue Nov 30, 8:09 pm)
(No subject header), Milton Miller, (Wed Dec 1, 10:37 am)
Re: (No subject header), Oleg Nesterov, (Wed Dec 1, 11:27 am)