Cleanup: use `modprobe --remove` rather than `rmmod`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 15 Sep 2020 16:10:18 +0000 (12:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 27 Nov 2020 15:22:20 +0000 (10:22 -0500)
commitd0e263e7e628d2eba76c883ffc6fb92065e440c7
tree7fec35a586dc8737cfdc0a75ee8dac7e851b9bd7
parent9124c6304bba12b0d4424b4071a25a34445ff4da
Cleanup: use `modprobe --remove` rather than `rmmod`

Background
==========
According to the rmmod(8) man page:
  rmmod is a trivial program to remove a module (when module unloading
  support is provided) from the kernel. Most users will want to use
  modprobe(8) with the -r option instead.

`rmmod` simply unloads the provided module and decrements the refcount
of the modules it depended on but doesn't unload those dependencies if
their refcount is zero.

Issue
=====
With the following scenario we can end up if modules with a zero
refcount still loaded in the kernel:
  modprobe lttng-test
  lttng-sessiond
  ... (test case) ...
  ctrl+c sessiond
  rmmod lttng-test

When we teardown the lttng-sessiond, some modules are kept in the kernel
because the `lttng-test` module depends on them. So unloading
`lttng-test` using `rmmod` keeps those dependencies in the kernel.

Solution
========
Use `modprobe --remove` to unload modules and their now unused
dependencies.

From the modprobe(8) man page:
  -r, --remove
     This option causes modprobe to remove rather than insert a module.
     If the modules it depends on are also unused, modprobe will try to
     remove them too. Unlike insertion, more than one module can be
     specified on the command line

Note
====
This commit also replaces existing uses of `modprobe -r` to `modprobe
--remove` for consistency.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7be83a645097e1eddd478cfbb717906b971f04ea
15 files changed:
tests/destructive/metadata-regeneration
tests/perf/test_perf_raw.in
tests/regression/kernel/test_clock_override
tests/regression/kernel/test_rotation_destroy_flush
tests/regression/tools/clear/test_kernel
tests/regression/tools/filtering/test_valid_filter
tests/regression/tools/metadata/test_kernel
tests/regression/tools/notification/test_notification_kernel
tests/regression/tools/notification/test_notification_multi_app
tests/regression/tools/regen-metadata/test_kernel
tests/regression/tools/regen-statedump/test_kernel
tests/regression/tools/rotation/test_kernel
tests/regression/tools/tracker/test_event_tracker
tests/regression/tools/wildcard/test_event_wildcard
tests/utils/utils.sh
This page took 0.036504 seconds and 4 git commands to generate.