1. 29 Mar, 2023 7 commits
    • Imran Khan's avatar
      kernfs: Introduce separate rwsem to protect inode attributes. · 9caf6961
      Imran Khan authored
      Right now a global per-fs rwsem (kernfs_rwsem) synchronizes multiple
      kernfs operations. On a large system with few hundred CPUs and few
      hundred applications simultaneoulsy trying to access sysfs, this
      results in multiple sys_open(s) contending on kernfs_rwsem via
      kernfs_iop_permission and kernfs_dop_revalidate.
      
      For example on a system with 384 cores, if I run 200 instances of an
      application which is mostly executing the following loop:
      
        for (int loop = 0; loop <100 ; loop++)
        {
          for (int port_num = 1; port_num < 2; port_num++)
          {
            for (int gid_index = 0; gid_index < 254; gid_index++ )
            {
              char ret_buf[64], ret_buf_lo[64];
              char gid_file_path[1024];
      
              int      ret_len;
              int      ret_fd;
              ssize_t  ret_rd;
      
              ub4  i, saved_errno;
      
              memset(ret_buf, 0, sizeof(ret_buf));
              memset(gid_file_path, 0, sizeof(gid_file_path));
      
              ret_len = snprintf(gid_file_path, sizeof(gid_file_path),
                                 "/sys/class/infiniband/%s/ports/%d/gids/%d",
                                 dev_name,
                                 port_num,
                                 gid_index);
      
              ret_fd = open(gid_file_path, O_RDONLY | O_CLOEXEC);
              if (ret_fd < 0)
              {
                printf("Failed to open %s\n", gid_file_path);
                continue;
              }
      
              /* Read the GID */
              ret_rd = read(ret_fd, ret_buf, 40);
      
              if (ret_rd == -1)
              {
                printf("Failed to read from file %s, errno: %u\n",
                       gid_file_path, saved_errno);
      
                continue;
              }
      
              close(ret_fd);
            }
          }
      
      I see contention around kernfs_rwsem as follows:
      
      path_openat
      |
      |----link_path_walk.part.0.constprop.0
      |      |
      |      |--49.92%--inode_permission
      |      |          |
      |      |           --48.69%--kernfs_iop_permission
      |      |                     |
      |      |                     |--18.16%--down_read
      |      |                     |
      |      |                     |--15.38%--up_read
      |      |                     |
      |      |                      --14.58%--_raw_spin_lock
      |      |                                |
      |      |                                 -----
      |      |
      |      |--29.08%--walk_component
      |      |          |
      |      |           --29.02%--lookup_fast
      |      |                     |
      |      |                     |--24.26%--kernfs_dop_revalidate
      |      |                     |          |
      |      |                     |          |--14.97%--down_read
      |      |                     |          |
      |      |                     |           --9.01%--up_read
      |      |                     |
      |      |                      --4.74%--__d_lookup
      |      |                                |
      |      |                                 --4.64%--_raw_spin_lock
      |      |                                           |
      |      |                                            ----
      
      Having a separate per-fs rwsem to protect kernfs inode attributes,
      will avoid the above mentioned contention and result in better
      performance as can bee seen below:
      
      path_openat
      |
      |----link_path_walk.part.0.constprop.0
      |     |
      |     |
      |     |--27.06%--inode_permission
      |     |          |
      |     |           --25.84%--kernfs_iop_permission
      |     |                     |
      |     |                     |--9.29%--up_read
      |     |                     |
      |     |                     |--8.19%--down_read
      |     |                     |
      |     |                      --7.89%--_raw_spin_lock
      |     |                                |
      |     |                                 ----
      |     |
      |     |--22.42%--walk_component
      |     |          |
      |     |           --22.36%--lookup_fast
      |     |                     |
      |     |                     |--16.07%--__d_lookup
      |     |                     |          |
      |     |                     |           --16.01%--_raw_spin_lock
      |     |                     |                     |
      |     |                     |                      ----
      |     |                     |
      |     |                      --6.28%--kernfs_dop_revalidate
      |     |                                |
      |     |                                |--3.76%--down_read
      |     |                                |
      |     |                                 --2.26%--up_read
      
      As can be seen from the above data the overhead due to both
      kerfs_iop_permission and kernfs_dop_revalidate have gone down and
      this also reduces overall run time of the earlier mentioned loop.
      Signed-off-by: default avatarImran Khan <imran.f.khan@oracle.com>
      Link: https://lore.kernel.org/r/20230309110932.2889010-2-imran.f.khan@oracle.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9caf6961
    • Amadeusz Sławiński's avatar
      firmware_loader: Add debug message with checksum for FW file · 02fe26f2
      Amadeusz Sławiński authored
      Enable dynamic-debug logging of firmware filenames and SHA256 checksums
      to clearly identify the firmware files that are loaded by the system.
      
      Example output:
      [   34.944619] firmware_class:_request_firmware: i915 0000:00:02.0: Loaded FW: i915/kbl_dmc_ver1_04.bin, sha256: 2cde41c3e5ad181423bcc3e98ff9c49f743c88f18646af4d0b3c3a9664b831a1
      [   48.155884] firmware_class:_request_firmware: snd_soc_avs 0000:00:1f.3: Loaded FW: intel/avs/cnl/dsp_basefw.bin, sha256: 43f6ac1b066e9bd0423d914960fbbdccb391af27d2b1da1085eee3ea8df0f357
      [   49.579540] firmware_class:_request_firmware: snd_soc_avs 0000:00:1f.3: Loaded FW: intel/avs/rt274-tplg.bin, sha256: 4b3580da96dc3d2c443ba20c6728d8b665fceb3ed57223c3a57582bbad8e2413
      [   49.798196] firmware_class:_request_firmware: snd_soc_avs 0000:00:1f.3: Loaded FW: intel/avs/hda-8086280c-tplg.bin, sha256: 5653172579b2be1b51fd69f5cf46e2bac8d63f2a1327924311c13b2f1fe6e601
      [   49.859627] firmware_class:_request_firmware: snd_soc_avs 0000:00:1f.3: Loaded FW: intel/avs/dmic-tplg.bin, sha256: 00fb7fbdb74683333400d7e46925dae60db448b88638efcca0b30215db9df63f
      Reviewed-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Reviewed-by: default avatarRuss Weight <russell.h.weight@intel.com>
      Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
      Link: https://lore.kernel.org/r/20230317224729.1025879-1-amadeuszx.slawinski@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02fe26f2
    • Heiner Kallweit's avatar
      soc: amlogic: meson-gx-socinfo: use new soc_device_register functionality to populate machine name · 67ca1b93
      Heiner Kallweit authored
      A new fallback mechanism has been added to soc_device_register that
      populates machine with the DT model information if machine isn't set yet.
      This allows to remove this code here.
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Reviewed-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Link: https://lore.kernel.org/r/ac3b4356-d4c3-25e4-9bc2-c5b369c676b2@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67ca1b93
    • Heiner Kallweit's avatar
      base: soc: populate machine name in soc_device_register if empty · 3f84aa5e
      Heiner Kallweit authored
      Several SoC drivers use the same of-based mechanism to populate the machine
      name. Therefore move this to the core and try to populate the machine name
      in soc_device_register if it's not set yet.
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Acked-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Link: https://lore.kernel.org/r/6dbdf458-9f46-613e-de58-b4a56a6cdd9f@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f84aa5e
    • Greg Kroah-Hartman's avatar
      driver core: class.c: convert to only use class_to_subsys · 7b884b7f
      Greg Kroah-Hartman authored
      Now that class_to_subsys() can be used to get access to the internal
      class private pointer, convert the remaining few places in class.c that
      were accessing the pointer directly to use class_to_subsys() instead.
      
      By doing this, the need for class_get() and class_put() goes away as no
      one actually tries to increment the class structures anymore, only the
      internal dynamic one.
      
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Link: https://lore.kernel.org/r/20230325194234.46588-2-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b884b7f
    • Greg Kroah-Hartman's avatar
      driver core: class: implement class_get/put without the private pointer. · 884f8ce4
      Greg Kroah-Hartman authored
      Much like what was done in commit 273afac6 ("driver core: bus:
      implement bus_get/put() without the private pointer"), it is time to
      move the driver core away from using the internal private pointer in
      struct class in order to enable it to be always a constant and be placed
      in read-only memory in the future.
      
      First step in doing this is to create a helper function that turns a
      'struct class' into 'struct subsys_private' called class_to_subsys().
      
      class_to_subsys() walks the list of registered busses in the system and
      finds the matching one based on the pointer to the class itself.  As
      this is a short list, and this function is not on any fast path, it
      should not be noticable.
      
      Implement class_get() and class_put() using this new helper function.
      
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Link: https://lore.kernel.org/r/20230325194234.46588-1-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      884f8ce4
    • Greg Kroah-Hartman's avatar
      driver core: class: mark the struct class for sysfs callbacks as constant · 75a2d422
      Greg Kroah-Hartman authored
      struct class should never be modified in a sysfs callback as there is
      nothing in the structure to modify, and frankly, the structure is almost
      never used in a sysfs callback, so mark it as constant to allow struct
      class to be moved to read-only memory.
      
      While we are touching all class sysfs callbacks also mark the attribute
      as constant as it can not be modified.  The bonding code still uses this
      structure so it can not be removed from the function callbacks.
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Bartosz Golaszewski <brgl@bgdev.pl>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Miquel Raynal <miquel.raynal@bootlin.com>
      Cc: Namjae Jeon <linkinjeon@kernel.org>
      Cc: Paolo Abeni <pabeni@redhat.com>
      Cc: Russ Weight <russell.h.weight@intel.com>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Steve French <sfrench@samba.org>
      Cc: Vignesh Raghavendra <vigneshr@ti.com>
      Cc: linux-cifs@vger.kernel.org
      Cc: linux-gpio@vger.kernel.org
      Cc: linux-mtd@lists.infradead.org
      Cc: linux-rdma@vger.kernel.org
      Cc: linux-s390@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: netdev@vger.kernel.org
      Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Link: https://lore.kernel.org/r/20230325084537.3622280-1-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75a2d422
  2. 28 Mar, 2023 4 commits
  3. 27 Mar, 2023 4 commits
  4. 25 Mar, 2023 1 commit
  5. 24 Mar, 2023 11 commits
  6. 23 Mar, 2023 13 commits