linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] modprobe: don't check refcount with remove command
       [not found] <1367501008-10459-1-git-send-email-johannes@sipsolutions.net>
@ 2013-05-03  2:47 ` Lucas De Marchi
  2013-05-03  6:32   ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas De Marchi @ 2013-05-03  2:47 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-modules, david.spinadel, Johannes Berg

Hi Johannes,

On Thu, May 2, 2013 at 10:23 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> The modprobe.d (5) documentation for the "install" command
> states that you could specify
>
> install fred /sbin/modprobe barney; /sbin/modprobe --ignore-install fred
>
> This makes some sense, but then the loading of "barney" is
> hidden from the user who did only "modprobe fred". Thus,
> it seems it should be possible to be able to unload the
> "fred" module with "modprobe -r fred" by configuring the
> "barney" module to also be removed:
>
> remove fred /sbin/rmmod barney fred
>
> (or similar.)
>
> Make this possible by not checking the refcount when an
> unload command was configured.
>
> Reported-by: David Spinadel <david.spinadel@intel.com>
> ---
>  tools/modprobe.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/modprobe.c b/tools/modprobe.c
> index a053efb..6b34658 100644
> --- a/tools/modprobe.c
> +++ b/tools/modprobe.c
> @@ -386,7 +386,7 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
>                         goto error;
>         }
>
> -       if (!ignore_loaded) {
> +       if (!ignore_loaded && !cmd) {
>                 int usage = kmod_module_get_refcnt(mod);
>
>                 if (usage > 0) {
> --

Thanks, patch has been applied.

However.... I'd like to strongly advise not to use install/remove
commands for simple dependencies like this. It's much simpler and
faster both for kmod and for who is configuring to use softdeps. Your
example could be very well replace with the single line below:

softdep fred pre: barney

I think we need a better explanation on man page and even remove this
example from there. Install/remove commands are only there because of
the legacy stuff that would stop working otherwise.

Anyway... thanks for catching this.

Lucas De Marchi

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] modprobe: don't check refcount with remove command
  2013-05-03  2:47 ` [PATCH] modprobe: don't check refcount with remove command Lucas De Marchi
@ 2013-05-03  6:32   ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2013-05-03  6:32 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-modules, david.spinadel

Hi Lucas,

> Thanks, patch has been applied.

Thanks.

> However.... I'd like to strongly advise not to use install/remove
> commands for simple dependencies like this. It's much simpler and
> faster both for kmod and for who is configuring to use softdeps. Your
> example could be very well replace with the single line below:
> 
> softdep fred pre: barney

Yes, however, I was just copying the man page example for illustration
purposes.

> I think we need a better explanation on man page and even remove this
> example from there. Install/remove commands are only there because of
> the legacy stuff that would stop working otherwise.

Makes sense. However, the use case we have for this is slightly
different, and not a simple dependency -- we have a bit of a reverse
dependency tree:

 modA1 and modA2 depend on modB

However, modB contains the driver struct, so modB is loaded first
automatically and pulls in either modA1 or modA2 depending on some other
information that can't be encoded in direct dependencies. Then, after
having loaded modB, you can't unload modB any more, and David noticed
that a configuration like

remove modB /sbin/rmmod modA1 modA2 modB

(actually it's a bit more complicated, but for no good reason I think)
no longer worked.

johannes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-03  6:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1367501008-10459-1-git-send-email-johannes@sipsolutions.net>
2013-05-03  2:47 ` [PATCH] modprobe: don't check refcount with remove command Lucas De Marchi
2013-05-03  6:32   ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).