1. 21 Dec, 2017 1 commit
  2. 07 Dec, 2017 2 commits
    • Greg Kroah-Hartman's avatar
      kobject: Remove redundant license text · 045c5f75
      Greg Kroah-Hartman authored
      Now that the SPDX tag is in all kobject files, that identifies the
      license in a specific and legally-defined manner.  So the extra GPL text
      wording can be removed as it is no longer needed at all.
      This is done on a quest to remove the 700+ different ways that files in
      the kernel describe the GPL license text.  And there's unneeded stuff
      like the address (sometimes incorrect) for the FSF which is never
      No copyright headers or other non-license-description text was removed.
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Greg Kroah-Hartman's avatar
      kobject: add SPDX identifiers to all kobject files · d9d16e16
      Greg Kroah-Hartman authored
      It's good to have SPDX identifiers in all files to make it easier to
      audit the kernel tree for correct licenses.
      Update the kobject files files with the correct SPDX license identifier
      based on the license text in the file itself.  The SPDX identifier is a
      legally binding shorthand, which can be used instead of the full boiler
      plate text.
      This work is based on a script and data from Thomas Gleixner, Philippe
      Ombredanne, and Kate Stewart.
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  3. 19 Sep, 2017 3 commits
    • Eric Dumazet's avatar
      kobject: factorize skb setup in kobject_uevent_net_broadcast() · d464e84e
      Eric Dumazet authored
      We can build one skb and let it be cloned in netlink.
      This is much faster, and use less memory (all clones will
      share the same skb->head)
      time perf record (for f in `seq 1 3000` ; do ip netns add tast$f; done)
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 4.110 MB perf.data (~179584 samples) ]
      real    0m24.227s # instead of 0m52.554s
      user    0m0.329s
      sys 0m23.753s # instead of 0m51.375s
          14.77%       ip  [kernel.kallsyms]  [k] __ip6addrlbl_add
          14.56%       ip  [kernel.kallsyms]  [k] netlink_broadcast_filtered
          11.65%       ip  [kernel.kallsyms]  [k] netlink_has_listeners
           6.19%       ip  [kernel.kallsyms]  [k] _raw_spin_lock_irqsave
           5.66%       ip  [kernel.kallsyms]  [k] kobject_uevent_env
           4.97%       ip  [kernel.kallsyms]  [k] memset_erms
           4.67%       ip  [kernel.kallsyms]  [k] refcount_sub_and_test
           4.41%       ip  [kernel.kallsyms]  [k] _raw_read_lock
           3.59%       ip  [kernel.kallsyms]  [k] refcount_inc_not_zero
           3.13%       ip  [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore
           1.55%       ip  [kernel.kallsyms]  [k] __wake_up
           1.20%       ip  [kernel.kallsyms]  [k] strlen
           1.03%       ip  [kernel.kallsyms]  [k] __wake_up_common
           0.93%       ip  [kernel.kallsyms]  [k] consume_skb
           0.92%       ip  [kernel.kallsyms]  [k] netlink_trim
           0.87%       ip  [kernel.kallsyms]  [k] insert_header
           0.63%       ip  [kernel.kallsyms]  [k] unmap_page_range
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    • Eric Dumazet's avatar
      kobject: copy env blob in one go · 4a336a23
      Eric Dumazet authored
      No need to iterate over strings, just copy in one efficient memcpy() call.
      time perf record "(for f in `seq 1 3000` ; do ip netns add tast$f; done)"
      [ perf record: Woken up 10 times to write data ]
      [ perf record: Captured and wrote 8.224 MB perf.data (~359301 samples) ]
      real    0m52.554s  # instead of 1m7.492s
      user    0m0.309s
      sys 0m51.375s # instead of 1m6.875s
           9.88%       ip  [kernel.kallsyms]  [k] netlink_broadcast_filtered
           8.86%       ip  [kernel.kallsyms]  [k] string
           7.37%       ip  [kernel.kallsyms]  [k] __ip6addrlbl_add
           5.68%       ip  [kernel.kallsyms]  [k] netlink_has_listeners
           5.52%       ip  [kernel.kallsyms]  [k] memcpy_erms
           4.76%       ip  [kernel.kallsyms]  [k] __alloc_skb
           4.54%       ip  [kernel.kallsyms]  [k] vsnprintf
           3.94%       ip  [kernel.kallsyms]  [k] format_decode
           3.80%       ip  [kernel.kallsyms]  [k] kmem_cache_alloc_node_trace
           3.71%       ip  [kernel.kallsyms]  [k] kmem_cache_alloc_node
           3.66%       ip  [kernel.kallsyms]  [k] kobject_uevent_env
           3.38%       ip  [kernel.kallsyms]  [k] strlen
           2.65%       ip  [kernel.kallsyms]  [k] _raw_spin_lock_irqsave
           2.20%       ip  [kernel.kallsyms]  [k] kfree
           2.09%       ip  [kernel.kallsyms]  [k] memset_erms
           2.07%       ip  [kernel.kallsyms]  [k] ___cache_free
           1.95%       ip  [kernel.kallsyms]  [k] kmem_cache_free
           1.91%       ip  [kernel.kallsyms]  [k] _raw_read_lock
           1.45%       ip  [kernel.kallsyms]  [k] ksize
           1.25%       ip  [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore
           1.00%       ip  [kernel.kallsyms]  [k] widen_string
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    • Eric Dumazet's avatar
      kobject: add kobject_uevent_net_broadcast() · 16dff336
      Eric Dumazet authored
      This removes some #ifdef pollution and will ease follow up patches.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  4. 18 Sep, 2017 1 commit
  5. 22 Jul, 2017 1 commit
    • Dmitry Torokhov's avatar
      driver core: emit uevents when device is bound to a driver · 1455cf8d
      Dmitry Torokhov authored
      There are certain touch controllers that may come up in either normal
      (application) or boot mode, depending on whether firmware/configuration is
      corrupted when they are powered on. In boot mode the kernel does not create
      input device instance (because it does not necessarily know the
      characteristics of the input device in question).
      Another number of controllers does not store firmware in a non-volatile
      memory, and they similarly need to have firmware loaded before input device
      instance is created. There are also other types of devices with similar
      There is a desire to be able to trigger firmware loading via udev, but it
      has to happen only when driver is bound to a physical device (i2c or spi).
      These udev actions can not use ADD events, as those happen too early, so we
      are introducing BIND and UNBIND events that are emitted at the right
      Also, many drivers create additional driver-specific device attributes
      when binding to the device, to provide userspace with additional controls.
      The new events allow userspace to adjust these driver-specific attributes
      without worrying that they are not there yet.
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  6. 25 May, 2017 1 commit
    • Peter Rajnoha's avatar
      kobject: support passing in variables for synthetic uevents · f36776fa
      Peter Rajnoha authored
      This patch makes it possible to pass additional arguments in addition
      to uevent action name when writing /sys/.../uevent attribute. These
      additional arguments are then inserted into generated synthetic uevent
      as additional environment variables.
      Before, we were not able to pass any additional uevent environment
      variables for synthetic uevents. This made it hard to identify such uevents
      properly in userspace to make proper distinction between genuine uevents
      originating from kernel and synthetic uevents triggered from userspace.
      Also, it was not possible to pass any additional information which would
      make it possible to optimize and change the way the synthetic uevents are
      processed back in userspace based on the originating environment of the
      triggering action in userspace. With the extra additional variables, we are
      able to pass through this extra information needed and also it makes it
      possible to synchronize with such synthetic uevents as they can be clearly
      identified back in userspace.
      The format for writing the uevent attribute is following:
          ACTION [UUID [KEY=VALUE ...]
      There's no change in how "ACTION" is recognized - it stays the same
      ("add", "change", "remove"). The "ACTION" is the only argument required
      to generate synthetic uevent, the rest of arguments, that this patch
      adds support for, are optional.
      The "UUID" is considered as transaction identifier so it's possible to
      use the same UUID value for one or more synthetic uevents in which case
      we logically group these uevents together for any userspace listeners.
      The "UUID" is expected to be in "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      format where "x" is a hex digit. The value appears in uevent as
      "SYNTH_UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" environment variable.
      The "KEY=VALUE" pairs can contain alphanumeric characters only. It's
      possible to define zero or more more pairs - each pair is then delimited
      by a space character " ". Each pair appears in synthetic uevents as
      "SYNTH_ARG_KEY=VALUE" environment variable. That means the KEY name gains
      "SYNTH_ARG_" prefix to avoid possible collisions with existing variables.
      To pass the "KEY=VALUE" pairs, it's also required to pass in the "UUID"
      part for the synthetic uevent first.
      If "UUID" is not passed in, the generated synthetic uevent gains
      "SYNTH_UUID=0" environment variable automatically so it's possible to
      identify this situation in userspace when reading generated uevent and so
      we can still make a difference between genuine and synthetic uevents.
      Signed-off-by: default avatarPeter Rajnoha <prajnoha@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  7. 28 Oct, 2016 1 commit
  8. 13 Feb, 2015 1 commit
  9. 25 Apr, 2014 1 commit
  10. 03 Apr, 2014 1 commit
    • Vladimir Davydov's avatar
      kobject: don't block for each kobject_uevent · bcccff93
      Vladimir Davydov authored
      Currently kobject_uevent has somewhat unpredictable semantics.  The
      point is, since it may call a usermode helper and wait for it to execute
      (UMH_WAIT_EXEC), it is impossible to say for sure what lock dependencies
      it will introduce for the caller - strictly speaking it depends on what
      fs the binary is located on and the set of locks fork may take.  There
      are quite a few kobject_uevent's users that do not take this into
      account and call it with various mutexes taken, e.g.  rtnl_mutex,
      net_mutex, which might potentially lead to a deadlock.
      Since there is actually no reason to wait for the usermode helper to
      execute there, let's make kobject_uevent start the helper asynchronously
      with the aid of the UMH_NO_WAIT flag.
      Personally, I'm interested in this, because I really want kobject_uevent
      to be called under the slab_mutex in the slub implementation as it used
      to be some time ago, because it greatly simplifies synchronization and
      automatically fixes a kmemcg-related race.  However, there was a
      deadlock detected on an attempt to call kobject_uevent under the
      slab_mutex (see https://lkml.org/lkml/2012/1/14/45), which was reported
      to be fixed by releasing the slab_mutex for kobject_uevent.
      Unfortunately, there was no information about who exactly blocked on the
      slab_mutex causing the usermode helper to stall, neither have I managed
      to find this out or reproduce the issue.
      BTW, this is not the first attempt to make kobject_uevent use
      UMH_NO_WAIT.  Previous one was made by commit f520360d ("kobject:
      don't block for each kobject_uevent"), but it was wrong (it passed
      arguments allocated on stack to async thread) so it was reverted in
      05f54c13 ("Revert "kobject: don't block for each kobject_uevent".").
      It targeted on speeding up the boot process though.
      Signed-off-by: default avatarVladimir Davydov <vdavydov@parallels.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  11. 20 Jan, 2014 1 commit
  12. 08 Sep, 2012 2 commits
  13. 29 Jun, 2012 1 commit
    • Pablo Neira Ayuso's avatar
      netlink: add netlink_kernel_cfg parameter to netlink_kernel_create · a31f2d17
      Pablo Neira Ayuso authored
      This patch adds the following structure:
      struct netlink_kernel_cfg {
              unsigned int    groups;
              void            (*input)(struct sk_buff *skb);
              struct mutex    *cb_mutex;
      That can be passed to netlink_kernel_create to set optional configurations
      for netlink kernel sockets.
      I've populated this structure by looking for NULL and zero parameters at the
      existing code. The remaining parameters that always need to be set are still
      left in the original interface.
      That includes optional parameters for the netlink socket creation. This allows
      easy extensibility of this interface in the future.
      This patch also adapts all callers to use this new interface.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  14. 08 Mar, 2012 1 commit
  15. 07 Mar, 2012 1 commit
  16. 10 Dec, 2011 1 commit
  17. 23 Aug, 2011 1 commit
  18. 24 Aug, 2010 1 commit
  19. 04 Jun, 2010 2 commits
  20. 21 May, 2010 3 commits
  21. 30 Mar, 2010 1 commit
    • Tejun Heo's avatar
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo authored
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      The script does the followings.
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
      The conversion was done in the following steps.
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
      6. percpu.h was updated not to include slab.h.
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Guess-its-ok-by: default avatarChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
  22. 08 Mar, 2010 1 commit
    • Emese Revfy's avatar
      kobject: Constify struct kset_uevent_ops · 9cd43611
      Emese Revfy authored
      Constify struct kset_uevent_ops.
      This is part of the ops structure constification
      effort started by Arjan van de Ven et al.
      Benefits of this constification:
       * prevents modification of data that is shared
         (referenced) by many other structure instances
         at runtime
       * detects/prevents accidental (but not intentional)
         modification attempts on archs that enforce
         read-only kernel data at runtime
       * potentially better optimized code as the compiler
         can assume that the const data cannot be changed
       * the compiler/linker move const data into .rodata
         and therefore exclude them from false sharing
      Signed-off-by: default avatarEmese Revfy <re.emese@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
  23. 16 Apr, 2009 2 commits
  24. 24 Mar, 2009 2 commits
    • Arjan van de Ven's avatar
      kobject: don't block for each kobject_uevent · f520360d
      Arjan van de Ven authored
      Right now, the kobject_uevent code blocks for each uevent that's being
      generated, due to using (for hystoric reasons) UHM_WAIT_EXEC as flag to
      call_usermode_helper().  Specifically, the effect is that each uevent
      that is being sent causes the code to wake up keventd, then block until
      keventd has processed the work. Needless to say, this happens many times
      during the system boot.
      This patches changes that to UHN_NO_WAIT (brilliant name for a constant
      btw) so that we only schedule the work to fire the uevent message, but
      do not wait for keventd to process the work.
      This removes one of the bottlenecks during boot; each one of them is
      only a small effect, but the sum of them does add up.
      [Note, distros that need this are broken, they should be setting
      CONFIG_UEVENT_HELPER_PATH to "", that way this code path will never be
      excuted at all -- gregkh]
      Signed-off-by: default avatarArjan van de Ven <arjan@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Ming Lei's avatar
      Driver core: implement uevent suppress in kobject · f67f129e
      Ming Lei authored
      This patch implements uevent suppress in kobject and removes it
      from struct device, based on the following ideas:
      1,Uevent sending should be one attribute of kobject, so suppressing it
      in kobject layer is more natural than in device layer. By this way,
      we can do it for other objects embedded with kobject.
      2,It may save several bytes for each instance of struct device.(On my
      omap3(32bit ARM) based box, can save 8bytes per device object)
      This patch also introduces dev_set|get_uevent_suppress() helpers to
      set and query uevent_suppress attribute in case to help kobject
      as private part of struct device in future.
      [This version is against the latest driver-core patch set of Greg,please
      ignore the last version.]
      Signed-off-by: default avatarMing Lei <tom.leiming@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
  25. 06 Feb, 2009 1 commit
    • Pablo Neira Ayuso's avatar
      netlink: change return-value logic of netlink_broadcast() · ff491a73
      Pablo Neira Ayuso authored
      Currently, netlink_broadcast() reports errors to the caller if no
      messages at all were delivered:
      1) If, at least, one message has been delivered correctly, returns 0.
      2) Otherwise, if no messages at all were delivered due to skb_clone()
         failure, return -ENOBUFS.
      3) Otherwise, if there are no listeners, return -ESRCH.
      With this patch, the caller knows if the delivery of any of the
      messages to the listeners have failed:
      1) If it fails to deliver any message (for whatever reason), return
      2) Otherwise, if all messages were delivered OK, returns 0.
      3) Otherwise, if no listeners, return -ESRCH.
      In the current ctnetlink code and in Netfilter in general, we can add
      reliable logging and connection tracking event delivery by dropping the
      packets whose events were not successfully delivered over Netlink. Of
      course, this option would be settable via /proc as this approach reduces
      performance (in terms of filtered connections per seconds by a stateful
      firewall) but providing reliable logging and event delivery (for
      conntrackd) in return.
      This patch also changes some clients of netlink_broadcast() that
      may report ENOBUFS errors via printk. This error handling is not
      of any help. Instead, the userspace daemons that are listening to
      those netlink messages should resync themselves with the kernel-side
      if they hit ENOBUFS.
      BTW, netlink_broadcast() clients include those that call
      cn_netlink_send(), nlmsg_multicast() and genlmsg_multicast() since they
      internally call netlink_broadcast() and return its error value.
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  26. 06 Jan, 2009 2 commits
  27. 26 Jul, 2008 1 commit
  28. 22 Jul, 2008 1 commit
  29. 30 Apr, 2008 1 commit
  30. 03 Apr, 2008 1 commit