1. 19 12月, 2020 22 次提交
  2. 21 10月, 2020 1 次提交
  3. 17 10月, 2020 2 次提交
    • D
      virtio-mem: try to merge system ram resources · 9b24247a
      David Hildenbrand 提交于
      virtio-mem adds memory in memory block granularity, to be able to remove
      it in the same granularity again later, and to grow slowly on demand.
      This, however, results in quite a lot of resources when adding a lot of
      memory.  Resources are effectively stored in a list-based tree.  Having a
      lot of resources not only wastes memory, it also makes traversing that
      tree more expensive, and makes /proc/iomem explode in size (e.g.,
      requiring kexec-tools to manually merge resources later when e.g., trying
      to create a kdump header).
      
      Before this patch, we get (/proc/iomem) when hotplugging 2G via virtio-mem
      on x86-64:
              [...]
              100000000-13fffffff : System RAM
              140000000-33fffffff : virtio0
                140000000-147ffffff : System RAM (virtio_mem)
                148000000-14fffffff : System RAM (virtio_mem)
                150000000-157ffffff : System RAM (virtio_mem)
                158000000-15fffffff : System RAM (virtio_mem)
                160000000-167ffffff : System RAM (virtio_mem)
                168000000-16fffffff : System RAM (virtio_mem)
                170000000-177ffffff : System RAM (virtio_mem)
                178000000-17fffffff : System RAM (virtio_mem)
                180000000-187ffffff : System RAM (virtio_mem)
                188000000-18fffffff : System RAM (virtio_mem)
                190000000-197ffffff : System RAM (virtio_mem)
                198000000-19fffffff : System RAM (virtio_mem)
                1a0000000-1a7ffffff : System RAM (virtio_mem)
                1a8000000-1afffffff : System RAM (virtio_mem)
                1b0000000-1b7ffffff : System RAM (virtio_mem)
                1b8000000-1bfffffff : System RAM (virtio_mem)
              3280000000-32ffffffff : PCI Bus 0000:00
      
      With this patch, we get (/proc/iomem):
              [...]
              fffc0000-ffffffff : Reserved
              100000000-13fffffff : System RAM
              140000000-33fffffff : virtio0
                140000000-1bfffffff : System RAM (virtio_mem)
              3280000000-32ffffffff : PCI Bus 0000:00
      
      Of course, with more hotplugged memory, it gets worse.  When unplugging
      memory blocks again, try_remove_memory() (via offline_and_remove_memory())
      will properly split the resource up again.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Wei Yang <richardw.yang@linux.intel.com>
      Cc: Anton Blanchard <anton@ozlabs.org>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Dave Jiang <dave.jiang@intel.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Julien Grall <julien@xen.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Leonardo Bras <leobras.c@gmail.com>
      Cc: Libor Pechacek <lpechacek@suse.cz>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Lynch <nathanl@linux.ibm.com>
      Cc: "Oliver O'Halloran" <oohall@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Pingfan Liu <kernelfans@gmail.com>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Roger Pau Monné <roger.pau@citrix.com>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vishal Verma <vishal.l.verma@intel.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Link: https://lkml.kernel.org/r/20200911103459.10306-7-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9b24247a
    • D
      mm/memory_hotplug: prepare passing flags to add_memory() and friends · b6117199
      David Hildenbrand 提交于
      We soon want to pass flags, e.g., to mark added System RAM resources.
      mergeable.  Prepare for that.
      
      This patch is based on a similar patch by Oscar Salvador:
      
      https://lkml.kernel.org/r/20190625075227.15193-3-osalvador@suse.deSigned-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: Juergen Gross <jgross@suse.com> # Xen related part
      Reviewed-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      Acked-by: NWei Liu <wei.liu@kernel.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Vishal Verma <vishal.l.verma@intel.com>
      Cc: Dave Jiang <dave.jiang@intel.com>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: "Oliver O'Halloran" <oohall@gmail.com>
      Cc: Pingfan Liu <kernelfans@gmail.com>
      Cc: Nathan Lynch <nathanl@linux.ibm.com>
      Cc: Libor Pechacek <lpechacek@suse.cz>
      Cc: Anton Blanchard <anton@ozlabs.org>
      Cc: Leonardo Bras <leobras.c@gmail.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Julien Grall <julien@xen.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Roger Pau Monné <roger.pau@citrix.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wei Yang <richardw.yang@linux.intel.com>
      Link: https://lkml.kernel.org/r/20200911103459.10306-5-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b6117199
  4. 14 10月, 2020 1 次提交
    • D
      virtio-mem: don't special-case ZONE_MOVABLE · 27f85279
      David Hildenbrand 提交于
      When introducing virtio-mem, the semantics of ZONE_MOVABLE were rather
      unclear, which is why we special-cased ZONE_MOVABLE such that partially
      plugged blocks would never end up in ZONE_MOVABLE.
      
      Now that the semantics are much clearer (and will be documented in a
      follow-up patch including the new virtio-mem behavior), let's allow to
      online partially plugged memory blocks to ZONE_MOVABLE and also consider
      memory blocks that were onlined to ZONE_MOVABLE when unplugging memory.
      While unplugged memory pages are, in general, unmovable, they can be
      skipped when offlining memory.
      
      virtio-mem only unplugs fairly big chunks (in the megabyte range) and
      rather tries to shrink the memory region than randomly choosing memory.
      In theory, if all other pages in the movable zone would be movable,
      virtio-mem would only shrink that zone and not create any kind of
      fragmentation.
      
      In the future, we might want to remember the zone again and use the
      information when (un)plugging memory.  For now, let's keep it simple.
      
      Note: Support for defragmentation is planned, to deal with fragmentation
      after unplug due to memory chunks within memory blocks that could not get
      unplugged before (e.g., somebody pinning pages within ZONE_MOVABLE for a
      longer time).
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Mike Rapoport <rppt@kernel.org>
      Cc: Qian Cai <cai@lca.pw>
      Link: http://lkml.kernel.org/r/20200816125333.7434-6-david@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      27f85279
  5. 05 8月, 2020 1 次提交
  6. 23 6月, 2020 2 次提交
    • D
      virtio-mem: add memory via add_memory_driver_managed() · b3562c60
      David Hildenbrand 提交于
      Virtio-mem managed memory is always detected and added by the virtio-mem
      driver, never using something like the firmware-provided memory map.
      This is the case after an ordinary system reboot, and has to be guaranteed
      after kexec. Especially, virtio-mem added memory resources can contain
      inaccessible parts ("unblocked memory blocks"), blindly forwarding them
      to a kexec kernel is dangerous, as unplugged memory will get accessed
      (esp. written).
      
      Let's use the new way of adding special driver-managed memory introduced
      in commit 7b7b2721 ("mm/memory_hotplug: introduce
      add_memory_driver_managed()").
      
      This will result in no entries in /sys/firmware/memmap ("raw firmware-
      provided memory map"), the memory resource will be flagged
      IORESOURCE_MEM_DRIVER_MANAGED (esp., kexec_file_load() will not place
      kexec images on this memory), and it is exposed as "System RAM
      (virtio_mem)" in /proc/iomem, so esp. kexec-tools can properly handle it.
      
      Example /proc/iomem before this change:
        [...]
        140000000-333ffffff : virtio0
          140000000-147ffffff : System RAM
        334000000-533ffffff : virtio1
          338000000-33fffffff : System RAM
          340000000-347ffffff : System RAM
          348000000-34fffffff : System RAM
        [...]
      
      Example /proc/iomem after this change:
        [...]
        140000000-333ffffff : virtio0
          140000000-147ffffff : System RAM (virtio_mem)
        334000000-533ffffff : virtio1
          338000000-33fffffff : System RAM (virtio_mem)
          340000000-347ffffff : System RAM (virtio_mem)
          348000000-34fffffff : System RAM (virtio_mem)
        [...]
      
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
      Cc: teawater <teawaterz@linux.alibaba.com>
      Fixes: 5f1f79bb ("virtio-mem: Paravirtualized memory hotplug")
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Link: https://lore.kernel.org/r/20200611093518.5737-1-david@redhat.comSigned-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NPankaj Gupta <pankaj.gupta.linux@gmail.com>
      b3562c60
    • D
      virtio-mem: silence a static checker warning · 1c3d69ab
      Dan Carpenter 提交于
      Smatch complains that "rc" can be uninitialized if we hit the "break;"
      statement on the first iteration through the loop.  I suspect that this
      can't happen in real life, but returning a zero literal is cleaner and
      silence the static checker warning.
      
      Fixes: 5f1f79bb ("virtio-mem: Paravirtualized memory hotplug")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/20200610085911.GC5439@mwandaSigned-off-by: NMichael S. Tsirkin <mst@redhat.com>
      1c3d69ab
  7. 09 6月, 2020 1 次提交
  8. 08 6月, 2020 1 次提交
  9. 05 6月, 2020 9 次提交