@@ -15,38 +15,43 @@ struct task_struct *__switch_to(struct task_struct *from,
15
15
struct thread_info * to_info = task_thread_info (to );
16
16
int cpu , other_cpu ;
17
17
18
- cpu = atomic_xchg_release (& from_info -> running_cpu , -1 );
18
+ cpu = atomic_xchg (& from_info -> running_cpu , -1 );
19
19
BUG_ON (cpu < 0 ); // current process must be scheduled to a cpu
20
20
21
21
// give the current cpu to the new worker
22
- other_cpu = atomic_xchg_acquire (& to_info -> running_cpu , cpu );
22
+ other_cpu = atomic_xchg (& to_info -> running_cpu , cpu );
23
23
BUG_ON (other_cpu >= 0 ); // new process should not have had a cpu
24
24
25
+ pr_info ("broken task: %p" ,
26
+ & ((struct task_struct * )0x00174000 )-> se .group_node );
27
+
25
28
// wake the other worker:
26
- // pr_info("wake cpu=%i task=%p\n", cpu, to);
29
+ pr_info ("wake cpu=%i task=%p\n" , cpu , to );
27
30
// memory.atomic.notify returns how many waiters were notified
28
31
// 0 is fine, because it means the worker isn't running yet
29
32
// 1 is great, because it means someone is waiting for this number
30
33
// 2+ means there's an issue, because I asked for only 1
31
34
BUG_ON (__builtin_wasm_memory_atomic_notify (
32
- & to_info -> running_cpu .counter , 1 ) > 1 );
35
+ & to_info -> running_cpu .counter ,
36
+ /* how many to wake up (at most): */ 1 ) > 1 );
33
37
34
- // pr_info("waiting cpu=%i task=%p in switch\n", cpu, from);
38
+ pr_info ("waiting cpu=%i task=%p in switch\n" ,
39
+ atomic_read (& from_info -> running_cpu ), from );
35
40
36
41
// sleep this worker:
37
42
/* memory.atomic.wait32 returns:
38
43
* 0 -> the thread blocked and was woken
39
44
= we slept and were woken
40
45
* 1 -> the value at the pointer didn't match the passed value
41
- = somebody gave us their cpu straight await
46
+ = somebody gave us their cpu straight away
42
47
* 2 -> the thread blocked but timed out
43
48
= not possible because we pass an infinite timeout
44
49
*/
45
50
__builtin_wasm_memory_atomic_wait32 (& from_info -> running_cpu .counter ,
46
51
/* block if the value is: */ -1 ,
47
52
/* timeout: */ -1 );
48
53
49
- // pr_info("woke up cpu=%i task=%p in switch\n", cpu, from);
54
+ pr_info ("woke up cpu=%i task=%p in switch\n" , cpu , from );
50
55
51
56
BUG_ON (cpu < 0 ); // we should be given a new cpu
52
57
@@ -73,14 +78,12 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
73
78
return 0 ;
74
79
}
75
80
76
- __attribute__(( export_name ( "task" ))) void _start_task (struct task_struct * task )
81
+ static void noinline_for_stack start_task_inner (struct task_struct * task )
77
82
{
78
83
struct thread_info * info = task_thread_info (task );
79
84
struct pt_regs * regs = task_pt_regs (task );
80
85
int cpu ;
81
86
82
- set_stack_pointer (task_pt_regs (task ) - 1 );
83
-
84
87
early_printk (" waiting cpu=%i task=%p in entry\n" ,
85
88
atomic_read (& info -> running_cpu ), task );
86
89
@@ -106,3 +109,9 @@ __attribute__((export_name("task"))) void _start_task(struct task_struct *task)
106
109
// call into userspace?
107
110
panic ("can't call userspace\n" );
108
111
}
112
+
113
+ __attribute__((export_name ("task" ))) void _start_task (struct task_struct * task )
114
+ {
115
+ set_stack_pointer (task_pt_regs (task ) - 1 );
116
+ start_task_inner (task );
117
+ }
0 commit comments