Keep trying to remove the module if it's failing with EAGAIN. This is an alternative to v1: https://lore.kernel.org/linux-modules/20210803202417.462197-1-mcgrof@xxxxxxxxxx/ v2: https://lore.kernel.org/linux-modules/20210810051602.3067384-1-mcgrof@xxxxxxxxxx/ The v2 above or variand thereof would be probably a better way, but unfortunately we can't poll the refcnt file in sysfs to get notified when it reaches 0. The alternative in v1, with sleep(), uses an arbitrary interval/maximum. It's not something I'm very confortable to add to the library side. So, add a quick implementation in modprobe to allow it to remove the module and wait up until a maximum timeout. Intention is to later migrate part of the logic in modprobe to libkmod, including for example the holders removal recently fixed. Lucas De Marchi (8): modprobe: Move -R to "Query options" libkmod: Allow to ignore log message on module removal module-playground: Add debugfs entry in mod-simple util: Add time-related functions from testsuite util: Add msec variants for time-related functions util: Add exponential backoff sleep testsuite: Add tests for sleep calculation modprobe: Add --wait libkmod/libkmod-module.c | 13 ++-- libkmod/libkmod.h | 2 + man/modprobe.xml | 17 ++++++ shared/util.c | 72 ++++++++++++++++++++++ shared/util.h | 17 ++++++ testsuite/module-playground/mod-simple.c | 18 +++++- testsuite/test-util.c | 41 +++++++++++++ testsuite/testsuite.c | 14 +---- tools/modprobe.c | 76 ++++++++++++++++++++---- 9 files changed, 240 insertions(+), 30 deletions(-) -- 2.36.1