Skip to contentSkip to conversation

more next_thread/while_each_thread changes

PATCH In review Oleg Nesterov 2 participants 7 messages Nov 22, 2013 Proc filesystem

lore
Share & tools
lore
#0 lore raw

cover more next_thread/while_each_thread changes

Trivial, change the remaining next_thread (ab)users to use while_each_thread().

The last user which should be changed is next_tid(), but we can't do this now.

__exit_signal() and complete_signal() are fine, they actually need next_thread() logic.

Oleg.

 fs/proc/array.c |    3 +--
 kernel/signal.c |    7 +++----
 kernel/sys.c    |    3 +--
 3 files changed, 5 insertions(+), 8 deletions(-)
#1 lore raw

PATCH 1/3 proc: change do_task_stat() to use while_each_thread()

do_task_stat() can use while_each_thread(), no changes in the compiled code.

---
 fs/proc/array.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/proc/array.c +1 -2
index c995807..c59e74f 100644
@@ -442,8 +442,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
 				min_flt += t->min_flt;
 				maj_flt += t->maj_flt;
 				gtime += task_gtime(t);
-				t = next_thread(t);
-			} while (t != task);
+			} while_each_thread(task, t);
 
 			min_flt += sig->min_flt;
 			maj_flt += sig->maj_flt;
Signature · 1 line
1.5.5.1
#3 lore raw

PATCH 2/3 k_getrusage() can use while_each_thread()

In reply to Oleg Nesterov

Change k_getrusage() to use while_each_thread(), no changes in the compiled code.

---
 kernel/sys.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
kernel/sys.c +1 -2
index 1d9a218..70d56d6 100644
@@ -1572,8 +1572,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
 			t = p;
 			do {
 				accumulate_thread_rusage(t, r);
-				t = next_thread(t);
-			} while (t != p);
+			} while_each_thread(p, t);
 			break;
 
 		default:
Signature · 1 line
1.5.5.1
#5 lore raw

PATCH 3/3 signals: change do_signal_stop/do_sigaction to use while_each_thread()

In reply to Oleg Nesterov

Change do_signal_stop() and do_sigaction() to avoid next_thread() and use while_each_thread() instead.

---
 kernel/signal.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
kernel/signal.c +3 -4
index ded28b9..086071d 100644
@@ -2047,8 +2047,8 @@ static bool do_signal_stop(int signr)
 		if (task_set_jobctl_pending(current, signr | gstop))
 			sig->group_stop_count++;
 
-		for (t = next_thread(current); t != current;
-		     t = next_thread(t)) {
+		t = current;
+		while_each_thread(current, t) {
 			/*
 			 * Setting state to TASK_STOPPED for a group
 			 * stop is always done with the siglock held,
@@ -3125,8 +3125,7 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
 			rm_from_queue_full(&mask, &t->signal->shared_pending);
 			do {
 				rm_from_queue_full(&mask, &t->pending);
-				t = next_thread(t);
-			} while (t != current);
+			} while_each_thread(current, t);
 		}
 	}
 
Signature · 1 line
1.5.5.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] proc: change do_task_stat() to use while_each_thread()

In reply to Oleg Nesterov
Quoted 4 lines · Oleg Nesterov

do_task_stat() can use while_each_thread(), no changes in the compiled code.

Quoted 21 lines
---
 fs/proc/array.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/proc/array.c +1 -3
index c995807..c59e74f 100644
@@ -442,8 +442,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
                                min_flt += t->min_flt;
                                maj_flt += t->maj_flt;
                                gtime += task_gtime(t);
-                               t = next_thread(t);
-                       } while (t != task);
+                       } while_each_thread(task, t);
 
                        min_flt += sig->min_flt;
                        maj_flt += sig->maj_flt;
--

1.5.5.1

Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] k_getrusage() can use while_each_thread()

In reply to Oleg Nesterov
Quoted 4 lines · Oleg Nesterov

Change k_getrusage() to use while_each_thread(), no changes in the compiled code.

Quoted 21 lines
---
 kernel/sys.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
kernel/sys.c +1 -3
index 1d9a218..70d56d6 100644
@@ -1572,8 +1572,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
                        t = p;
                        do {
                                accumulate_thread_rusage(t, r);
-                               t = next_thread(t);
-                       } while (t != p);
+                       } while_each_thread(p, t);
                        break;
 
                default:
--

1.5.5.1

Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] signals: change do_signal_stop/do_sigaction to use while_each_thread()

In reply to Oleg Nesterov
Quoted 4 lines · Oleg Nesterov

Change do_signal_stop() and do_sigaction() to avoid next_thread() and use while_each_thread() instead.

Quoted 32 lines
---
 kernel/signal.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
kernel/signal.c +3 -5
index ded28b9..086071d 100644
@@ -2047,8 +2047,8 @@ static bool do_signal_stop(int signr)
                if (task_set_jobctl_pending(current, signr | gstop))
                        sig->group_stop_count++;
 
-               for (t = next_thread(current); t != current;
-                    t = next_thread(t)) {
+               t = current;
+               while_each_thread(current, t) {
                        /*
                         * Setting state to TASK_STOPPED for a group
                         * stop is always done with the siglock held,
@@ -3125,8 +3125,7 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
                        rm_from_queue_full(&mask, &t->signal->shared_pending);
                        do {
                                rm_from_queue_full(&mask, &t->pending);
-                               t = next_thread(t);
-                       } while (t != current);
+                       } while_each_thread(current, t);
                }
        }
 
--

1.5.5.1

Signature · 1 line
Sameer