linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups
@ 2014-04-28 15:19 Oleg Nesterov
  2014-04-28 15:19 ` [PATCH RESEND 1/3] memcg: mm_update_next_owner() should skip kthreads Oleg Nesterov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Oleg Nesterov @ 2014-04-28 15:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Balbir Singh, Johannes Weiner, KAMEZAWA Hiroyuki, Michal Hocko,
	Peter Chiang, linux-kernel

Andrew,

You applied the last (4th) memcg-kill-config_mm_owner.patch, but other
patches in this thread were ignored. Hopefully thi is because I sent
them chaotically.

Let me resend 1-3 in case you missed them. Acked by Michal.

Oleg.

 init/main.c   |    1 -
 kernel/exit.c |   18 +++++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH RESEND 1/3] memcg: mm_update_next_owner() should skip kthreads
  2014-04-28 15:19 [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Oleg Nesterov
@ 2014-04-28 15:19 ` Oleg Nesterov
  2014-04-28 15:19 ` [PATCH RESEND 2/3] memcg: optimize the "Search everything else" loop in mm_update_next_owner() Oleg Nesterov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Oleg Nesterov @ 2014-04-28 15:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Balbir Singh, Johannes Weiner, KAMEZAWA Hiroyuki, Michal Hocko,
	Peter Chiang, linux-kernel

"Search through everything else" in mm_update_next_owner() can
hit a kthread which adopted this "mm" via use_mm(), it should
not be used as mm->owner. Add the PF_KTHREAD check.

While at it, change this code to use for_each_process_thread()
instead of deprecated do_each_thread/while_each_thread.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
---
 kernel/exit.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index ad7183a..e270d2a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -356,14 +356,12 @@ retry:
 	}
 
 	/*
-	 * Search through everything else. We should not get
-	 * here often
+	 * Search through everything else, we should not get here often.
 	 */
-	do_each_thread(g, c) {
-		if (c->mm == mm)
+	for_each_process_thread(g, c) {
+		if (!(c->flags & PF_KTHREAD) && c->mm == mm)
 			goto assign_new_owner;
-	} while_each_thread(g, c);
-
+	}
 	read_unlock(&tasklist_lock);
 	/*
 	 * We found no owner yet mm_users > 1: this implies that we are
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH RESEND 2/3] memcg: optimize the "Search everything else" loop in mm_update_next_owner()
  2014-04-28 15:19 [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Oleg Nesterov
  2014-04-28 15:19 ` [PATCH RESEND 1/3] memcg: mm_update_next_owner() should skip kthreads Oleg Nesterov
@ 2014-04-28 15:19 ` Oleg Nesterov
  2014-04-28 15:19 ` [PATCH RESEND 3/3] memcg: kill start_kernel()->mm_init_owner(&init_mm) Oleg Nesterov
  2014-04-29 12:15 ` [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Michal Hocko
  3 siblings, 0 replies; 5+ messages in thread
From: Oleg Nesterov @ 2014-04-28 15:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Balbir Singh, Johannes Weiner, KAMEZAWA Hiroyuki, Michal Hocko,
	Peter Chiang, linux-kernel

for_each_process_thread() is sub-optimal. All threads share the same
->mm, we can swicth to the next process once we found a thread with
->mm != NULL and ->mm != mm.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
---
 kernel/exit.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index e270d2a..429659c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -358,9 +358,15 @@ retry:
 	/*
 	 * Search through everything else, we should not get here often.
 	 */
-	for_each_process_thread(g, c) {
-		if (!(c->flags & PF_KTHREAD) && c->mm == mm)
-			goto assign_new_owner;
+	for_each_process(g) {
+		if (g->flags & PF_KTHREAD)
+			continue;
+		for_each_thread(g, c) {
+			if (c->mm == mm)
+				goto assign_new_owner;
+			if (c->mm)
+				break;
+		}
 	}
 	read_unlock(&tasklist_lock);
 	/*
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH RESEND 3/3] memcg: kill start_kernel()->mm_init_owner(&init_mm)
  2014-04-28 15:19 [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Oleg Nesterov
  2014-04-28 15:19 ` [PATCH RESEND 1/3] memcg: mm_update_next_owner() should skip kthreads Oleg Nesterov
  2014-04-28 15:19 ` [PATCH RESEND 2/3] memcg: optimize the "Search everything else" loop in mm_update_next_owner() Oleg Nesterov
@ 2014-04-28 15:19 ` Oleg Nesterov
  2014-04-29 12:15 ` [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Michal Hocko
  3 siblings, 0 replies; 5+ messages in thread
From: Oleg Nesterov @ 2014-04-28 15:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Balbir Singh, Johannes Weiner, KAMEZAWA Hiroyuki, Michal Hocko,
	Peter Chiang, linux-kernel

Remove start_kernel()->mm_init_owner(&init_mm, &init_task).

This doesn't really hurt but unnecessary and misleading. init_task
is the "swapper" thread == current, its ->mm is always NULL. And
init_mm can only be used as ->active_mm, not as ->mm.

mm_init_owner() has a single caller with this patch, perhaps it
should die. mm_init() can initialize ->owner under #ifdef.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
---
 init/main.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/init/main.c b/init/main.c
index 3815895..17090bb 100644
--- a/init/main.c
+++ b/init/main.c
@@ -507,7 +507,6 @@ asmlinkage void __init start_kernel(void)
 	page_address_init();
 	pr_notice("%s", linux_banner);
 	setup_arch(&command_line);
-	mm_init_owner(&init_mm, &init_task);
 	mm_init_cpumask(&init_mm);
 	setup_command_line(command_line);
 	setup_nr_cpu_ids();
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups
  2014-04-28 15:19 [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Oleg Nesterov
                   ` (2 preceding siblings ...)
  2014-04-28 15:19 ` [PATCH RESEND 3/3] memcg: kill start_kernel()->mm_init_owner(&init_mm) Oleg Nesterov
@ 2014-04-29 12:15 ` Michal Hocko
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Hocko @ 2014-04-29 12:15 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, Balbir Singh, Johannes Weiner, KAMEZAWA Hiroyuki,
	Peter Chiang, linux-kernel

On Mon 28-04-14 17:19:26, Oleg Nesterov wrote:
> Andrew,
> 
> You applied the last (4th) memcg-kill-config_mm_owner.patch, but other
> patches in this thread were ignored. Hopefully thi is because I sent
> them chaotically.

All of them are queued AFAICS. I do not know where those emails are
archived so i've bounced them to you off-list.

> Let me resend 1-3 in case you missed them. Acked by Michal.
> 
> Oleg.
> 
>  init/main.c   |    1 -
>  kernel/exit.c |   18 +++++++++++-------
>  2 files changed, 11 insertions(+), 8 deletions(-)
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-29 12:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-28 15:19 [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Oleg Nesterov
2014-04-28 15:19 ` [PATCH RESEND 1/3] memcg: mm_update_next_owner() should skip kthreads Oleg Nesterov
2014-04-28 15:19 ` [PATCH RESEND 2/3] memcg: optimize the "Search everything else" loop in mm_update_next_owner() Oleg Nesterov
2014-04-28 15:19 ` [PATCH RESEND 3/3] memcg: kill start_kernel()->mm_init_owner(&init_mm) Oleg Nesterov
2014-04-29 12:15 ` [PATCH RESEND 0/3] memcg: minor ->mm_owner fix/cleanups Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).