mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop
       [not found] <04db01d10192$615ef0c0$241cd240$@alibaba-inc.com>
@ 2015-10-08  6:43 ` Hillf Danton
  0 siblings, 0 replies; 4+ messages in thread
From: Hillf Danton @ 2015-10-08  6:43 UTC (permalink / raw)
  To: 'Oleg Nesterov'
  Cc: Andrew Morton, David Rientjes, 'Kyle Walker',
	'Michal Hocko',
	linux-kernel

> 
> Purely cosmetic, but the complex "if" condition looks annoying to me.
> Especially because it is not consistent with OOM_SCORE_ADJ_MIN check
> which adds another if/continue.
> 
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
> ---
>  mm/oom_kill.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index b6b8c78..c189ee5 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -583,14 +583,18 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
>  	 * pending fatal signal.
>  	 */
>  	rcu_read_lock();
> -	for_each_process(p)
> -		if (p->mm == mm && !same_thread_group(p, victim) &&
> -		    !(p->flags & PF_KTHREAD)) {
> -			if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
> -				continue;
> +	for_each_process(p) {
> +		if (p->mm != mm)
> +			continue;
> +		if (same_thread_group(p, victim))
> +			continue;
> +		if (unlikely(p->flags & PF_KTHREAD))
> +			continue;

Given the result of "grep -nr PF_KTHREAD linux-next/mm", it looks
a helper function, like current_is_kswapd(), is needed.

int task_is_kthread(struct task_struct *task)

Other than that,
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>

> +		if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
> +			continue;
> 
> -			do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
> -		}
> +		do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
> +	}
>  	rcu_read_unlock();
> 
>  	mmput(mm);
> --
> 2.4.3
> 
> 



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

* Re: [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop
  2015-09-30 18:24 ` [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop Oleg Nesterov
  2015-09-30 21:15   ` David Rientjes
@ 2015-10-01 12:50   ` Michal Hocko
  1 sibling, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2015-10-01 12:50 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, David Rientjes, Kyle Walker, Stanislav Kozina,
	Tetsuo Handa, linux-kernel

On Wed 30-09-15 20:24:08, Oleg Nesterov wrote:
> Purely cosmetic, but the complex "if" condition looks annoying to me.
> Especially because it is not consistent with OOM_SCORE_ADJ_MIN check
> which adds another if/continue.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/oom_kill.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index b6b8c78..c189ee5 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -583,14 +583,18 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
>  	 * pending fatal signal.
>  	 */
>  	rcu_read_lock();
> -	for_each_process(p)
> -		if (p->mm == mm && !same_thread_group(p, victim) &&
> -		    !(p->flags & PF_KTHREAD)) {
> -			if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
> -				continue;
> +	for_each_process(p) {
> +		if (p->mm != mm)
> +			continue;
> +		if (same_thread_group(p, victim))
> +			continue;
> +		if (unlikely(p->flags & PF_KTHREAD))
> +			continue;
> +		if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
> +			continue;
>  
> -			do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
> -		}
> +		do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
> +	}
>  	rcu_read_unlock();
>  
>  	mmput(mm);
> -- 
> 2.4.3

-- 
Michal Hocko
SUSE Labs

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

* Re: [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop
  2015-09-30 18:24 ` [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop Oleg Nesterov
@ 2015-09-30 21:15   ` David Rientjes
  2015-10-01 12:50   ` Michal Hocko
  1 sibling, 0 replies; 4+ messages in thread
From: David Rientjes @ 2015-09-30 21:15 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, Kyle Walker, Michal Hocko, Stanislav Kozina,
	Tetsuo Handa, linux-kernel

On Wed, 30 Sep 2015, Oleg Nesterov wrote:

> Purely cosmetic, but the complex "if" condition looks annoying to me.
> Especially because it is not consistent with OOM_SCORE_ADJ_MIN check
> which adds another if/continue.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Acked-by: David Rientjes <rientjes@google.com>

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

* [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop
  2015-09-30 18:23 [PATCH -mm v2 0/3] mm/oom_kill: ensure we actually kill all tasks sharing the same mm Oleg Nesterov
@ 2015-09-30 18:24 ` Oleg Nesterov
  2015-09-30 21:15   ` David Rientjes
  2015-10-01 12:50   ` Michal Hocko
  0 siblings, 2 replies; 4+ messages in thread
From: Oleg Nesterov @ 2015-09-30 18:24 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Kyle Walker, Michal Hocko, Stanislav Kozina,
	Tetsuo Handa, linux-kernel

Purely cosmetic, but the complex "if" condition looks annoying to me.
Especially because it is not consistent with OOM_SCORE_ADJ_MIN check
which adds another if/continue.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 mm/oom_kill.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index b6b8c78..c189ee5 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -583,14 +583,18 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
 	 * pending fatal signal.
 	 */
 	rcu_read_lock();
-	for_each_process(p)
-		if (p->mm == mm && !same_thread_group(p, victim) &&
-		    !(p->flags & PF_KTHREAD)) {
-			if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
-				continue;
+	for_each_process(p) {
+		if (p->mm != mm)
+			continue;
+		if (same_thread_group(p, victim))
+			continue;
+		if (unlikely(p->flags & PF_KTHREAD))
+			continue;
+		if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
+			continue;
 
-			do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
-		}
+		do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
+	}
 	rcu_read_unlock();
 
 	mmput(mm);
-- 
2.4.3


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

end of thread, other threads:[~2015-10-08  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <04db01d10192$615ef0c0$241cd240$@alibaba-inc.com>
2015-10-08  6:43 ` [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop Hillf Danton
2015-09-30 18:23 [PATCH -mm v2 0/3] mm/oom_kill: ensure we actually kill all tasks sharing the same mm Oleg Nesterov
2015-09-30 18:24 ` [PATCH -mm v2 2/3] mm/oom_kill: cleanup the "kill sharing same memory" loop Oleg Nesterov
2015-09-30 21:15   ` David Rientjes
2015-10-01 12:50   ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome