Skip to content

Commit 42a20f8

Browse files
keesPeter Zijlstra
authored andcommitted
sched: Add wrapper for get_wchan() to keep task blocked
Having a stable wchan means the process must be blocked and for it to stay that way while performing stack unwinding. Suggested-by: Peter Zijlstra <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Acked-by: Russell King (Oracle) <[email protected]> [arm] Tested-by: Mark Rutland <[email protected]> [arm64] Link: https://lkml.kernel.org/r/[email protected]
1 parent bc9bbb8 commit 42a20f8

File tree

50 files changed

+80
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+80
-112
lines changed

arch/alpha/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern void start_thread(struct pt_regs *, unsigned long, unsigned long);
4242
struct task_struct;
4343
extern void release_thread(struct task_struct *);
4444

45-
unsigned long get_wchan(struct task_struct *p);
45+
unsigned long __get_wchan(struct task_struct *p);
4646

4747
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
4848

arch/alpha/kernel/process.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,11 @@ thread_saved_pc(struct task_struct *t)
376376
}
377377

378378
unsigned long
379-
get_wchan(struct task_struct *p)
379+
__get_wchan(struct task_struct *p)
380380
{
381381
unsigned long schedule_frame;
382382
unsigned long pc;
383-
if (!p || p == current || task_is_running(p))
384-
return 0;
383+
385384
/*
386385
* This one depends on the frame size of schedule(). Do a
387386
* "disass schedule" in gdb to find the frame size. Also, the

arch/arc/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct task_struct;
7070
extern void start_thread(struct pt_regs * regs, unsigned long pc,
7171
unsigned long usp);
7272

73-
extern unsigned int get_wchan(struct task_struct *p);
73+
extern unsigned int __get_wchan(struct task_struct *p);
7474

7575
#endif /* !__ASSEMBLY__ */
7676

arch/arc/kernel/stacktrace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* = specifics of data structs where trace is saved(CONFIG_STACKTRACE etc)
1616
*
1717
* vineetg: March 2009
18-
* -Implemented correct versions of thread_saved_pc() and get_wchan()
18+
* -Implemented correct versions of thread_saved_pc() and __get_wchan()
1919
*
2020
* rajeshwarr: 2008
2121
* -Initial implementation
@@ -248,7 +248,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)
248248
* Of course just returning schedule( ) would be pointless so unwind until
249249
* the function is not in schedular code
250250
*/
251-
unsigned int get_wchan(struct task_struct *tsk)
251+
unsigned int __get_wchan(struct task_struct *tsk)
252252
{
253253
return arc_unwind_core(tsk, NULL, __get_first_nonsched, NULL);
254254
}

arch/arm/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct task_struct;
8484
/* Free all resources held by a thread. */
8585
extern void release_thread(struct task_struct *);
8686

87-
unsigned long get_wchan(struct task_struct *p);
87+
unsigned long __get_wchan(struct task_struct *p);
8888

8989
#define task_pt_regs(p) \
9090
((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)

arch/arm/kernel/process.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
276276
return 0;
277277
}
278278

279-
unsigned long get_wchan(struct task_struct *p)
279+
unsigned long __get_wchan(struct task_struct *p)
280280
{
281281
struct stackframe frame;
282282
unsigned long stack_page;
283283
int count = 0;
284-
if (!p || p == current || task_is_running(p))
285-
return 0;
286284

287285
frame.fp = thread_saved_fp(p);
288286
frame.sp = thread_saved_sp(p);

arch/arm64/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ struct task_struct;
257257
/* Free all resources held by a thread. */
258258
extern void release_thread(struct task_struct *);
259259

260-
unsigned long get_wchan(struct task_struct *p);
260+
unsigned long __get_wchan(struct task_struct *p);
261261

262262
void update_sctlr_el1(u64 sctlr);
263263

arch/arm64/kernel/process.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,11 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
528528
return last;
529529
}
530530

531-
unsigned long get_wchan(struct task_struct *p)
531+
unsigned long __get_wchan(struct task_struct *p)
532532
{
533533
struct stackframe frame;
534534
unsigned long stack_page, ret = 0;
535535
int count = 0;
536-
if (!p || p == current || task_is_running(p))
537-
return 0;
538536

539537
stack_page = (unsigned long)try_get_task_stack(p);
540538
if (!stack_page)

arch/csky/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static inline void release_thread(struct task_struct *dead_task)
8181

8282
extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
8383

84-
unsigned long get_wchan(struct task_struct *p);
84+
unsigned long __get_wchan(struct task_struct *p);
8585

8686
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
8787
#define KSTK_ESP(tsk) (task_pt_regs(tsk)->usp)

arch/csky/kernel/stacktrace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,11 @@ static bool save_wchan(unsigned long pc, void *arg)
111111
return false;
112112
}
113113

114-
unsigned long get_wchan(struct task_struct *task)
114+
unsigned long __get_wchan(struct task_struct *task)
115115
{
116116
unsigned long pc = 0;
117117

118-
if (likely(task && task != current && !task_is_running(task)))
119-
walk_stackframe(task, NULL, save_wchan, &pc);
118+
walk_stackframe(task, NULL, save_wchan, &pc);
120119
return pc;
121120
}
122121

0 commit comments

Comments
 (0)