Skip to contentSkip to conversation

mm/oom_kill: cleanup the "kill sharing same memory" loop

PATCH Hillf Danton 1 participant 1 message Oct 8, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Hillf Danton

author Acked-by
#1 lore raw
Quoted 20 lines

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.

---
 mm/oom_kill.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
mm/oom_kill.c +0 -2
index b6b8c78..c189ee5 100644
@@ -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) &&

mm/oom_kill.c void oom_kill_process(struct oom_control *oc, struct task_struct *p, · line 592

Quoted 10 lines
mm/oom_kill.c +7 -3
-		    !(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,

Quoted 14 lines
mm/oom_kill.c +4 -3
+		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