Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1407895
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm |
| Date | 2016-05-27 10:10 +0200 |
| Message-ID | <rDl0e-Ub-15@gated-at.bofh.it> (permalink) |
| References | (3 earlier) <rD5ou-86j-7@gated-at.bofh.it> <rD5y9-89y-1@gated-at.bofh.it> <rD6aR-ac-1@gated-at.bofh.it> <rDjKO-8ri-13@gated-at.bofh.it> <rDkdP-ox-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri 27-05-16 09:15:07, Michal Hocko wrote:
> On Fri 27-05-16 08:45:10, Michal Hocko wrote:
> [...]
> > It is still an operation which is not needed for 99% of situations. So
> > if we do not need it for correctness then I do not think this is worth
> > bothering.
>
> Since you have pointed out exit_mm vs. __exit_signal race yesterday I
> was thinking how to make the check reliable. Even
> atomic_read(mm->mm_users) > get_nr_threads() is not reliable and we can
> miss other tasks just because the current thread group is mostly past
> exit_mm. So far I couldn't find a way to tweak this around though.
Just for the record I was playing with the following yesterday but I
couldn't convince myself that this is safe and reasonable in the first
place (I do not like it to be honest).
---
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 1685890d424e..db027eca8be5 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -123,6 +123,35 @@ struct task_struct *find_lock_task_mm(struct task_struct *p)
return t;
}
+bool task_has_external_users(struct task_struct *p)
+{
+ struct mm_struct *mm = NULL;
+ struct task_struct *t;
+ int active_threads = 0;
+ bool ret = true; /* be pessimistic */
+
+ rcu_read_lock();
+ for_each_thread(p, t) {
+ task_lock(t);
+ if (likely(t->mm)) {
+ active_threads++;
+ if (!mm) {
+ mm = t->mm;
+ atomic_inc(&mm->mm_count);
+ }
+ }
+ task_unlock(t);
+ }
+ rcu_read_unlock();
+
+ if (mm) {
+ if (atomic_read(&mm->mm_users) <= active_threads)
+ ret = false;
+ mmdrop(mm);
+ }
+ return ret;
+}
+
/*
* order == -1 means the oom kill is required by sysrq, otherwise only
* for display purposes.
--
Michal Hocko
SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] Handle oom bypass more gracefully Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
[PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-27 13:20 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-27 18:20 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 09:10 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-30 11:30 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 11:50 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-30 12:50 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 13:20 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-05-30 14:30 +0200
Re: [PATCH 3/6] mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj Michal Hocko <mhocko@kernel.org> - 2016-05-30 14:30 +0200
[PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-26 16:40 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-26 17:00 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are noexternal tasks sharing mm Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-26 17:30 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are noexternal tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-26 17:40 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-26 18:20 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-27 08:50 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-27 09:20 +0200
Re: [PATCH 1/6] mm, oom: do not loop over all tasks if there are no external tasks sharing mm Michal Hocko <mhocko@kernel.org> - 2016-05-27 10:10 +0200
[PATCH 2/6] proc, oom_adj: extract oom_score_adj setting into a helper Michal Hocko <mhocko@kernel.org> - 2016-05-26 14:50 +0200
Re: [PATCH 0/5] Handle oom bypass more gracefully Michal Hocko <mhocko@kernel.org> - 2016-05-27 18:10 +0200
csiph-web