Skip to contentSkip to conversation

cpuset: two minor code-cleanups

PATCH In review Lai Jiangshan 2 participants 2 messages Jul 16, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 cpuset: two minor code-cleanups

in function cpuset_update_task_memory_state() local variable
struct task_struct *tsk = current;

and local variable tsk is used 14 times and statement task_cs(tsk) is used twice in this function. So using task_cs(tsk) instead of task_cs(current) is better for readability.

And "(struct cgroup_scanner *)&scan" is not good for readability also. (and "container_of" is used in cpuset_do_move_task(), not "(cpuset_hotplug_scanner *)scan")

---

kernel/cpuset.c +2 -2
index 798b3ab..4513deb 100644
@@ -369,7 +369,7 @@ void cpuset_update_task_memory_state(void)
 		my_cpusets_mem_gen = top_cpuset.mems_generation;
 	} else {
 		rcu_read_lock();
-		my_cpusets_mem_gen = task_cs(current)->mems_generation;
+		my_cpusets_mem_gen = task_cs(tsk)->mems_generation;
 		rcu_read_unlock();
 	}
 
@@ -1778,7 +1778,7 @@ static void move_member_tasks_to_cpuset(struct cpuset *from, struct cpuset *to)
 	scan.scan.heap = NULL;
 	scan.to = to->css.cgroup;
 
-	if (cgroup_scan_tasks((struct cgroup_scanner *)&scan))
+	if (cgroup_scan_tasks(&scan.scan))
 		printk(KERN_ERR "move_member_tasks_to_cpuset: "
 				"cgroup_scan_tasks failed\n");
 }
Acked-by on v1 3/3
#1 lore raw
Quoted 9 lines · Lai Jiangshan

in function cpuset_update_task_memory_state() local variable
struct task_struct *tsk = current;

and local variable tsk is used 14 times and statement task_cs(tsk) is used twice in this function. So using task_cs(tsk) instead of task_cs(current) is better for readability.

Quoted 5 lines

And "(struct cgroup_scanner *)&scan" is not good for readability also. (and "container_of" is used in cpuset_do_move_task(), not "(cpuset_hotplug_scanner *)scan")

Thanks.

Quoted 29 lines

---

kernel/cpuset.c +2 -2
index 798b3ab..4513deb 100644
@@ -369,7 +369,7 @@ void cpuset_update_task_memory_state(void)
               my_cpusets_mem_gen = top_cpuset.mems_generation;
       } else {
               rcu_read_lock();
-               my_cpusets_mem_gen = task_cs(current)->mems_generation;
+               my_cpusets_mem_gen = task_cs(tsk)->mems_generation;
               rcu_read_unlock();
       }
 
@@ -1778,7 +1778,7 @@ static void move_member_tasks_to_cpuset(struct cpuset *from, struct cpuset *to)
       scan.scan.heap = NULL;
       scan.to = to->css.cgroup;
 
-       if (cgroup_scan_tasks((struct cgroup_scanner *)&scan))
+       if (cgroup_scan_tasks(&scan.scan))
               printk(KERN_ERR "move_member_tasks_to_cpuset: "
                               "cgroup_scan_tasks failed\n");
 }