History

[PATCH] m68k: introduce setup_thread_stack() and end_of_stack()

encapsulates the rest of arch-dependent operations with thread_info access. Two new helpers - setup_thread_stack() and end_of_stack(). For normal case the former consists of copying thread_info of parent to new thread_info and the latter returns pointer immediately past the end of thread_info.

Al Viro committed 21 years ago

Commit 10ebffd1 parent a1261f53 files · +14 −4Browse files

Unified · Split

3 files
  1. include/linux/sched.h +11 −0
  2. kernel/fork.c +1 −2
  3. kernel/sched.c +2 −2
include/linux/sched.h+11−0
@@ -1235,6 +1235,17 @@ static inline void task_unlock(struct task_struct *p) · 1234 unmodified lines
12351235
12361236 #define task_thread_info(task) (task)->thread_info
12371237
1238+static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
1239+{
1240+ *task_thread_info(p) = *task_thread_info(org);
1241+ task_thread_info(p)->task = p;
1242+}
1243+
1244+static inline unsigned long *end_of_stack(struct task_struct *p)
1245+{
1246+ return (unsigned long *)(p->thread_info + 1);
1247+}
1248+
12381249 /* set thread flags in other task's structures
12391250 * - see asm/thread_info.h for TIF_xxxx flags available
12401251 */
kernel/fork.c+1−2
@@ -171,10 +171,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) · 170 unmodified lines
171171 return NULL;
172172 }
173173
174− *ti = *orig->thread_info;
175174 *tsk = *orig;
176175 tsk->thread_info = ti;
177− ti->task = tsk;
176+ setup_thread_stack(tsk, orig);
178177
179178 /* One for us, one for whoever does the "release_task()" (usually parent) */
180179 atomic_set(&tsk->usage,2);
kernel/sched.c+2−2
@@ -4327,10 +4327,10 @@ static void show_task(task_t *p) · 4326 unmodified lines
43274327 #endif
43284328 #ifdef CONFIG_DEBUG_STACK_USAGE
43294329 {
4330− unsigned long *n = (unsigned long *) (p->thread_info+1);
4330+ unsigned long *n = end_of_stack(p);
43314331 while (!*n)
43324332 n++;
4333− free = (unsigned long) n - (unsigned long)(p->thread_info+1);
4333+ free = (unsigned long)n - (unsigned long)end_of_stack(p);
43344334 }
43354335 #endif
43364336 printk("%5lu %5d %6d ", free, p->pid, p->parent->pid);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t