Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: module auto-unload

On Sun, 15 Dec 2013, Christos Zoulas wrote:

+       if (t < 0)
+               return (EINVAL);

You are not allowing it to become negative.

 *      Automatically unload modules.  We try once to unload autoloaded
 *      modules after module_autotime seconds.  If the system is under
- *     severe memory pressure, we'll try unloading all modules.
+ *     severe memory pressure, we'll try unloading all modules, else if
+ *     module_autotime is non-positive, we don't try to unload.
static void
module_thread(void *cookie)
@@ -1311,6 +1341,8 @@ module_thread(void *cookie)

                        if ( < uvmexp.freemin) {
                                module_thread_ticks = hz;
+                       } else if (module_autotime <= 0) {
+                               continue;

Yet, you add a check for it. I would just not add the two lines above,
and have only 0 mean "never unload"

Yes, this check could be simply == instead of <=

I left this check here, though, so it would not auto-unload any modules that were loaded before setting module_autotime to 0. In other words,

        T=0    module_autotime == 10 (the default)
        T=1    X is autoloaded, and is scheduled for auto-unload
        T=2    module_autotime is set to 0
        T=3    module_thread() kicks in and unloads X

With the check-for-0 in module_thread() we avoid this unload. I could live with it either way, but it seemed more logical to me to avoid all auto-unloads as soon as the time-out was set to zero, rather than only avoiding timeouts for modules that were loaded after the set-to-zero.

I have just completed testing this change, and it seems to work just fine, at least on my amd64 systems. Is there any reason why these changes should not be committed?

| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at |
| Kernel Developer |                          | pgoyette at  |

Home | Main Index | Thread Index | Old Index