File tree Expand file tree Collapse file tree 5 files changed +29
-10
lines changed Expand file tree Collapse file tree 5 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ void free_thread_stack(unsigned long *);
49
49
50
50
void threads_init (void );
51
51
void threads_cleanup (void );
52
+ void threads_cnt_dec (void );
52
53
53
54
#define TIF_SYSCALL_TRACE 0
54
55
#define TIF_NOTIFY_RESUME 1
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ int __init lkl_start_kernel(struct lkl_host_operations *ops,
75
75
}
76
76
77
77
lkl_ops -> sem_down (init_sem );
78
+ lkl_ops -> sem_free (init_sem );
78
79
current_thread_info ()-> tid = lkl_ops -> thread_self ();
79
80
lkl_cpu_change_owner (current_thread_info ()-> tid );
80
81
@@ -112,7 +113,8 @@ void machine_restart(char *unused)
112
113
long lkl_sys_halt (void )
113
114
{
114
115
long err ;
115
- long params [6 ] = { 0 , };
116
+ long params [6 ] = {LINUX_REBOOT_MAGIC1 ,
117
+ LINUX_REBOOT_MAGIC2 , LINUX_REBOOT_CMD_RESTART , };
116
118
117
119
err = lkl_syscall (__NR_reboot , params );
118
120
if (err < 0 )
@@ -158,6 +160,7 @@ static int lkl_run_init(struct linux_binprm *bprm)
158
160
init_pid_ns .child_reaper = 0 ;
159
161
160
162
syscalls_init ();
163
+ threads_cnt_dec ();
161
164
162
165
lkl_ops -> sem_up (init_sem );
163
166
lkl_ops -> thread_exit ();
Original file line number Diff line number Diff line change @@ -113,6 +113,13 @@ long lkl_syscall(long no, long *params)
113
113
114
114
ret = run_syscall (no , params );
115
115
116
+ if (no == __NR_reboot ) {
117
+ set_current_state (TASK_UNINTERRUPTIBLE );
118
+ if (!thread_set_sched_jmp ())
119
+ schedule ();
120
+ return ret ;
121
+ }
122
+
116
123
out :
117
124
lkl_cpu_put ();
118
125
Original file line number Diff line number Diff line change @@ -225,18 +225,23 @@ void threads_init(void)
225
225
ti -> tid = lkl_ops -> thread_self ();
226
226
}
227
227
228
+ void threads_cnt_dec (void )
229
+ {
230
+ __sync_fetch_and_sub (& threads_counter , 1 );
231
+ }
232
+
228
233
void threads_cleanup (void )
229
234
{
230
- struct task_struct * p ;
235
+ struct task_struct * p , * t ;
231
236
232
- for_each_process ( p ) {
233
- struct thread_info * ti = task_thread_info (p );
237
+ for_each_process_thread ( p , t ) {
238
+ struct thread_info * ti = task_thread_info (t );
234
239
235
- if (p -> pid != 1 )
236
- WARN (!(p -> flags & PF_KTHREAD ),
237
- "non kernel thread task %p \n" , p -> comm );
238
- WARN (p -> state == TASK_RUNNING ,
239
- "thread %s still running while halting\n" , p -> comm );
240
+ if (t -> pid != 1 && ! test_ti_thread_flag ( ti , TIF_HOST_THREAD ) )
241
+ WARN (!(t -> flags & PF_KTHREAD ),
242
+ "non kernel thread task %s \n" , t -> comm );
243
+ WARN (t -> state == TASK_RUNNING ,
244
+ "thread %s still running while halting\n" , t -> comm );
240
245
241
246
kill_thread (ti );
242
247
}
Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ hijack_fini(void)
433
433
{
434
434
int i ;
435
435
char * dump = getenv ("LKL_HIJACK_DUMP" );
436
+ int err ;
436
437
437
438
/* The following pauses the kernel before exiting allowing one
438
439
* to debug or collect stattistics/diagnosis info from it.
@@ -453,5 +454,7 @@ hijack_fini(void)
453
454
if (nd )
454
455
lkl_netdev_free (nd );
455
456
456
- lkl_sys_halt ();
457
+ err = lkl_sys_halt ();
458
+ if (err )
459
+ fprintf (stderr , "lkl_sys_halt: %s\n" , lkl_strerror (err ));
457
460
}
You can’t perform that action at this time.
0 commit comments