Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1538882

Re: [RFC 04/10] kmod: provide wrappers for kmod_concurrent inc/dec

From "Luis R. Rodriguez" <mcgrof@kernel.org>
Newsgroups linux.kernel
Subject Re: [RFC 04/10] kmod: provide wrappers for kmod_concurrent inc/dec
Date 2016-12-08 22:10 +0100
Message-ID <sMe70-2Kc-15@gated-at.bofh.it> (permalink)
References <sMbVv-188-1@gated-at.bofh.it> <sMcRA-1I2-21@gated-at.bofh.it> <sMdDX-2iT-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Dec 08, 2016 at 12:29:42PM -0800, Kees Cook wrote:
> On Thu, Dec 8, 2016 at 11:48 AM, Luis R. Rodriguez <mcgrof@kernel.org> wrote:
> > kmod_concurrent is used as an atomic counter for enabling
> > the allowed limit of modprobe calls, provide wrappers for it
> > to enable this to be expanded on more easily. This will be done
> > later.
> >
> > Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
> > ---
> >  kernel/kmod.c | 27 +++++++++++++++++++++------
> >  1 file changed, 21 insertions(+), 6 deletions(-)
> >
> > diff --git a/kernel/kmod.c b/kernel/kmod.c
> > index cb6f7ca7b8a5..049d7eabda38 100644
> > --- a/kernel/kmod.c
> > +++ b/kernel/kmod.c
> > @@ -44,6 +44,9 @@
> >  #include <trace/events/module.h>
> >
> >  extern int max_threads;
> > +
> > +static atomic_t kmod_concurrent = ATOMIC_INIT(0);
> > +
> >  unsigned int max_modprobes;
> >  module_param(max_modprobes, uint, 0644);
> >  MODULE_PARM_DESC(max_modprobes, "Max number of allowed concurrent modprobes");
> > @@ -108,6 +111,20 @@ static int call_modprobe(char *module_name, int wait)
> >         return -ENOMEM;
> >  }
> >
> > +static int kmod_umh_threads_get(void)
> > +{
> > +       atomic_inc(&kmod_concurrent);
> > +       if (atomic_read(&kmod_concurrent) < max_modprobes)
> > +               return 0;
> > +       atomic_dec(&kmod_concurrent);
> > +       return -ENOMEM;
> > +}
> > +
> > +static void kmod_umh_threads_put(void)
> > +{
> > +       atomic_dec(&kmod_concurrent);
> > +}
> 
> Can you use a kref here instead? We're trying to kill raw use of
> atomic_t for reference counting...

That's a much broader functional change than I was looking for, but I am up for
it. Can you describe the benefit of using kref you expect or why this is an
ongoing crusade? Since its a larger functional change how about doing this
change later, and we can test impact with the tress test driver. In theory if
there are benefits can't we add a test case to prove the gains?

  Luis

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 00/10] kmod: stress test driver, few fixes and enhancements "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 19:50 +0100
  [RFC 02/10] module: fix memory leak on early load_module() failures "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
    Re: [RFC 02/10] module: fix memory leak on early load_module() failures Kees Cook <keescook@chromium.org> - 2016-12-08 21:40 +0100
      Re: [RFC 02/10] module: fix memory leak on early load_module() failures "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 22:20 +0100
        Re: [RFC 02/10] module: fix memory leak on early load_module() failures Kees Cook <keescook@chromium.org> - 2016-12-08 22:20 +0100
    Re: [RFC 02/10] module: fix memory leak on early load_module()  failures Miroslav Benes <mbenes@suse.cz> - 2016-12-09 18:10 +0100
  [RFC 08/10] sysctl: add support for unsigned int properly "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
  [RFC 05/10] kmod: return -EBUSY if modprobe limit is reached "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
  [RFC 07/10] kmod: use simplified rate limit printk "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
  [RFC 04/10] kmod: provide wrappers for kmod_concurrent inc/dec "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
    Re: [RFC 04/10] kmod: provide wrappers for kmod_concurrent inc/dec Kees Cook <keescook@chromium.org> - 2016-12-08 21:40 +0100
      Re: [RFC 04/10] kmod: provide wrappers for kmod_concurrent inc/dec "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 22:10 +0100
  [RFC 06/10] kmod: provide sanity check on kmod_concurrent access "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
  [RFC 10/10] kmod: add a sanity check on module loading "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
    Re: [RFC 10/10] kmod: add a sanity check on module loading Martin Wilck <mwilck@suse.com> - 2016-12-09 21:10 +0100
      Re: [RFC 10/10] kmod: add a sanity check on module loading Linus Torvalds <torvalds@linux-foundation.org> - 2016-12-09 22:00 +0100
  [RFC 03/10] kmod: add dynamic max concurrent thread count "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100
    Re: [RFC 03/10] kmod: add dynamic max concurrent thread count Kees Cook <keescook@chromium.org> - 2016-12-08 21:30 +0100
      Re: [RFC 03/10] kmod: add dynamic max concurrent thread count "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 22:10 +0100
  [RFC 09/10] kmod: add helpers for getting kmod count and limit "Luis R. Rodriguez" <mcgrof@kernel.org> - 2016-12-08 20:50 +0100

csiph-web