Skip to content

Commit

Permalink
taskq - Make consumer tasks MPALMOSTSAFE
Browse files Browse the repository at this point in the history
* All consumers of taskqueue_thread[cpu] have to be at least
  MPALMOSTSAFE as they won't be called with the mplock held.
  • Loading branch information
bwalex committed Oct 2, 2009
1 parent 5c62729 commit 227ce82
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions sys/bus/cam/cam_xpt.c
Expand Up @@ -2932,6 +2932,7 @@ xpt_action_sasync_cb(void *context, int pending)
struct xpt_task *task;
uint32_t added;

get_mplock();
task = (struct xpt_task *)context;
cur_entry = (struct async_node *)task->data1;
added = task->data2;
Expand All @@ -2951,6 +2952,7 @@ xpt_action_sasync_cb(void *context, int pending)
xpt_for_all_busses(xptsetasyncbusfunc, cur_entry);
}

rel_mplock();
kfree(task, M_CAMXPT);
}

Expand Down Expand Up @@ -7042,6 +7044,7 @@ xpt_finishconfig_task(void *context, int pending)
struct periph_driver **p_drv;
int i;

get_mplock();
kprintf("CAM: finished configuring all busses (%d left)\n",
busses_to_config);

Expand All @@ -7066,6 +7069,7 @@ xpt_finishconfig_task(void *context, int pending)
xsoftc.xpt_config_hook = NULL;
}

rel_mplock();
kfree(context, M_CAMXPT);
}

Expand Down
7 changes: 6 additions & 1 deletion sys/bus/cam/scsi/scsi_cd.c
Expand Up @@ -586,9 +586,12 @@ cdsysctlinit(void *context, int pending)
struct cd_softc *softc;
char tmpstr[80], tmpstr2[80];

get_mplock();
periph = (struct cam_periph *)context;
if (cam_periph_acquire(periph) != CAM_REQ_CMP)
if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
rel_mplock();
return;
}

softc = (struct cd_softc *)periph->softc;
ksnprintf(tmpstr, sizeof(tmpstr), "CAM CD unit %d", periph->unit_number);
Expand All @@ -603,6 +606,7 @@ cdsysctlinit(void *context, int pending)
if (softc->sysctl_tree == NULL) {
kprintf("cdsysctlinit: unable to allocate sysctl tree\n");
cam_periph_release(periph);
rel_mplock();
return;
}

Expand All @@ -616,6 +620,7 @@ cdsysctlinit(void *context, int pending)
"Minimum CDB size");

cam_periph_release(periph);
rel_mplock();
}

/*
Expand Down
7 changes: 6 additions & 1 deletion sys/bus/cam/scsi/scsi_da.c
Expand Up @@ -945,9 +945,12 @@ dasysctlinit(void *context, int pending)
struct da_softc *softc;
char tmpstr[80], tmpstr2[80];

get_mplock();
periph = (struct cam_periph *)context;
if (cam_periph_acquire(periph) != CAM_REQ_CMP)
if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
rel_mplock();
return;
}

softc = (struct da_softc *)periph->softc;
ksnprintf(tmpstr, sizeof(tmpstr), "CAM DA unit %d", periph->unit_number);
Expand All @@ -961,6 +964,7 @@ dasysctlinit(void *context, int pending)
if (softc->sysctl_tree == NULL) {
kprintf("dasysctlinit: unable to allocate sysctl tree\n");
cam_periph_release(periph);
rel_mplock();
return;
}

Expand All @@ -974,6 +978,7 @@ dasysctlinit(void *context, int pending)
"Minimum CDB size");

cam_periph_release(periph);
rel_mplock();
}

static int
Expand Down
2 changes: 2 additions & 0 deletions sys/kern/kern_exit.c
Expand Up @@ -944,10 +944,12 @@ reaplwps(void *context, int dummy)
struct lwplist *lwplist = context;
struct lwp *lp;

get_mplock();
while ((lp = LIST_FIRST(lwplist))) {
LIST_REMOVE(lp, u.lwp_reap_entry);
reaplwp(lp);
}
rel_mplock();
}

static void
Expand Down

0 comments on commit 227ce82

Please sign in to comment.