Use list heads for task list
Subsystems (5)
PATCH 1/1 Use list heads for task list
This patch (against 2.5.6-pre1) converts prev_task and next_task in the task_struct to use list heads.
Signature · 1 line
Brian Gerst
arch/alpha/kernel/smp.c +1 -1
@@ -460,7 +460,7 @@if (fork_by_hand () <0 )panic ("failed fork for CPU %d" , cpuid); - idle = init_task.prev_task; + idle =LAST_TASK ;if (!idle)panic ("No idle process for CPU %d" , cpuid);
arch/i386/kernel/smpboot.c +1 -1
@@ -828,7 +828,7 @@* We remove it from the pidhash and the runqueue * once we got the process: */ - idle = init_task.prev_task; + idle =LAST_TASK ;if (!idle)panic ("No idle process for CPU %d" , cpu);
arch/ia64/kernel/smpboot.c +1 -1
@@ -412,7 +412,7 @@* We remove it from the pidhash and the runqueue * once we got the process: */ - idle = init_task.prev_task; + idle =LAST_TASK ;if (!idle)panic ("No idle process for CPU %d" , cpu);
arch/mips/kernel/smp.c +2 -2
@@ -123,7 +123,7 @@/* Spawn a new process normally. Grab a pointer to its task struct so we can mess with it */ do_fork (CLONE_VM |CLONE_PID ,0 , ®s,0 ); - p = init_task.prev_task; + p =LAST_TASK ;/* Schedule the first task manually */ p->processor = i;
@@ -152,7 +152,7 @@* Linux can schedule processes on this slave. */ kernel_thread (0 ,NULL ,CLONE_PID ); - p = init_task.prev_task; + p =LAST_TASK ;sprintf (p->comm,"%s%d" ,"Idle" , i); init_tasks[i] = p; p->processor = i;
arch/mips64/sgi-ip27/ip27-init.c +1 -1
@@ -491,7 +491,7 @@* Linux can schedule processes on this slave. */ kernel_thread (0 ,NULL ,CLONE_PID ); - p = init_task.prev_task; + p =LAST_TASK ;sprintf (p->comm,"%s%d" ,"Idle" , num_cpus); init_tasks[num_cpus] = p;alloc_cpupda (cpu, num_cpus);
arch/ppc/kernel/smp.c +1 -1
@@ -364,7 +364,7 @@memset (®s,0 ,sizeof (struct pt_regs ));if (do_fork (CLONE_VM |CLONE_PID ,0 , ®s,0 ) <0 )panic ("failed fork for CPU %d" , i); - p = init_task.prev_task; + p =LAST_TASK ;if (!p)panic ("No idle task for CPU %d" , i);init_idle (p, i);
arch/ppc64/kernel/smp.c +1 -1
@@ -669,7 +669,7 @@if (do_fork (CLONE_VM |CLONE_PID ,0 , ®s,0 ) <0 )panic ("failed fork for CPU %d" , i); - p = init_task.prev_task; + p =LAST_TASK ;if (!p)panic ("No idle task for CPU %d" , i);
arch/s390/kernel/smp.c +1 -1
@@ -528,7 +528,7 @@* We remove it from the pidhash and the runqueue * once we got the process: */ - idle = init_task.prev_task; + idle =LAST_TASK ;if (!idle)panic ("No idle process for CPU %d" ,cpu); idle->processor = cpu;
arch/s390x/kernel/smp.c +1 -1
@@ -507,7 +507,7 @@* We remove it from the pidhash and the runqueue * once we got the process: */ - idle = init_task.prev_task; + idle =LAST_TASK ;if (!idle)panic ("No idle process for CPU %d" ,cpu); idle->processor = cpu;
arch/sparc/kernel/sun4d_smp.c +1 -1
@@ -220,7 +220,7 @@ cpucount++; - p = init_task.prev_task; + p =LAST_TASK ; p->cpu = i;
arch/sparc/kernel/sun4m_smp.c +1 -1
@@ -193,7 +193,7 @@ cpucount++; - p = init_task.prev_task; + p =LAST_TASK ; p->cpu = i;
arch/sparc64/kernel/smp.c +1 -1
@@ -270,7 +270,7 @@kernel_thread (NULL ,NULL ,CLONE_PID ); cpucount++; - p = init_task.prev_task; + p =LAST_TASK ;init_idle (p, i);
arch/x86_64/kernel/smpboot.c +1 -1
@@ -559,7 +559,7 @@* We remove it from the pidhash and the runqueue * once we got the process: */ - idle = init_task.prev_task; + idle =LAST_TASK ;if (!idle)panic ("No idle process for CPU %d" , cpu);
include/linux/init_task.h +1 -2
@@ -53,8 +53,7 @@ active_mm: &init_mm, \ run_list: LIST_HEAD_INIT(tsk.run_list), \ time_slice: HZ, \ - next_task: &tsk, \ - prev_task: &tsk, \ + task_list: LIST_HEAD_INIT(tsk.task_list), \ p_opptr: &tsk, \ p_pptr: &tsk, \ thread_group: LIST_HEAD_INIT(tsk.thread_group), \
include/linux/sched.h +10 -9
@@ -250,7 +250,7 @@unsigned long cpus_allowed;unsigned int time_slice; -struct task_struct *next_task, *prev_task; +struct list_head task_list;struct mm_struct *mm, *active_mm;struct list_head local_pages;
@@ -716,8 +716,7 @@ })#define REMOVE_LINKS (p) do { \ - (p)->next_task->prev_task = (p)->prev_task; \ - (p)->prev_task->next_task = (p)->next_task; \ + list_del(&(p)->task_list); \ if ((p)->p_osptr) \ (p)->p_osptr->p_ysptr = (p)->p_ysptr; \ if ((p)->p_ysptr) \
@@ -727,18 +726,20 @@ } while (0)#define SET_LINKS (p) do { \ - (p)->next_task = &init_task; \ - (p)->prev_task = init_task.prev_task; \ - init_task.prev_task->next_task = (p); \ - init_task.prev_task = (p); \ + list_add_tail(&(p)->task_list, &init_task.task_list); \ (p)->p_ysptr = NULL; \ if (((p)->p_osptr = (p)->p_pptr->p_cptr) != NULL) \ (p)->p_osptr->p_ysptr = p; \ (p)->p_pptr->p_cptr = p; \ } while (0) -#define for_each_task (p) \ - for (p = &init_task ; (p = p->next_task) != &init_task ; ) +#define LAST_TASK list_entry(init_task.task_list.prev, struct task_struct, task_list) + +#define for_each_task (task) \ + for (task = next_task(&init_task) ; task != &init_task ; task = next_task(task)) + +#define next_task (p) \ + list_entry((p)->task_list.next, struct task_struct, task_list)#define for_each_thread (task) \ for (task = next_thread(current) ; task != current ; task = next_thread(task))