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:53 +0000 (10:22 -0500)
commitd267104b87f12ea8f0bf73bff1af272f98dc069e
tree5236ca673a302081ba7707c08eb2c2a49a92aeb5
parentfd5f40473396e65ca78a6806c269b7b4604803eb
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.028291 seconds and 4 git commands to generate.