The commit "check,common/*: replace module removal with patient module removal" introduced the new helper function _patient_rmmod() which calls modprobe command with --wait option to do patient module removal. However, the modprobe command can return a zero exit status even when the module removal fails. In such cases, the failure remains unreported and hidden. This behavior was observed during the execution of blktests srp test group using rdma_rxe driver on a kernel affected by the rdma_rxe module unload failure bug, which was addressed by the recent patch [1]. To address this problem, check the reference count of the target module after calling the modprobe command in _patient_rmmod(). If the module's reference count indicates a removal failure, print an error message to stderr. While at it, change the print target stream from stdout to stderr for other error messages in _patient_rmmod() to ensure the messages are printed on failure. [1] https://lore.kernel.org/linux-rdma/20251219140408.2300163-1-metze@samba.org/ Signed-off-by: Shin'ichiro Kawasaki --- check | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/check b/check index cd247a0..b554cd0 100755 --- a/check +++ b/check @@ -530,7 +530,10 @@ _patient_rmmod() modprobe --remove --wait="${timeout_ms}" "$module" mod_ret=$? if [[ $mod_ret -ne 0 ]]; then - echo "kmod patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max returned $mod_ret" + echo "kmod patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max returned $mod_ret" >&2 + elif ! _patient_rmmod_check_refcnt "$module_sys"; then + echo "modprobe with --wait option succeeded but still $module has references" >&2 + mod_ret=1 fi return $mod_ret fi @@ -544,7 +547,7 @@ _patient_rmmod() done if [[ $refcnt_is_zero -ne 1 ]]; then - echo "custom patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max" + echo "custom patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max" 2>&1 return 1 fi @@ -575,7 +578,7 @@ _patient_rmmod() done if [[ $mod_ret -ne 0 ]]; then - echo "custom patient module removal for $module timed out trying to remove using timeout of $max_tries_max last try returned $mod_ret" + echo "custom patient module removal for $module timed out trying to remove using timeout of $max_tries_max last try returned $mod_ret" 2>&1 fi return $mod_ret -- 2.52.0