mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Replace cv_{timed}wait_sig with cv_{timed}wait_idle where appropriate
There are a number of places where cv_?_sig is used simply for accounting purposes but the surrounding code has no ability to cope with actually receiving a signal. On FreeBSD it is possible to send signals to individual kernel threads so this could enable undesirable behavior. This patch adds routines on Linux that will do the same idle accounting as _sig without making the task interruptible. On FreeBSD cv_*_idle are all aliases for cv_* Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Matt Macy <mmacy@FreeBSD.org> Closes #10843
This commit is contained in:
committed by
Brian Behlendorf
parent
fd20a81b9a
commit
36f36610c3
+1
-1
@@ -9174,7 +9174,7 @@ l2arc_feed_thread(void *unused)
|
||||
cookie = spl_fstrans_mark();
|
||||
while (l2arc_thread_exit == 0) {
|
||||
CALLB_CPR_SAFE_BEGIN(&cpr);
|
||||
(void) cv_timedwait_sig(&l2arc_feed_thr_cv,
|
||||
(void) cv_timedwait_idle(&l2arc_feed_thr_cv,
|
||||
&l2arc_feed_thr_lock, next);
|
||||
CALLB_CPR_SAFE_END(&cpr, &l2arc_feed_thr_lock);
|
||||
next = ddi_get_lbolt() + hz;
|
||||
|
||||
+1
-1
@@ -718,7 +718,7 @@ dbuf_evict_thread(void *unused)
|
||||
while (!dbuf_evict_thread_exit) {
|
||||
while (!dbuf_cache_above_lowater() && !dbuf_evict_thread_exit) {
|
||||
CALLB_CPR_SAFE_BEGIN(&cpr);
|
||||
(void) cv_timedwait_sig_hires(&dbuf_evict_cv,
|
||||
(void) cv_timedwait_idle_hires(&dbuf_evict_cv,
|
||||
&dbuf_evict_lock, SEC2NSEC(1), MSEC2NSEC(1), 0);
|
||||
CALLB_CPR_SAFE_END(&cpr, &dbuf_evict_lock);
|
||||
}
|
||||
|
||||
+1
-1
@@ -671,7 +671,7 @@ mmp_thread(void *arg)
|
||||
}
|
||||
|
||||
CALLB_CPR_SAFE_BEGIN(&cpr);
|
||||
(void) cv_timedwait_sig_hires(&mmp->mmp_thread_cv,
|
||||
(void) cv_timedwait_idle_hires(&mmp->mmp_thread_cv,
|
||||
&mmp->mmp_thread_lock, next_time, USEC2NSEC(100),
|
||||
CALLOUT_FLAG_ABSOLUTE);
|
||||
CALLB_CPR_SAFE_END(&cpr, &mmp->mmp_thread_lock);
|
||||
|
||||
+4
-8
@@ -242,16 +242,11 @@ txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, clock_t time)
|
||||
{
|
||||
CALLB_CPR_SAFE_BEGIN(cpr);
|
||||
|
||||
/*
|
||||
* cv_wait_sig() is used instead of cv_wait() in order to prevent
|
||||
* this process from incorrectly contributing to the system load
|
||||
* average when idle.
|
||||
*/
|
||||
if (time) {
|
||||
(void) cv_timedwait_sig(cv, &tx->tx_sync_lock,
|
||||
(void) cv_timedwait_idle(cv, &tx->tx_sync_lock,
|
||||
ddi_get_lbolt() + time);
|
||||
} else {
|
||||
cv_wait_sig(cv, &tx->tx_sync_lock);
|
||||
cv_wait_idle(cv, &tx->tx_sync_lock);
|
||||
}
|
||||
|
||||
CALLB_CPR_SAFE_END(cpr, &tx->tx_sync_lock);
|
||||
@@ -760,7 +755,8 @@ txg_wait_open(dsl_pool_t *dp, uint64_t txg, boolean_t should_quiesce)
|
||||
if (should_quiesce == B_TRUE) {
|
||||
cv_wait_io(&tx->tx_quiesce_done_cv, &tx->tx_sync_lock);
|
||||
} else {
|
||||
cv_wait_sig(&tx->tx_quiesce_done_cv, &tx->tx_sync_lock);
|
||||
cv_wait_idle(&tx->tx_quiesce_done_cv,
|
||||
&tx->tx_sync_lock);
|
||||
}
|
||||
}
|
||||
mutex_exit(&tx->tx_sync_lock);
|
||||
|
||||
@@ -481,7 +481,7 @@ vdev_trim_range(trim_args_t *ta, uint64_t start, uint64_t size)
|
||||
if (ta->trim_type == TRIM_TYPE_MANUAL) {
|
||||
while (vd->vdev_trim_rate != 0 && !vdev_trim_should_stop(vd) &&
|
||||
vdev_trim_calculate_rate(ta) > vd->vdev_trim_rate) {
|
||||
cv_timedwait_sig(&vd->vdev_trim_io_cv,
|
||||
cv_timedwait_idle(&vd->vdev_trim_io_cv,
|
||||
&vd->vdev_trim_io_lock, ddi_get_lbolt() +
|
||||
MSEC_TO_TICK(10));
|
||||
}
|
||||
|
||||
+2
-7
@@ -237,15 +237,10 @@ zthr_procedure(void *arg)
|
||||
t->zthr_func(t->zthr_arg, t);
|
||||
mutex_enter(&t->zthr_state_lock);
|
||||
} else {
|
||||
/*
|
||||
* cv_wait_sig() is used instead of cv_wait() in
|
||||
* order to prevent this process from incorrectly
|
||||
* contributing to the system load average when idle.
|
||||
*/
|
||||
if (t->zthr_sleep_timeout == 0) {
|
||||
cv_wait_sig(&t->zthr_cv, &t->zthr_state_lock);
|
||||
cv_wait_idle(&t->zthr_cv, &t->zthr_state_lock);
|
||||
} else {
|
||||
(void) cv_timedwait_sig_hires(&t->zthr_cv,
|
||||
(void) cv_timedwait_idle_hires(&t->zthr_cv,
|
||||
&t->zthr_state_lock, t->zthr_sleep_timeout,
|
||||
MSEC2NSEC(1), 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user