Lines 1166-1172
Link Here
|
1166 |
struct callout_cpu *cc, *old_cc; |
1166 |
struct callout_cpu *cc, *old_cc; |
1167 |
struct lock_class *class; |
1167 |
struct lock_class *class; |
1168 |
int direct, sq_locked, use_lock; |
1168 |
int direct, sq_locked, use_lock; |
1169 |
int cancelled, not_on_a_list; |
1169 |
int not_on_a_list; |
1170 |
|
1170 |
|
1171 |
if ((flags & CS_DRAIN) != 0) |
1171 |
if ((flags & CS_DRAIN) != 0) |
1172 |
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock, |
1172 |
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock, |
Lines 1236-1249
Link Here
|
1236 |
} |
1236 |
} |
1237 |
|
1237 |
|
1238 |
/* |
1238 |
/* |
1239 |
* If the callout is running, try to stop it or drain it. |
1239 |
* If the callout isn't pending, it's not on the queue, so |
|
|
1240 |
* don't attempt to remove it from the queue. We can try to |
1241 |
* stop it by other means however. |
1240 |
*/ |
1242 |
*/ |
1241 |
if (cc_exec_curr(cc, direct) == c) { |
1243 |
if (!(c->c_iflags & CALLOUT_PENDING)) { |
1242 |
/* |
1244 |
/* |
1243 |
* Succeed we to stop it or not, we must clear the |
1245 |
* If it wasn't on the queue and it isn't the current |
1244 |
* active flag - this is what API users expect. |
1246 |
* callout, then we can't stop it, so just bail. |
|
|
1247 |
* It probably has already been run (if locking |
1248 |
* is properly done). You could get here if the caller |
1249 |
* calls stop twice in a row for example. The second |
1250 |
* call would fall here without CALLOUT_ACTIVE set. |
1245 |
*/ |
1251 |
*/ |
1246 |
c->c_flags &= ~CALLOUT_ACTIVE; |
1252 |
c->c_flags &= ~CALLOUT_ACTIVE; |
|
|
1253 |
if (cc_exec_curr(cc, direct) != c) { |
1254 |
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", |
1255 |
c, c->c_func, c->c_arg); |
1256 |
CC_UNLOCK(cc); |
1257 |
if (sq_locked) |
1258 |
sleepq_release(&cc_exec_waiting(cc, direct)); |
1259 |
return (-1); |
1260 |
} |
1247 |
|
1261 |
|
1248 |
if ((flags & CS_DRAIN) != 0) { |
1262 |
if ((flags & CS_DRAIN) != 0) { |
1249 |
/* |
1263 |
/* |
Lines 1362-1368
Link Here
|
1362 |
cc_exec_drain(cc, direct) = drain; |
1376 |
cc_exec_drain(cc, direct) = drain; |
1363 |
} |
1377 |
} |
1364 |
CC_UNLOCK(cc); |
1378 |
CC_UNLOCK(cc); |
1365 |
return ((flags & CS_EXECUTING) != 0); |
1379 |
return ((flags & CS_MIGRBLOCK) != 0); |
1366 |
} |
1380 |
} |
1367 |
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", |
1381 |
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", |
1368 |
c, c->c_func, c->c_arg); |
1382 |
c, c->c_func, c->c_arg); |
Lines 1369-1389
Link Here
|
1369 |
if (drain) { |
1383 |
if (drain) { |
1370 |
cc_exec_drain(cc, direct) = drain; |
1384 |
cc_exec_drain(cc, direct) = drain; |
1371 |
} |
1385 |
} |
|
|
1386 |
CC_UNLOCK(cc); |
1372 |
KASSERT(!sq_locked, ("sleepqueue chain still locked")); |
1387 |
KASSERT(!sq_locked, ("sleepqueue chain still locked")); |
1373 |
cancelled = ((flags & CS_EXECUTING) != 0); |
1388 |
return (0); |
1374 |
} else |
1389 |
} |
1375 |
cancelled = 1; |
|
|
1376 |
|
1377 |
if (sq_locked) |
1390 |
if (sq_locked) |
1378 |
sleepq_release(&cc_exec_waiting(cc, direct)); |
1391 |
sleepq_release(&cc_exec_waiting(cc, direct)); |
1379 |
|
1392 |
|
1380 |
if ((c->c_iflags & CALLOUT_PENDING) == 0) { |
|
|
1381 |
CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", |
1382 |
c, c->c_func, c->c_arg); |
1383 |
CC_UNLOCK(cc); |
1384 |
return (cancelled); |
1385 |
} |
1386 |
|
1387 |
c->c_iflags &= ~CALLOUT_PENDING; |
1393 |
c->c_iflags &= ~CALLOUT_PENDING; |
1388 |
c->c_flags &= ~CALLOUT_ACTIVE; |
1394 |
c->c_flags &= ~CALLOUT_ACTIVE; |
1389 |
|
1395 |
|
Lines 1400-1406
Link Here
|
1400 |
} |
1406 |
} |
1401 |
callout_cc_del(c, cc); |
1407 |
callout_cc_del(c, cc); |
1402 |
CC_UNLOCK(cc); |
1408 |
CC_UNLOCK(cc); |
1403 |
return (cancelled); |
1409 |
return (1); |
1404 |
} |
1410 |
} |
1405 |
|
1411 |
|
1406 |
void |
1412 |
void |