Skip to contentSkip to conversation

proc_oom_score: remove tasklist_lock and pid_alive()

PATCH Applied Oleg Nesterov 3 participants 3 messages Jun 8, 2016 – Jun 9, 2016 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc_oom_score: remove tasklist_lock and pid_alive()

This was needed before to ensure that ->signal != 0 and do_each_thread() is safe, see the commit b95c35e76b29b for details.

Today tsk->signal can't go away and for_each_thread(tsk) is always safe.

---
 fs/proc/base.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/proc/base.c +2 -5
index a11eb71..93e7754 100644
@@ -579,11 +579,8 @@ static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
 	unsigned long totalpages = totalram_pages + total_swap_pages;
 	unsigned long points = 0;
 
-	read_lock(&tasklist_lock);
-	if (pid_alive(task))
-		points = oom_badness(task, NULL, NULL, totalpages) *
-						1000 / totalpages;
-	read_unlock(&tasklist_lock);
+	points = oom_badness(task, NULL, NULL, totalpages) *
+					1000 / totalpages;
 	seq_printf(m, "%lu\n", points);
 
 	return 0;
Signature · 1 line
2.5.0
Acked-by on v1 1/1
#2 lore raw
In reply to Oleg Nesterov
Quoted 6 lines · Oleg Nesterov

This was needed before to ensure that ->signal != 0 and do_each_thread() is safe, see the commit b95c35e76b29b for details.

Today tsk->signal can't go away and for_each_thread(tsk) is always safe.

Quoted 25 lines
---
 fs/proc/base.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/proc/base.c +2 -5
index a11eb71..93e7754 100644
@@ -579,11 +579,8 @@ static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
 	unsigned long totalpages = totalram_pages + total_swap_pages;
 	unsigned long points = 0;
 
-	read_lock(&tasklist_lock);
-	if (pid_alive(task))
-		points = oom_badness(task, NULL, NULL, totalpages) *
-						1000 / totalpages;
-	read_unlock(&tasklist_lock);
+	points = oom_badness(task, NULL, NULL, totalpages) *
+					1000 / totalpages;
 	seq_printf(m, "%lu\n", points);
 
 	return 0;
Signature · 1 line
2.5.0
Signature · 2 lines
Michal Hocko
SUSE Labs