1. 21 5月, 2020 3 次提交
  2. 19 5月, 2020 1 次提交
  3. 15 5月, 2020 3 次提交
  4. 05 5月, 2020 2 次提交
  5. 29 4月, 2020 3 次提交
  6. 28 4月, 2020 6 次提交
    • J
      driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires · 35a67236
      John Stultz 提交于
      In commit c8c43cee ("driver core: Fix
      driver_deferred_probe_check_state() logic"), we set the default
      driver_deferred_probe_timeout value to 30 seconds to allow for
      drivers that are missing dependencies to have some time so that
      the dependency may be loaded from userland after initcalls_done
      is set.
      
      However, Yoshihiro Shimoda reported that on his device that
      expects to have unmet dependencies (due to "optional links" in
      its devicetree), was failing to mount the NFS root.
      
      In digging further, it seemed the problem was that while the
      device properly probes after waiting 30 seconds for any missing
      modules to load, the ip_auto_config() had already failed,
      resulting in NFS to fail. This was due to ip_auto_config()
      calling wait_for_device_probe() which doesn't wait for the
      driver_deferred_probe_timeout to fire.
      
      This patch tries to fix the issue by creating a waitqueue
      for the driver_deferred_probe_timeout, and calling wait_event()
      to make sure driver_deferred_probe_timeout is zero in
      wait_for_device_probe() to make sure all the probing is
      finished.
      
      The downside to this solution is that kernel functionality that
      uses wait_for_device_probe(), will block until the
      driver_deferred_probe_timeout fires, regardless of if there is
      any missing dependencies.
      
      However, the previous patch reverts the default timeout value to
      zero, so this side-effect will only affect users who specify a
      driver_deferred_probe_timeout= value as a boot argument, where
      the additional delay would be beneficial to allow modules to
      load later during boot.
      
      Thanks to Geert for chasing down that ip_auto_config was why NFS
      was failing in this case!
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
      Cc: Basil Eljuse <Basil.Eljuse@arm.com>
      Cc: Ferry Toth <fntoth@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Anders Roxell <anders.roxell@linaro.org>
      Cc: linux-pm@vger.kernel.org
      Reported-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Tested-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Fixes: c8c43cee ("driver core: Fix driver_deferred_probe_check_state() logic")
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Link: https://lore.kernel.org/r/20200422203245.83244-4-john.stultz@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35a67236
    • J
      driver core: Use dev_warn() instead of dev_WARN() for deferred_probe_timeout warnings · 4ccc03e2
      John Stultz 提交于
      In commit c8c43cee ("driver core: Fix
      driver_deferred_probe_check_state() logic") and following
      changes the logic was changes slightly so that if there is no
      driver to match whats found in the dtb, we wait the sepcified
      seconds for modules to be loaded by userland, and then timeout,
      where as previously we'd print "ignoring dependency for device,
      assuming no driver" and immediately return -ENODEV after
      initcall_done.
      
      However, in the timeout case (which previously existed but was
      practicaly un-used without a boot argument), the timeout message
      uses dev_WARN(). This means folks are now seeing a big backtrace
      in their boot logs if there a entry in their dts that doesn't
      have a driver.
      
      To fix this, lets use dev_warn(), instead of dev_WARN() to match
      the previous error path.
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
      Cc: Basil Eljuse <Basil.Eljuse@arm.com>
      Cc: Ferry Toth <fntoth@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Anders Roxell <anders.roxell@linaro.org>
      Cc: linux-pm@vger.kernel.org
      Reviewed-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Fixes: c8c43cee ("driver core: Fix driver_deferred_probe_check_state() logic")
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Link: https://lore.kernel.org/r/20200422203245.83244-3-john.stultz@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ccc03e2
    • J
      driver core: Revert default driver_deferred_probe_timeout value to 0 · ce68929f
      John Stultz 提交于
      This patch addresses a regression in 5.7-rc1+
      
      In commit c8c43cee ("driver core: Fix
      driver_deferred_probe_check_state() logic"), we both cleaned up
      the logic and also set the default driver_deferred_probe_timeout
      value to 30 seconds to allow for drivers that are missing
      dependencies to have some time so that the dependency may be
      loaded from userland after initcalls_done is set.
      
      However, Yoshihiro Shimoda reported that on his device that
      expects to have unmet dependencies (due to "optional links" in
      its devicetree), was failing to mount the NFS root.
      
      In digging further, it seemed the problem was that while the
      device properly probes after waiting 30 seconds for any missing
      modules to load, the ip_auto_config() had already failed,
      resulting in NFS to fail. This was due to ip_auto_config()
      calling wait_for_device_probe() which doesn't wait for the
      driver_deferred_probe_timeout to fire.
      
      Fixing that issue is possible, but could also introduce 30
      second delays in bootups for users who don't have any
      missing dependencies, which is not ideal.
      
      So I think the best solution to avoid any regressions is to
      revert back to a default timeout value of zero, and allow
      systems that need to utilize the timeout in order for userland
      to load any modules that supply misisng dependencies in the dts
      to specify the timeout length via the exiting documented boot
      argument.
      
      Thanks to Geert for chasing down that ip_auto_config was why NFS
      was failing in this case!
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
      Cc: Basil Eljuse <Basil.Eljuse@arm.com>
      Cc: Ferry Toth <fntoth@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Anders Roxell <anders.roxell@linaro.org>
      Reported-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Tested-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Tested-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Fixes: c8c43cee ("driver core: Fix driver_deferred_probe_check_state() logic")
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Link: https://lore.kernel.org/r/20200422203245.83244-2-john.stultz@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce68929f
    • J
      component: Silence bind error on -EPROBE_DEFER · 7706b0a7
      James Hilliard 提交于
      If a component fails to bind due to -EPROBE_DEFER we should not log an
      error as this is not a real failure.
      
      Fixes messages like:
      vc4-drm soc:gpu: failed to bind 3f902000.hdmi (ops vc4_hdmi_ops): -517
      vc4-drm soc:gpu: master bind failed: -517
      Signed-off-by: NJames Hilliard <james.hilliard1@gmail.com>
      Link: https://lore.kernel.org/r/20200411190241.89404-1-james.hilliard1@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7706b0a7
    • S
      driver core: Fix handling of fw_devlink=permissive · 00b24755
      Saravana Kannan 提交于
      When commit 8375e74f ("driver core: Add fw_devlink kernel
      commandline option") added fw_devlink, it didn't implement "permissive"
      mode correctly.
      
      That commit got the device links flags correct to make sure unprobed
      suppliers don't block the probing of a consumer. However, if a consumer
      is waiting for mandatory suppliers to register, that could still block a
      consumer from probing.
      
      This commit fixes that by making sure in permissive mode, all suppliers
      to a consumer are treated as a optional suppliers. So, even if a
      consumer is waiting for suppliers to register and link itself (using the
      DL_FLAG_SYNC_STATE_ONLY flag) to the supplier, the consumer is never
      blocked from probing.
      
      Fixes: 8375e74f ("driver core: Add fw_devlink kernel commandline option")
      Reported-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NSaravana Kannan <saravanak@google.com>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Link: https://lore.kernel.org/r/20200331022832.209618-1-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00b24755
    • U
      driver core: platform: Initialize dma_parms for platform devices · 9495b7e9
      Ulf Hansson 提交于
      It's currently the platform driver's responsibility to initialize the
      pointer, dma_parms, for its corresponding struct device. The benefit with
      this approach allows us to avoid the initialization and to not waste memory
      for the struct device_dma_parameters, as this can be decided on a case by
      case basis.
      
      However, it has turned out that this approach is not very practical.  Not
      only does it lead to open coding, but also to real errors. In principle
      callers of dma_set_max_seg_size() doesn't check the error code, but just
      assumes it succeeds.
      
      For these reasons, let's do the initialization from the common platform bus
      at the device registration point. This also follows the way the PCI devices
      are being managed, see pci_device_add().
      Suggested-by: NChristoph Hellwig <hch@lst.de>
      Cc: <stable@vger.kernel.org>
      Tested-by: NHaibo Chen <haibo.chen@nxp.com>
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/r/20200422100954.31211-1-ulf.hansson@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9495b7e9
  7. 26 4月, 2020 1 次提交
  8. 23 4月, 2020 1 次提交
  9. 22 4月, 2020 1 次提交
  10. 17 4月, 2020 2 次提交
  11. 08 4月, 2020 7 次提交
    • D
      mm/memory_hotplug: allow to specify a default online_type · 5f47adf7
      David Hildenbrand 提交于
      For now, distributions implement advanced udev rules to essentially
      - Don't online any hotplugged memory (s390x)
      - Online all memory to ZONE_NORMAL (e.g., most virt environments like
        hyperv)
      - Online all memory to ZONE_MOVABLE in case the zone imbalance is taken
        care of (e.g., bare metal, special virt environments)
      
      In summary: All memory is usually onlined the same way, however, the
      kernel always has to ask user space to come up with the same answer.
      E.g., Hyper-V always waits for a memory block to get onlined before
      continuing, otherwise it might end up adding memory faster than
      onlining it, which can result in strange OOM situations.  This waiting
      slows down adding of a bigger amount of memory.
      
      Let's allow to specify a default online_type, not just "online" and
      "offline".  This allows distributions to configure the default online_type
      when booting up and be done with it.
      
      We can now specify "offline", "online", "online_movable" and
      "online_kernel" via
      - "memhp_default_state=" on the kernel cmdline
      - /sys/devices/system/memory/auto_online_blocks
      just like we are able to specify for a single memory block via
      /sys/devices/system/memory/memoryX/state
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NWei Yang <richard.weiyang@gmail.com>
      Reviewed-by: NBaoquan He <bhe@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Wei Yang <richard.weiyang@gmail.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Yumei Huang <yuhuang@redhat.com>
      Link: http://lkml.kernel.org/r/20200317104942.11178-9-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5f47adf7
    • D
      mm/memory_hotplug: convert memhp_auto_online to store an online_type · 862919e5
      David Hildenbrand 提交于
      ...  and rename it to memhp_default_online_type.  This is a preparation
      for more detailed default online behavior.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NWei Yang <richard.weiyang@gmail.com>
      Reviewed-by: NBaoquan He <bhe@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Wei Yang <richard.weiyang@gmail.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Yumei Huang <yuhuang@redhat.com>
      Link: http://lkml.kernel.org/r/20200317104942.11178-8-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      862919e5
    • D
      drivers/base/memory: store mapping between MMOP_* and string in an array · 4dc8207b
      David Hildenbrand 提交于
      Let's use a simple array which we can reuse soon.  While at it, move the
      string->mmop conversion out of the device hotplug lock.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NWei Yang <richard.weiyang@gmail.com>
      Reviewed-by: NBaoquan He <bhe@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Wei Yang <richard.weiyang@gmail.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Yumei Huang <yuhuang@redhat.com>
      Link: http://lkml.kernel.org/r/20200317104942.11178-4-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4dc8207b
    • D
      drivers/base/memory: map MMOP_OFFLINE to 0 · efc978ad
      David Hildenbrand 提交于
      Historically, we used the value -1.  Just treat 0 as the special case now.
      Clarify a comment (which was wrong, when we come via device_online() the
      first time, the online_type would have been 0 / MEM_ONLINE).  The default
      is now always MMOP_OFFLINE.  This removes the last user of the manual
      "-1", which didn't use the enum value.
      
      This is a preparation to use the online_type as an array index.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NWei Yang <richard.weiyang@gmail.com>
      Reviewed-by: NBaoquan He <bhe@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Wei Yang <richard.weiyang@gmail.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Yumei Huang <yuhuang@redhat.com>
      Link: http://lkml.kernel.org/r/20200317104942.11178-3-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      efc978ad
    • D
      drivers/base/memory: rename MMOP_ONLINE_KEEP to MMOP_ONLINE · 956f8b44
      David Hildenbrand 提交于
      Patch series "mm/memory_hotplug: allow to specify a default online_type", v3.
      
      Distributions nowadays use udev rules ([1] [2]) to specify if and how to
      online hotplugged memory.  The rules seem to get more complex with many
      special cases.  Due to the various special cases,
      CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE cannot be used.  All memory hotplug
      is handled via udev rules.
      
      Every time we hotplug memory, the udev rule will come to the same
      conclusion.  Especially Hyper-V (but also soon virtio-mem) add a lot of
      memory in separate memory blocks and wait for memory to get onlined by
      user space before continuing to add more memory blocks (to not add memory
      faster than it is getting onlined).  This of course slows down the whole
      memory hotplug process.
      
      To make the job of distributions easier and to avoid udev rules that get
      more and more complicated, let's extend the mechanism provided by
      - /sys/devices/system/memory/auto_online_blocks
      - "memhp_default_state=" on the kernel cmdline
      to be able to specify also "online_movable" as well as "online_kernel"
      
      === Example /usr/libexec/config-memhotplug ===
      
      #!/bin/bash
      
      VIRT=`systemd-detect-virt --vm`
      ARCH=`uname -p`
      
      sense_virtio_mem() {
        if [ -d "/sys/bus/virtio/drivers/virtio_mem/" ]; then
          DEVICES=`find /sys/bus/virtio/drivers/virtio_mem/ -maxdepth 1 -type l | wc -l`
          if [ $DEVICES != "0" ]; then
              return 0
          fi
        fi
        return 1
      }
      
      if [ ! -e "/sys/devices/system/memory/auto_online_blocks" ]; then
        echo "Memory hotplug configuration support missing in the kernel"
        exit 1
      fi
      
      if grep "memhp_default_state=" /proc/cmdline > /dev/null; then
        echo "Memory hotplug configuration overridden in kernel cmdline (memhp_default_state=)"
        exit 1
      fi
      
      if [ $VIRT == "microsoft" ]; then
        echo "Detected Hyper-V on $ARCH"
        # Hyper-V wants all memory in ZONE_NORMAL
        ONLINE_TYPE="online_kernel"
      elif sense_virtio_mem; then
        echo "Detected virtio-mem on $ARCH"
        # virtio-mem wants all memory in ZONE_NORMAL
        ONLINE_TYPE="online_kernel"
      elif [ $ARCH == "s390x" ] || [ $ARCH == "s390" ]; then
        echo "Detected $ARCH"
        # standby memory should not be onlined automatically
        ONLINE_TYPE="offline"
      elif [ $ARCH == "ppc64" ] || [ $ARCH == "ppc64le" ]; then
        echo "Detected" $ARCH
        # PPC64 onlines all hotplugged memory right from the kernel
        ONLINE_TYPE="offline"
      elif [ $VIRT == "none" ]; then
        echo "Detected bare-metal on $ARCH"
        # Bare metal users expect hotplugged memory to be unpluggable. We assume
        # that ZONE imbalances on such enterpise servers cannot happen and is
        # properly documented
        ONLINE_TYPE="online_movable"
      else
        # TODO: Hypervisors that want to unplug DIMMs and can guarantee that ZONE
        # imbalances won't happen
        echo "Detected $VIRT on $ARCH"
        # Usually, ballooning is used in virtual environments, so memory should go to
        # ZONE_NORMAL. However, sometimes "movable_node" is relevant.
        ONLINE_TYPE="online"
      fi
      
      echo "Selected online_type:" $ONLINE_TYPE
      
      # Configure what to do with memory that will be hotplugged in the future
      echo $ONLINE_TYPE 2>/dev/null > /sys/devices/system/memory/auto_online_blocks
      if [ $? != "0" ]; then
        echo "Memory hotplug cannot be configured (e.g., old kernel or missing permissions)"
        # A backup udev rule should handle old kernels if necessary
        exit 1
      fi
      
      # Process all already pluggedd blocks (e.g., DIMMs, but also Hyper-V or virtio-mem)
      if [ $ONLINE_TYPE != "offline" ]; then
        for MEMORY in /sys/devices/system/memory/memory*; do
          STATE=`cat $MEMORY/state`
          if [ $STATE == "offline" ]; then
              echo $ONLINE_TYPE > $MEMORY/state
          fi
        done
      fi
      
      === Example /usr/lib/systemd/system/config-memhotplug.service ===
      
      [Unit]
      Description=Configure memory hotplug behavior
      DefaultDependencies=no
      Conflicts=shutdown.target
      Before=sysinit.target shutdown.target
      After=systemd-modules-load.service
      ConditionPathExists=|/sys/devices/system/memory/auto_online_blocks
      
      [Service]
      ExecStart=/usr/libexec/config-memhotplug
      Type=oneshot
      TimeoutSec=0
      RemainAfterExit=yes
      
      [Install]
      WantedBy=sysinit.target
      
      === Example modification to the 40-redhat.rules [2] ===
      
      : diff --git a/40-redhat.rules b/40-redhat.rules-new
      : index 2c690e5..168fd03 100644
      : --- a/40-redhat.rules
      : +++ b/40-redhat.rules-new
      : @@ -6,6 +6,9 @@ SUBSYSTEM=="cpu", ACTION=="add", TEST=="online", ATTR{online}=="0", ATTR{online}
      :  # Memory hotadd request
      :  SUBSYSTEM!="memory", GOTO="memory_hotplug_end"
      :  ACTION!="add", GOTO="memory_hotplug_end"
      : +# memory hotplug behavior configured
      : +PROGRAM=="grep online /sys/devices/system/memory/auto_online_blocks", GOTO="memory_hotplug_end"
      : +
      :  PROGRAM="/bin/uname -p", RESULT=="s390*", GOTO="memory_hotplug_end"
      :
      :  ENV{.state}="online"
      
      ===
      
      [1] https://github.com/lnykryn/systemd-rhel/pull/281
      [2] https://github.com/lnykryn/systemd-rhel/blob/staging/rules/40-redhat.rules
      
      This patch (of 8):
      
      The name is misleading and it's not really clear what is "kept".  Let's
      just name it like the online_type name we expose to user space ("online").
      
      Add some documentation to the types.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NWei Yang <richard.weiyang@gmail.com>
      Reviewed-by: NBaoquan He <bhe@redhat.com>
      Acked-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Wei Yang <richard.weiyang@gmail.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Yumei Huang <yuhuang@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: K. Y. Srinivasan <kys@microsoft.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Link: http://lkml.kernel.org/r/20200319131221.14044-1-david@redhat.com
      Link: http://lkml.kernel.org/r/20200317104942.11178-2-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      956f8b44
    • D
      drivers/base/memory.c: drop pages_correctly_probed() · fada9ae3
      David Hildenbrand 提交于
      pages_correctly_probed() is a leftover from ancient times.  It dates back
      to commit 3947be19 ("[PATCH] memory hotplug: sysfs and add/remove
      functions"), where Pg_reserved checks were added as a sfety net:
      
      	/*
      	 * The probe routines leave the pages reserved, just
      	 * as the bootmem code does.  Make sure they're still
      	 * that way.
      	 */
      
      The checks were refactored quite a bit over the years, especially in
      commit b77eab70 ("mm/memory_hotplug: optimize probe routine"), where
      checks for present, valid, and online sections were added.
      
      Hotplugged memory is added via add_memory(), which will create the full
      memmap for the hotplugged memory, and mark all sections valid and present.
      
      Only full memory blocks are onlined/offlined, so we also cannot have an
      inconsistency in that regard (especially, memory blocks with some sections
      being online and some being offline).
      
      1. Boot memory always starts online.  Since commit c5e79ef5
         ("mm/memory_hotplug.c: don't allow to online/offline memory blocks with
         holes") we disallow to offline any memory with holes.  Therefore, we
         never online memory with holes.  Present and validity checks are
         superfluous.
      
      2. Only complete memory blocks are onlined/offlined (and especially,
         the state - online or offline - is stored for whole memory blocks).
         Besides the core, only arch/powerpc/platforms/powernv/memtrace.c
         manually calls offline_pages() and fiddels with memory block states.
         But it also only offlines complete memory blocks.
      
      3. To make any of these conditions trigger, something would have to be
         terribly messed up in the core.  (e.g., online/offline only some
         sections of a memory block).
      
      4. Memory unplug properly makes sure that all sysfs attributes were
         removed (and therefore, that all threads left the sysfs handlers).  We
         don't have to worry about zombie devices at this point.
      
      5. The valid_section_nr(section_nr) check is actually dead code, as it
         would never have been reached due to the WARN_ON_ONCE(!pfn_valid(pfn)).
      
      No wonder we haven't seen any of these errors in a long time (or even
         ever, according to my search).  Let's just get rid of them.  Now, all
         checks that could hinder onlining and offlining are completely
         contained in online_pages()/offline_pages().
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Link: http://lkml.kernel.org/r/20200127110424.5757-3-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fada9ae3
    • D
      drivers/base/memory.c: drop section_count · 68c3a6ac
      David Hildenbrand 提交于
      Patch series "mm: drop superfluous section checks when onlining/offlining".
      
      Let's drop some superfluous section checks on the onlining/offlining path.
      
      This patch (of 3):
      
      Since commit c5e79ef5 ("mm/memory_hotplug.c: don't allow to
      online/offline memory blocks with holes") we have a generic check in
      offline_pages() that disallows offlining memory blocks with holes.
      
      Memory blocks with missing sections are just another variant of these type
      of blocks.  We can stop checking (and especially storing) present
      sections.  A proper error message is now printed why offlining failed.
      
      section_count was initially introduced in commit 07681215 ("Driver
      core: Add section count to memory_block struct") in order to detect when
      it is okay to remove a memory block.  It was used in commit 26bbe7ef
      ("drivers/base/memory.c: prohibit offlining of memory blocks with missing
      sections") to disallow offlining memory blocks with missing sections.  As
      we refactored creation/removal of memory devices and have a proper check
      for holes in place, we can drop the section_count.
      
      This also removes a leftover comment regarding the mem_sysfs_mutex, which
      was removed in commit 848e19ad ("drivers/base/memory.c: drop the
      mem_sysfs_mutex").
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Link: http://lkml.kernel.org/r/20200127110424.5757-2-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      68c3a6ac
  12. 03 4月, 2020 1 次提交
  13. 01 4月, 2020 2 次提交
  14. 30 3月, 2020 1 次提交
    • D
      drivers/base/memory.c: indicate all memory blocks as removable · 53cdc1cb
      David Hildenbrand 提交于
      We see multiple issues with the implementation/interface to compute
      whether a memory block can be offlined (exposed via
      /sys/devices/system/memory/memoryX/removable) and would like to simplify
      it (remove the implementation).
      
      1. It runs basically lockless. While this might be good for performance,
         we see possible races with memory offlining that will require at
         least some sort of locking to fix.
      
      2. Nowadays, more false positives are possible. No arch-specific checks
         are performed that validate if memory offlining will not be denied
         right away (and such check will require locking). For example, arm64
         won't allow to offline any memory block that was added during boot -
         which will imply a very high error rate. Other archs have other
         constraints.
      
      3. The interface is inherently racy. E.g., if a memory block is detected
         to be removable (and was not a false positive at that time), there is
         still no guarantee that offlining will actually succeed. So any
         caller already has to deal with false positives.
      
      4. It is unclear which performance benefit this interface actually
         provides. The introducing commit 5c755e9f ("memory-hotplug: add
         sysfs removable attribute for hotplug memory remove") mentioned
      
      	"A user-level agent must be able to identify which sections
      	 of memory are likely to be removable before attempting the
      	 potentially expensive operation."
      
         However, no actual performance comparison was included.
      
      Known users:
      
       - lsmem: Will group memory blocks based on the "removable" property. [1]
      
       - chmem: Indirect user. It has a RANGE mode where one can specify
                removable ranges identified via lsmem to be offlined. However,
                it also has a "SIZE" mode, which allows a sysadmin to skip the
                manual "identify removable blocks" step. [2]
      
       - powerpc-utils: Uses the "removable" attribute to skip some memory
                blocks right away when trying to find some to offline+remove.
                However, with ballooning enabled, it already skips this
                information completely (because it once resulted in many false
                negatives). Therefore, the implementation can deal with false
                positives properly already. [3]
      
      According to Nathan Fontenot, DLPAR on powerpc is nowadays no longer
      driven from userspace via the drmgr command (powerpc-utils).  Nowadays
      it's managed in the kernel - including onlining/offlining of memory
      blocks - triggered by drmgr writing to /sys/kernel/dlpar.  So the
      affected legacy userspace handling is only active on old kernels.  Only
      very old versions of drmgr on a new kernel (unlikely) might execute
      slower - totally acceptable.
      
      With CONFIG_MEMORY_HOTREMOVE, always indicating "removable" should not
      break any user space tool.  We implement a very bad heuristic now.
      Without CONFIG_MEMORY_HOTREMOVE we cannot offline anything, so report
      "not removable" as before.
      
      Original discussion can be found in [4] ("[PATCH RFC v1] mm:
      is_mem_section_removable() overhaul").
      
      Other users of is_mem_section_removable() will be removed next, so that
      we can remove is_mem_section_removable() completely.
      
      [1] http://man7.org/linux/man-pages/man1/lsmem.1.html
      [2] http://man7.org/linux/man-pages/man8/chmem.8.html
      [3] https://github.com/ibm-power-utilities/powerpc-utils
      [4] https://lkml.kernel.org/r/20200117105759.27905-1-david@redhat.com
      
      Also, this patch probably fixes a crash reported by Steve.
      http://lkml.kernel.org/r/CAPcyv4jpdaNvJ67SkjyUJLBnBnXXQv686BiVW042g03FUmWLXw@mail.gmail.comReported-by: N"Scargall, Steve" <steve.scargall@intel.com>
      Suggested-by: NMichal Hocko <mhocko@kernel.org>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NNathan Fontenot <ndfont@gmail.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Badari Pulavarty <pbadari@us.ibm.com>
      Cc: Robert Jennings <rcj@linux.vnet.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Karel Zak <kzak@redhat.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200128093542.6908-1-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      53cdc1cb
  15. 27 3月, 2020 1 次提交
    • G
      Revert "driver core: Set fw_devlink to "permissive" behavior by default" · 18555cb6
      Greg Kroah-Hartman 提交于
      This reverts commit c442a0d1 as it
      breaks some of the Raspberry Pi devices.  Marek writes:
      	This patch has just landed in linux-next 20200326. Sadly it
      	breaks booting of the Raspberry Pi3b and Pi4 boards, either in
      	32bit or 64bit mode. There is no warning nor panic message, just
      	a silent freeze. The last message shown on the earlycon is:
      
      	[    0.893217] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
      
      so revert it for now and let's try again and add it to linux-next after
      5.7-rc1 is out so that we can try to get more debugging/testing
      happening.
      Reported-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: Saravana Kannan <saravanak@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18555cb6
  16. 26 3月, 2020 1 次提交
  17. 25 3月, 2020 2 次提交
  18. 24 3月, 2020 2 次提交