mirror of
https://github.com/drasko/codezero.git
synced 2026-01-16 21:03:16 +01:00
Some more progress with debugging pager exits
This commit is contained in:
@@ -102,7 +102,8 @@ int init_pager(struct pager *pager,
|
||||
address_space_attach(task, space);
|
||||
} else {
|
||||
/* Otherwise allocate conventionally */
|
||||
task->space = address_space_create(0);
|
||||
space = address_space_create(0);
|
||||
address_space_attach(task, space);
|
||||
}
|
||||
|
||||
/* Initialize ktcb */
|
||||
@@ -115,6 +116,13 @@ int init_pager(struct pager *pager,
|
||||
task->tgid = task->tid;
|
||||
task->container = cont;
|
||||
|
||||
/*
|
||||
* Setup dummy container pointer so that curcont works,
|
||||
* and add the address space to container space list
|
||||
*/
|
||||
current->container = cont;
|
||||
address_space_add(task->space);
|
||||
|
||||
/* Initialize uninitialized capability fields while on dummy */
|
||||
list_foreach_struct(cap, ¤t->cap_list.caps, list) {
|
||||
/* Initialize owner */
|
||||
@@ -156,7 +164,6 @@ int init_pager(struct pager *pager,
|
||||
|
||||
/* Container list that keeps all tasks */
|
||||
tcb_add(task);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -169,16 +176,19 @@ int container_init_pagers(struct kernel_resources *kres,
|
||||
{
|
||||
struct container *cont;
|
||||
struct pager *pager;
|
||||
int first = 1;
|
||||
|
||||
list_foreach_struct(cont, &kres->containers.list, list) {
|
||||
for (int i = 0; i < cont->npagers; i++) {
|
||||
pager = &cont->pager[i];
|
||||
|
||||
/* First pager initializes specially */
|
||||
if (i == 0)
|
||||
if (first) {
|
||||
init_pager(pager, cont, current_pgd);
|
||||
else
|
||||
first = 0;
|
||||
} else {
|
||||
init_pager(pager, cont, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -301,6 +301,8 @@ void sched_die_pager(void)
|
||||
*/
|
||||
void sched_die_child(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
/*
|
||||
* Find pager, he _must_ be there because he never
|
||||
* quits before quitting us
|
||||
@@ -308,7 +310,8 @@ void sched_die_child(void)
|
||||
struct ktcb *pager = tcb_find(current->pagerid);
|
||||
|
||||
/* Lock its task_dead queue */
|
||||
mutex_lock(&pager->task_dead.list_lock);
|
||||
if ((err = mutex_lock(&pager->task_dead.list_lock)) < 0)
|
||||
return err;
|
||||
|
||||
/* Remove from container task list,
|
||||
* callers get -ESRCH */
|
||||
@@ -332,7 +335,7 @@ void sched_die_child(void)
|
||||
* Add self to pager's dead tasks list,
|
||||
* to be deleted by pager
|
||||
*/
|
||||
ktcb_list_add(current, &pager->task_dead);
|
||||
__ktcb_list_add_nolock(current, &pager->task_dead);
|
||||
|
||||
/* Now quit the scheduler */
|
||||
preempt_disable();
|
||||
@@ -354,15 +357,20 @@ void sched_die_child(void)
|
||||
* pager can safely delete us
|
||||
*/
|
||||
mutex_unlock(&pager->task_dead.list_lock);
|
||||
schedule();
|
||||
BUG();
|
||||
}
|
||||
|
||||
void sched_die_sync(void)
|
||||
{
|
||||
if (current->tid == current->pagerid)
|
||||
sched_die_pager();
|
||||
else
|
||||
sched_die_child();
|
||||
/*
|
||||
* Infinitely retry if mutexes get interrupted
|
||||
*/
|
||||
while (1)
|
||||
if (current->tid == current->pagerid)
|
||||
sched_die_pager();
|
||||
else
|
||||
sched_die_child();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -68,7 +68,12 @@ void address_space_add(struct address_space *space)
|
||||
void address_space_remove(struct address_space *space)
|
||||
{
|
||||
spin_lock(&curcont->space_list.list_lock);
|
||||
BUG_ON(list_empty(&space->list));
|
||||
|
||||
/*
|
||||
* If current is quitting as the last task of this space,
|
||||
* its tcb may already be removed, and this is fine
|
||||
*/
|
||||
BUG_ON(list_empty(&space->list) && space != current->space);
|
||||
BUG_ON(--curcont->space_list.count < 0);
|
||||
list_remove_init(&space->list);
|
||||
spin_unlock(&curcont->space_list.list_lock);
|
||||
|
||||
@@ -70,7 +70,8 @@ void tcb_delete(struct ktcb *tcb)
|
||||
BUG_ON(tcb->wqh_pager.sleepers > 0);
|
||||
BUG_ON(tcb->wqh_send.sleepers > 0);
|
||||
BUG_ON(tcb->wqh_recv.sleepers > 0);
|
||||
BUG_ON(!list_empty(&tcb->task_list));
|
||||
BUG_ON(!list_empty(&tcb->task_list) &&
|
||||
!(tcb->flags & TASK_EXITING));
|
||||
BUG_ON(!list_empty(&tcb->rq_list) && tcb != current);
|
||||
BUG_ON(tcb->rq && tcb != current);
|
||||
BUG_ON(tcb->nlocks);
|
||||
|
||||
Reference in New Issue
Block a user