Skip to contentSkip to conversation

check_for_tasks: read_lock(tasklist_lock) doesn't need to disable irqs

PATCH In review Oleg Nesterov 4 participants 4 messages Sep 10, 2015 – Sep 13, 2015 CPU hotplug

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check_for_tasks: read_lock(tasklist_lock) doesn't need to disable irqs

check_for_tasks() doesn't need to disable irqs, recursive read_lock() from interrupt is fine.

While at it, s/do_each_thread/for_each_process_thread/.

---
 kernel/cpu.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
kernel/cpu.c +4 -4
index 94bbe46..24551f2 100644
@@ -302,8 +302,8 @@ static inline void check_for_tasks(int dead_cpu)
 {
 	struct task_struct *g, *p;
 
-	read_lock_irq(&tasklist_lock);
-	do_each_thread(g, p) {
+	read_lock(&tasklist_lock);
+	for_each_process_thread(g, p) {
 		if (!p->on_rq)
 			continue;
 		/*
@@ -318,8 +318,8 @@ static inline void check_for_tasks(int dead_cpu)
 
 		pr_warn("Task %s (pid=%d) is on cpu %d (state=%ld, flags=%x)\n",
 			p->comm, task_pid_nr(p), dead_cpu, p->state, p->flags);
-	} while_each_thread(g, p);
-	read_unlock_irq(&tasklist_lock);
+	}
+	read_unlock(&tasklist_lock);
 }
 
 struct take_cpu_down_param {
Signature · 1 line
1.5.5.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Oleg Nesterov

check_for_tasks() doesn't need to disable irqs, recursive read_lock() from interrupt is fine.

While at it, s/do_each_thread/for_each_process_thread/.

Quoted 31 lines
---
 kernel/cpu.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
kernel/cpu.c +4 -4
index 94bbe46..24551f2 100644
@@ -302,8 +302,8 @@ static inline void check_for_tasks(int dead_cpu)
 {
 	struct task_struct *g, *p;
 
-	read_lock_irq(&tasklist_lock);
-	do_each_thread(g, p) {
+	read_lock(&tasklist_lock);
+	for_each_process_thread(g, p) {
 		if (!p->on_rq)
 			continue;
 		/*
@@ -318,8 +318,8 @@ static inline void check_for_tasks(int dead_cpu)
 
 		pr_warn("Task %s (pid=%d) is on cpu %d (state=%ld, flags=%x)\n",
 			p->comm, task_pid_nr(p), dead_cpu, p->state, p->flags);
-	} while_each_thread(g, p);
-	read_unlock_irq(&tasklist_lock);
+	}
+	read_unlock(&tasklist_lock);
 }
 
 struct take_cpu_down_param {
Reviewed-by on v1 1/1
#2 lore raw
In reply to Oleg Nesterov
Quoted 6 lines · Oleg Nesterov

check_for_tasks() doesn't need to disable irqs, recursive read_lock() from interrupt is fine.

While at it, s/do_each_thread/for_each_process_thread/.

Looks good to me.

Quoted 4 lines
---
 kernel/cpu.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Signature · 2 lines
Thanks and Regards
Srikar Dronamraju
#3 lore raw

[tip:sched/core] cpu/hotplug: Read_lock(tasklist_lock) doesn' t need to disable irqs

In reply to Oleg Nesterov
cpu/hotplug: Read_lock(tasklist_lock) doesn't need to disable irqs
Commit-ID:  a75a6068dac25d4022ebcd82192ed6345407843c
Gitweb:     http://git.kernel.org/tip/a75a6068dac25d4022ebcd82192ed6345407843c
Author:     Oleg Nesterov <[email protected]>
AuthorDate: Thu, 10 Sep 2015 15:07:50 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 12 Sep 2015 11:54:27 +0200

cpu/hotplug: Read_lock(tasklist_lock) doesn't need to disable irqs

check_for_tasks() doesn't need to disable irqs, recursive read_lock() from interrupt is fine.

While at it, s/do_each_thread/for_each_process_thread/.

---
 kernel/cpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/cpu.c +4 -4
index 82cf9df..050c634 100644
@@ -304,8 +304,8 @@ static inline void check_for_tasks(int dead_cpu)
 {
 	struct task_struct *g, *p;
 
-	read_lock_irq(&tasklist_lock);
-	do_each_thread(g, p) {
+	read_lock(&tasklist_lock);
+	for_each_process_thread(g, p) {
 		if (!p->on_rq)
 			continue;
 		/*
@@ -320,8 +320,8 @@ static inline void check_for_tasks(int dead_cpu)
 
 		pr_warn("Task %s (pid=%d) is on cpu %d (state=%ld, flags=%x)\n",
 			p->comm, task_pid_nr(p), dead_cpu, p->state, p->flags);
-	} while_each_thread(g, p);
-	read_unlock_irq(&tasklist_lock);
+	}
+	read_unlock(&tasklist_lock);
 }
 
 struct take_cpu_down_param {