17 Oct, 2020

2 commits

  • Let's try to merge system ram resources we add, to minimize the number of
    resources in /proc/iomem. We don't care about the boundaries of
    individual chunks we added.

    Signed-off-by: David Hildenbrand
    Signed-off-by: Andrew Morton
    Reviewed-by: Juergen Gross
    Cc: Michal Hocko
    Cc: Boris Ostrovsky
    Cc: Stefano Stabellini
    Cc: Roger Pau Monné
    Cc: Julien Grall
    Cc: Pankaj Gupta
    Cc: Baoquan He
    Cc: Wei Yang
    Cc: Anton Blanchard
    Cc: Ard Biesheuvel
    Cc: Benjamin Herrenschmidt
    Cc: Christian Borntraeger
    Cc: Dan Williams
    Cc: Dave Jiang
    Cc: Eric Biederman
    Cc: Greg Kroah-Hartman
    Cc: Haiyang Zhang
    Cc: Heiko Carstens
    Cc: Jason Gunthorpe
    Cc: Jason Wang
    Cc: Kees Cook
    Cc: "K. Y. Srinivasan"
    Cc: Len Brown
    Cc: Leonardo Bras
    Cc: Libor Pechacek
    Cc: Michael Ellerman
    Cc: "Michael S. Tsirkin"
    Cc: Nathan Lynch
    Cc: "Oliver O'Halloran"
    Cc: Paul Mackerras
    Cc: Pingfan Liu
    Cc: "Rafael J. Wysocki"
    Cc: Stephen Hemminger
    Cc: Thomas Gleixner
    Cc: Vasily Gorbik
    Cc: Vishal Verma
    Cc: Wei Liu
    Link: https://lkml.kernel.org/r/20200911103459.10306-8-david@redhat.com
    Signed-off-by: Linus Torvalds

    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.de

    Signed-off-by: David Hildenbrand
    Signed-off-by: Andrew Morton
    Reviewed-by: Juergen Gross # Xen related part
    Reviewed-by: Pankaj Gupta
    Acked-by: Wei Liu
    Cc: Michal Hocko
    Cc: Dan Williams
    Cc: Jason Gunthorpe
    Cc: Baoquan He
    Cc: Michael Ellerman
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: "Rafael J. Wysocki"
    Cc: Len Brown
    Cc: Greg Kroah-Hartman
    Cc: Vishal Verma
    Cc: Dave Jiang
    Cc: "K. Y. Srinivasan"
    Cc: Haiyang Zhang
    Cc: Stephen Hemminger
    Cc: Wei Liu
    Cc: Heiko Carstens
    Cc: Vasily Gorbik
    Cc: Christian Borntraeger
    Cc: David Hildenbrand
    Cc: "Michael S. Tsirkin"
    Cc: Jason Wang
    Cc: Boris Ostrovsky
    Cc: Stefano Stabellini
    Cc: "Oliver O'Halloran"
    Cc: Pingfan Liu
    Cc: Nathan Lynch
    Cc: Libor Pechacek
    Cc: Anton Blanchard
    Cc: Leonardo Bras
    Cc: Ard Biesheuvel
    Cc: Eric Biederman
    Cc: Julien Grall
    Cc: Kees Cook
    Cc: Roger Pau Monné
    Cc: Thomas Gleixner
    Cc: Wei Yang
    Link: https://lkml.kernel.org/r/20200911103459.10306-5-david@redhat.com
    Signed-off-by: Linus Torvalds

    David Hildenbrand
     

07 Sep, 2020

1 commit

  • Pull xen updates from Juergen Gross:
    "A small series for fixing a problem with Xen PVH guests when running
    as backends (e.g. as dom0).

    Mapping other guests' memory is now working via ZONE_DEVICE, thus not
    requiring to abuse the memory hotplug functionality for that purpose"

    * tag 'for-linus-5.9-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
    xen: add helpers to allocate unpopulated memory
    memremap: rename MEMORY_DEVICE_DEVDAX to MEMORY_DEVICE_GENERIC
    xen/balloon: add header guard

    Linus Torvalds
     

04 Sep, 2020

1 commit

  • To be used in order to create foreign mappings. This is based on the
    ZONE_DEVICE facility which is used by persistent memory devices in
    order to create struct pages and kernel virtual mappings for the IOMEM
    areas of such devices. Note that on kernels without support for
    ZONE_DEVICE Xen will fallback to use ballooned pages in order to
    create foreign mappings.

    The newly added helpers use the same parameters as the existing
    {alloc/free}_xenballooned_pages functions, which allows for in-place
    replacement of the callers. Once a memory region has been added to be
    used as scratch mapping space it will no longer be released, and pages
    returned are kept in a linked list. This allows to have a buffer of
    pages and prevents resorting to frequent additions and removals of
    regions.

    If enabled (because ZONE_DEVICE is supported) the usage of the new
    functionality untangles Xen balloon and RAM hotplug from the usage of
    unpopulated physical memory ranges to map foreign pages, which is the
    correct thing to do in order to avoid mappings of foreign pages depend
    on memory hotplug.

    Note the driver is currently not enabled on Arm platforms because it
    would interfere with the identity mapping required on some platforms.

    Signed-off-by: Roger Pau Monné
    Reviewed-by: Juergen Gross
    Link: https://lore.kernel.org/r/20200901083326.21264-4-roger.pau@citrix.com
    Signed-off-by: Juergen Gross

    Roger Pau Monne
     

08 Aug, 2020

2 commits

  • Merge misc updates from Andrew Morton:

    - a few MM hotfixes

    - kthread, tools, scripts, ntfs and ocfs2

    - some of MM

    Subsystems affected by this patch series: kthread, tools, scripts, ntfs,
    ocfs2 and mm (hofixes, pagealloc, slab-generic, slab, slub, kcsan,
    debug, pagecache, gup, swap, shmem, memcg, pagemap, mremap, mincore,
    sparsemem, vmalloc, kasan, pagealloc, hugetlb and vmscan).

    * emailed patches from Andrew Morton : (162 commits)
    mm: vmscan: consistent update to pgrefill
    mm/vmscan.c: fix typo
    khugepaged: khugepaged_test_exit() check mmget_still_valid()
    khugepaged: retract_page_tables() remember to test exit
    khugepaged: collapse_pte_mapped_thp() protect the pmd lock
    khugepaged: collapse_pte_mapped_thp() flush the right range
    mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible
    mm: thp: replace HTTP links with HTTPS ones
    mm/page_alloc: fix memalloc_nocma_{save/restore} APIs
    mm/page_alloc.c: skip setting nodemask when we are in interrupt
    mm/page_alloc: fallbacks at most has 3 elements
    mm/page_alloc: silence a KASAN false positive
    mm/page_alloc.c: remove unnecessary end_bitidx for [set|get]_pfnblock_flags_mask()
    mm/page_alloc.c: simplify pageblock bitmap access
    mm/page_alloc.c: extract the common part in pfn_to_bitidx()
    mm/page_alloc.c: replace the definition of NR_MIGRATETYPE_BITS with PB_migratetype_bits
    mm/shuffle: remove dynamic reconfiguration
    mm/memory_hotplug: document why shuffle_zone() is relevant
    mm/page_alloc: remove nr_free_pagecache_pages()
    mm: remove vm_total_pages
    ...

    Linus Torvalds
     
  • Patch series "mm: cleanup usage of "

    Most architectures have very similar versions of pXd_alloc_one() and
    pXd_free_one() for intermediate levels of page table. These patches add
    generic versions of these functions in and enable
    use of the generic functions where appropriate.

    In addition, functions declared and defined in headers are
    used mostly by core mm and early mm initialization in arch and there is no
    actual reason to have the included all over the place.
    The first patch in this series removes unneeded includes of

    In the end it didn't work out as neatly as I hoped and moving
    pXd_alloc_track() definitions to would require
    unnecessary changes to arches that have custom page table allocations, so
    I've decided to move lib/ioremap.c to mm/ and make pgalloc-track.h local
    to mm/.

    This patch (of 8):

    In most cases header is required only for allocations of
    page table memory. Most of the .c files that include that header do not
    use symbols declared in and do not require that header.

    As for the other header files that used to include , it is
    possible to move that include into the .c file that actually uses symbols
    from and drop the include from the header file.

    The process was somewhat automated using

    sed -i -E '/[
    Signed-off-by: Andrew Morton
    Reviewed-by: Pekka Enberg
    Acked-by: Geert Uytterhoeven [m68k]
    Cc: Abdul Haleem
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Christophe Leroy
    Cc: Joerg Roedel
    Cc: Max Filippov
    Cc: Peter Zijlstra
    Cc: Satheesh Rajendran
    Cc: Stafford Horne
    Cc: Stephen Rothwell
    Cc: Steven Rostedt
    Cc: Joerg Roedel
    Cc: Matthew Wilcox
    Link: http://lkml.kernel.org/r/20200627143453.31835-1-rppt@kernel.org
    Link: http://lkml.kernel.org/r/20200627143453.31835-2-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

03 Aug, 2020

3 commits

  • This reverts commit dfd74a1edfaba5864276a2859190a8d242d18952.

    This has been fixed by commit dca4436d1cf9e0d237c which added the out
    of bounds check to __add_memory, so that trying to add blocks past
    MAX_PHYSMEM_BITS will fail.

    Note the check in the Xen balloon driver was bogus anyway, as it
    checked the start address of the resource, but it should instead test
    the end address to assert the whole resource falls below
    MAX_PHYSMEM_BITS.

    Signed-off-by: Roger Pau Monné
    Reviewed-by: Juergen Gross
    Link: https://lore.kernel.org/r/20200727091342.52325-4-roger.pau@citrix.com
    Signed-off-by: Juergen Gross

    Roger Pau Monne
     
  • So it can be killed, or else processes can get hung indefinitely
    waiting for balloon pages.

    Signed-off-by: Roger Pau Monné
    Reviewed-by: Juergen Gross
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200727091342.52325-3-roger.pau@citrix.com
    Signed-off-by: Juergen Gross

    Roger Pau Monne
     
  • target_unpopulated is incremented with nr_pages at the start of the
    function, but the call to free_xenballooned_pages will only subtract
    pgno number of pages, and thus the rest need to be subtracted before
    returning or else accounting will be skewed.

    Signed-off-by: Roger Pau Monné
    Reviewed-by: Juergen Gross
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200727091342.52325-2-roger.pau@citrix.com
    Signed-off-by: Juergen Gross

    Roger Pau Monne
     

10 Jun, 2020

1 commit

  • Patch series "mm: consolidate definitions of page table accessors", v2.

    The low level page table accessors (pXY_index(), pXY_offset()) are
    duplicated across all architectures and sometimes more than once. For
    instance, we have 31 definition of pgd_offset() for 25 supported
    architectures.

    Most of these definitions are actually identical and typically it boils
    down to, e.g.

    static inline unsigned long pmd_index(unsigned long address)
    {
    return (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
    }

    static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
    {
    return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address);
    }

    These definitions can be shared among 90% of the arches provided
    XYZ_SHIFT, PTRS_PER_XYZ and xyz_page_vaddr() are defined.

    For architectures that really need a custom version there is always
    possibility to override the generic version with the usual ifdefs magic.

    These patches introduce include/linux/pgtable.h that replaces
    include/asm-generic/pgtable.h and add the definitions of the page table
    accessors to the new header.

    This patch (of 12):

    The linux/mm.h header includes to allow inlining of the
    functions involving page table manipulations, e.g. pte_alloc() and
    pmd_alloc(). So, there is no point to explicitly include
    in the files that include .

    The include statements in such cases are remove with a simple loop:

    for f in $(git grep -l "include ") ; do
    sed -i -e '/include / d' $f
    done

    Signed-off-by: Mike Rapoport
    Signed-off-by: Andrew Morton
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Brian Cain
    Cc: Catalin Marinas
    Cc: Chris Zankel
    Cc: "David S. Miller"
    Cc: Geert Uytterhoeven
    Cc: Greentime Hu
    Cc: Greg Ungerer
    Cc: Guan Xuetao
    Cc: Guo Ren
    Cc: Heiko Carstens
    Cc: Helge Deller
    Cc: Ingo Molnar
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Matthew Wilcox
    Cc: Matt Turner
    Cc: Max Filippov
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Mike Rapoport
    Cc: Nick Hu
    Cc: Paul Walmsley
    Cc: Richard Weinberger
    Cc: Rich Felker
    Cc: Russell King
    Cc: Stafford Horne
    Cc: Thomas Bogendoerfer
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Cc: Vincent Chen
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Yoshinori Sato
    Link: http://lkml.kernel.org/r/20200514170327.31389-1-rppt@kernel.org
    Link: http://lkml.kernel.org/r/20200514170327.31389-2-rppt@kernel.org
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

16 Dec, 2019

1 commit


13 Dec, 2019

1 commit

  • When CONFIG_XEN_BALLOON_MEMORY_HOTPLUG is not defined
    reserve_additional_memory() will set balloon_stats.target_pages to a
    wrong value in case there are still some ballooned pages allocated via
    alloc_xenballooned_pages().

    This will result in balloon_process() no longer be triggered when
    ballooned pages are freed in batches.

    Reported-by: Nicholas Tsirakis
    Signed-off-by: Juergen Gross
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Juergen Gross

    Juergen Gross
     

02 Dec, 2019

1 commit

  • __online_page_set_limits() is a dummy function - remove it and all
    callers.

    Link: http://lkml.kernel.org/r/8e1bc9d3b492f6bde16e95ebc1dee11d6aefabd7.1567889743.git.jrdr.linux@gmail.com
    Link: http://lkml.kernel.org/r/854db2cf8145d9635249c95584d9a91fd774a229.1567889743.git.jrdr.linux@gmail.com
    Link: http://lkml.kernel.org/r/9afe6c5a18158f3884a6b302ac2c772f3da49ccc.1567889743.git.jrdr.linux@gmail.com
    Signed-off-by: Souptick Joarder
    Reviewed-by: David Hildenbrand
    Acked-by: Michal Hocko
    Cc: Juergen Gross
    Cc: "Kirill A. Shutemov"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Souptick Joarder
     

02 Oct, 2019

4 commits

  • Let's move the clearing to balloon_retrieve(). In
    bp_state increase_reservation(), we now clear the flag a little earlier
    than before, however, this should not matter for XEN.

    Suggested-by: Boris Ostrovsky
    Cc: Boris Ostrovsky
    Cc: Juergen Gross
    Cc: Stefano Stabellini
    Signed-off-by: David Hildenbrand
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Boris Ostrovsky

    David Hildenbrand
     
  • Let's move the __SetPageOffline() call which all callers perform into
    balloon_append().

    In bp_state decrease_reservation(), pages are now marked PG_offline a
    little later than before, however, this should not matter for XEN.

    Suggested-by: Boris Ostrovsky
    Cc: Boris Ostrovsky
    Cc: Juergen Gross
    Cc: Stefano Stabellini
    Signed-off-by: David Hildenbrand
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Boris Ostrovsky

    David Hildenbrand
     
  • Let's simply use balloon_append() directly.

    Cc: Boris Ostrovsky
    Cc: Juergen Gross
    Cc: Stefano Stabellini
    Signed-off-by: David Hildenbrand
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Boris Ostrovsky

    David Hildenbrand
     
  • We are missing a __SetPageOffline(), which is why we can get
    !PageOffline() pages onto the balloon list, where
    alloc_xenballooned_pages() will complain:

    page:ffffea0003e7ffc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
    flags: 0xffffe00001000(reserved)
    raw: 000ffffe00001000 dead000000000100 dead000000000200 0000000000000000
    raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
    page dumped because: VM_BUG_ON_PAGE(!PageOffline(page))
    ------------[ cut here ]------------
    kernel BUG at include/linux/page-flags.h:744!
    invalid opcode: 0000 [#1] SMP NOPTI

    Reported-by: Marek Marczykowski-Górecki
    Tested-by: Marek Marczykowski-Górecki
    Fixes: 77c4adf6a6df ("xen/balloon: mark inflated pages PG_offline")
    Cc: stable@vger.kernel.org # v5.1+
    Cc: Boris Ostrovsky
    Cc: Juergen Gross
    Cc: Stefano Stabellini
    Signed-off-by: David Hildenbrand
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Boris Ostrovsky

    David Hildenbrand
     

20 Jul, 2019

1 commit

  • Pull xen updates from Juergen Gross:
    "Fixes and features:

    - A series to introduce a common command line parameter for disabling
    paravirtual extensions when running as a guest in virtualized
    environment

    - A fix for int3 handling in Xen pv guests

    - Removal of the Xen-specific tmem driver as support of tmem in Xen
    has been dropped (and it was experimental only)

    - A security fix for running as Xen dom0 (XSA-300)

    - A fix for IRQ handling when offlining cpus in Xen guests

    - Some small cleanups"

    * tag 'for-linus-5.3a-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
    xen: let alloc_xenballooned_pages() fail if not enough memory free
    xen/pv: Fix a boot up hang revealed by int3 self test
    x86/xen: Add "nopv" support for HVM guest
    x86/paravirt: Remove const mark from x86_hyper_xen_hvm variable
    xen: Map "xen_nopv" parameter to "nopv" and mark it obsolete
    x86: Add "nopv" parameter to disable PV extensions
    x86/xen: Mark xen_hvm_need_lapic() and xen_x2apic_para_available() as __init
    xen: remove tmem driver
    Revert "x86/paravirt: Set up the virt_spin_lock_key after static keys get initialized"
    xen/events: fix binding user event channels to cpus

    Linus Torvalds
     

19 Jul, 2019

1 commit

  • In the sysctl code the proc_dointvec_minmax() function is often used to
    validate the user supplied value between an allowed range. This
    function uses the extra1 and extra2 members from struct ctl_table as
    minimum and maximum allowed value.

    On sysctl handler declaration, in every source file there are some
    readonly variables containing just an integer which address is assigned
    to the extra1 and extra2 members, so the sysctl range is enforced.

    The special values 0, 1 and INT_MAX are very often used as range
    boundary, leading duplication of variables like zero=0, one=1,
    int_max=INT_MAX in different source files:

    $ git grep -E '\.extra[12].*&(zero|one|int_max)' |wc -l
    248

    Add a const int array containing the most commonly used values, some
    macros to refer more easily to the correct array member, and use them
    instead of creating a local one for every object file.

    This is the bloat-o-meter output comparing the old and new binary
    compiled with the default Fedora config:

    # scripts/bloat-o-meter -d vmlinux.o.old vmlinux.o
    add/remove: 2/2 grow/shrink: 0/2 up/down: 24/-188 (-164)
    Data old new delta
    sysctl_vals - 12 +12
    __kstrtab_sysctl_vals - 12 +12
    max 14 10 -4
    int_max 16 - -16
    one 68 - -68
    zero 128 28 -100
    Total: Before=20583249, After=20583085, chg -0.00%

    [mcroce@redhat.com: tipc: remove two unused variables]
    Link: http://lkml.kernel.org/r/20190530091952.4108-1-mcroce@redhat.com
    [akpm@linux-foundation.org: fix net/ipv6/sysctl_net_ipv6.c]
    [arnd@arndb.de: proc/sysctl: make firmware loader table conditional]
    Link: http://lkml.kernel.org/r/20190617130014.1713870-1-arnd@arndb.de
    [akpm@linux-foundation.org: fix fs/eventpoll.c]
    Link: http://lkml.kernel.org/r/20190430180111.10688-1-mcroce@redhat.com
    Signed-off-by: Matteo Croce
    Signed-off-by: Arnd Bergmann
    Acked-by: Kees Cook
    Reviewed-by: Aaron Tomlin
    Cc: Matthew Wilcox
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matteo Croce
     

18 Jul, 2019

1 commit

  • Instead of trying to allocate pages with GFP_USER in
    add_ballooned_pages() check the available free memory via
    si_mem_available(). GFP_USER is far less limiting memory exhaustion
    than the test via si_mem_available().

    This will avoid dom0 running out of memory due to excessive foreign
    page mappings especially on ARM and on x86 in PVH mode, as those don't
    have a pre-ballooned area which can be used for foreign mappings.

    As the normal ballooning suffers from the same problem don't balloon
    down more than si_mem_available() pages in one iteration. At the same
    time limit the default maximum number of retries.

    This is part of XSA-300.

    Signed-off-by: Juergen Gross

    Juergen Gross
     

15 Mar, 2019

1 commit

  • The XEN balloon driver - in contrast to other balloon drivers - allows
    to map some inflated pages to user space. Such pages are allocated via
    alloc_xenballooned_pages() and freed via free_xenballooned_pages().
    The pfn space of these allocated pages is used to map other things
    by the hypervisor using hypercalls.

    Pages marked with PG_offline must never be mapped to user space (as
    this page type uses the mapcount field of struct pages).

    So what we can do is, clear/set PG_offline when allocating/freeing an
    inflated pages. This way, most inflated pages can be excluded by
    dumping tools and the "reused for other purpose" balloon pages are
    correctly not marked as PG_offline.

    Fixes: 77c4adf6a6df (xen/balloon: mark inflated pages PG_offline)
    Reported-by: Julien Grall
    Tested-by: Julien Grall
    Signed-off-by: David Hildenbrand
    Reviewed-by: Juergen Gross
    Signed-off-by: Juergen Gross

    David Hildenbrand
     

06 Mar, 2019

2 commits

  • Mark inflated and never onlined pages PG_offline, to tell the world that
    the content is stale and should not be dumped.

    Link: http://lkml.kernel.org/r/20181119101616.8901-5-david@redhat.com
    Signed-off-by: David Hildenbrand
    Reviewed-by: Juergen Gross
    Cc: Boris Ostrovsky
    Cc: Stefano Stabellini
    Cc: Matthew Wilcox
    Cc: Michal Hocko
    Cc: "Michael S. Tsirkin"
    Cc: Alexander Duyck
    Cc: Alexey Dobriyan
    Cc: Arnd Bergmann
    Cc: Baoquan He
    Cc: Borislav Petkov
    Cc: Christian Hansen
    Cc: Dave Young
    Cc: David Rientjes
    Cc: Greg Kroah-Hartman
    Cc: Haiyang Zhang
    Cc: Jonathan Corbet
    Cc: Julien Freche
    Cc: Kairui Song
    Cc: Kazuhito Hagio
    Cc: "Kirill A. Shutemov"
    Cc: Konstantin Khlebnikov
    Cc: "K. Y. Srinivasan"
    Cc: Len Brown
    Cc: Lianbo Jiang
    Cc: Michal Hocko
    Cc: Mike Rapoport
    Cc: Miles Chen
    Cc: Nadav Amit
    Cc: Naoya Horiguchi
    Cc: Omar Sandoval
    Cc: Pankaj gupta
    Cc: Pavel Machek
    Cc: Pavel Tatashin
    Cc: Rafael J. Wysocki
    Cc: "Rafael J. Wysocki"
    Cc: Stephen Hemminger
    Cc: Stephen Rothwell
    Cc: Vitaly Kuznetsov
    Cc: Vlastimil Babka
    Cc: Xavier Deguillard
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Hildenbrand
     
  • When freeing pages are done with higher order, time spent on coalescing
    pages by buddy allocator can be reduced. With section size of 256MB,
    hot add latency of a single section shows improvement from 50-60 ms to
    less than 1 ms, hence improving the hot add latency by 60 times. Modify
    external providers of online callback to align with the change.

    [arunks@codeaurora.org: v11]
    Link: http://lkml.kernel.org/r/1547792588-18032-1-git-send-email-arunks@codeaurora.org
    [akpm@linux-foundation.org: remove unused local, per Arun]
    [akpm@linux-foundation.org: avoid return of void-returning __free_pages_core(), per Oscar]
    [akpm@linux-foundation.org: fix it for mm-convert-totalram_pages-and-totalhigh_pages-variables-to-atomic.patch]
    [arunks@codeaurora.org: v8]
    Link: http://lkml.kernel.org/r/1547032395-24582-1-git-send-email-arunks@codeaurora.org
    [arunks@codeaurora.org: v9]
    Link: http://lkml.kernel.org/r/1547098543-26452-1-git-send-email-arunks@codeaurora.org
    Link: http://lkml.kernel.org/r/1538727006-5727-1-git-send-email-arunks@codeaurora.org
    Signed-off-by: Arun KS
    Reviewed-by: Andrew Morton
    Acked-by: Michal Hocko
    Reviewed-by: Oscar Salvador
    Reviewed-by: Alexander Duyck
    Cc: K. Y. Srinivasan
    Cc: Haiyang Zhang
    Cc: Stephen Hemminger
    Cc: Boris Ostrovsky
    Cc: Juergen Gross
    Cc: Dan Williams
    Cc: Vlastimil Babka
    Cc: Joonsoo Kim
    Cc: Greg Kroah-Hartman
    Cc: Mathieu Malaterre
    Cc: "Kirill A. Shutemov"
    Cc: Souptick Joarder
    Cc: Mel Gorman
    Cc: Aaron Lu
    Cc: Srivatsa Vaddagiri
    Cc: Vinayak Menon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun KS
     

29 Dec, 2018

1 commit

  • Userspace should always be in charge of how to online memory and if memory
    should be onlined automatically in the kernel. Let's drop the parameter
    to overwrite this - XEN passes memhp_auto_online, just like add_memory(),
    so we can directly use that instead internally.

    Link: http://lkml.kernel.org/r/20181123123740.27652-1-david@redhat.com
    Signed-off-by: David Hildenbrand
    Acked-by: Michal Hocko
    Reviewed-by: Oscar Salvador
    Acked-by: Juergen Gross
    Cc: Boris Ostrovsky
    Cc: Stefano Stabellini
    Cc: Dan Williams
    Cc: Pavel Tatashin
    Cc: David Hildenbrand
    Cc: Joonsoo Kim
    Cc: Arun KS
    Cc: Mathieu Malaterre
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Hildenbrand
     

03 Dec, 2018

1 commit

  • Pull xen fixes from Juergen Gross:

    - A revert of a previous commit as it is no longer necessary and has
    shown to cause problems in some memory hotplug cases.

    - Some small fixes and a minor cleanup.

    - A patch for adding better diagnostic data in a very rare failure
    case.

    * tag 'for-linus-4.20a-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
    pvcalls-front: fixes incorrect error handling
    Revert "xen/balloon: Mark unallocated host memory as UNUSABLE"
    xen: xlate_mmu: add missing header to fix 'W=1' warning
    xen/x86: add diagnostic printout to xen_mc_flush() in case of error
    x86/xen: cleanup includes in arch/x86/xen/spinlock.c

    Linus Torvalds
     

30 Nov, 2018

1 commit

  • This reverts commit b3cf8528bb21febb650a7ecbf080d0647be40b9f.

    That commit unintentionally broke Xen balloon memory hotplug with
    "hotplug_unpopulated" set to 1. As long as "System RAM" resource
    got assigned under a new "Unusable memory" resource in IO/Mem tree
    any attempt to online this memory would fail due to general kernel
    restrictions on having "System RAM" resources as 1st level only.

    The original issue that commit has tried to workaround fa564ad96366
    ("x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 00-1f, 30-3f,
    60-7f)") also got amended by the following 03a551734 ("x86/PCI: Move
    and shrink AMD 64-bit window to avoid conflict") which made the
    original fix to Xen ballooning unnecessary.

    Signed-off-by: Igor Druzhinin
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Juergen Gross

    Igor Druzhinin
     

31 Oct, 2018

2 commits

  • add_memory() currently does not take the device_hotplug_lock, however
    is aleady called under the lock from
    arch/powerpc/platforms/pseries/hotplug-memory.c
    drivers/acpi/acpi_memhotplug.c
    to synchronize against CPU hot-remove and similar.

    In general, we should hold the device_hotplug_lock when adding memory to
    synchronize against online/offline request (e.g. from user space) - which
    already resulted in lock inversions due to device_lock() and
    mem_hotplug_lock - see 30467e0b3be ("mm, hotplug: fix concurrent memory
    hot-add deadlock"). add_memory()/add_memory_resource() will create memory
    block devices, so this really feels like the right thing to do.

    Holding the device_hotplug_lock makes sure that a memory block device
    can really only be accessed (e.g. via .online/.state) from user space,
    once the memory has been fully added to the system.

    The lock is not held yet in
    drivers/xen/balloon.c
    arch/powerpc/platforms/powernv/memtrace.c
    drivers/s390/char/sclp_cmd.c
    drivers/hv/hv_balloon.c
    So, let's either use the locked variants or take the lock.

    Don't export add_memory_resource(), as it once was exported to be used by
    XEN, which is never built as a module. If somebody requires it, we also
    have to export a locked variant (as device_hotplug_lock is never
    exported).

    Link: http://lkml.kernel.org/r/20180925091457.28651-3-david@redhat.com
    Signed-off-by: David Hildenbrand
    Reviewed-by: Pavel Tatashin
    Reviewed-by: Rafael J. Wysocki
    Reviewed-by: Rashmica Gupta
    Reviewed-by: Oscar Salvador
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Michael Ellerman
    Cc: "Rafael J. Wysocki"
    Cc: Len Brown
    Cc: Greg Kroah-Hartman
    Cc: Boris Ostrovsky
    Cc: Juergen Gross
    Cc: Nathan Fontenot
    Cc: John Allen
    Cc: Michal Hocko
    Cc: Dan Williams
    Cc: Joonsoo Kim
    Cc: Vlastimil Babka
    Cc: Mathieu Malaterre
    Cc: Pavel Tatashin
    Cc: YASUAKI ISHIMATSU
    Cc: Balbir Singh
    Cc: Haiyang Zhang
    Cc: Heiko Carstens
    Cc: Jonathan Corbet
    Cc: Kate Stewart
    Cc: "K. Y. Srinivasan"
    Cc: Martin Schwidefsky
    Cc: Michael Neuling
    Cc: Philippe Ombredanne
    Cc: Stephen Hemminger
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Hildenbrand
     
  • Move remaining definitions and declarations from include/linux/bootmem.h
    into include/linux/memblock.h and remove the redundant header.

    The includes were replaced with the semantic patch below and then
    semi-automated removal of duplicated '#include

    @@
    @@
    - #include
    + #include

    [sfr@canb.auug.org.au: dma-direct: fix up for the removal of linux/bootmem.h]
    Link: http://lkml.kernel.org/r/20181002185342.133d1680@canb.auug.org.au
    [sfr@canb.auug.org.au: powerpc: fix up for removal of linux/bootmem.h]
    Link: http://lkml.kernel.org/r/20181005161406.73ef8727@canb.auug.org.au
    [sfr@canb.auug.org.au: x86/kaslr, ACPI/NUMA: fix for linux/bootmem.h removal]
    Link: http://lkml.kernel.org/r/20181008190341.5e396491@canb.auug.org.au
    Link: http://lkml.kernel.org/r/1536927045-23536-30-git-send-email-rppt@linux.vnet.ibm.com
    Signed-off-by: Mike Rapoport
    Signed-off-by: Stephen Rothwell
    Acked-by: Michal Hocko
    Cc: Catalin Marinas
    Cc: Chris Zankel
    Cc: "David S. Miller"
    Cc: Geert Uytterhoeven
    Cc: Greentime Hu
    Cc: Greg Kroah-Hartman
    Cc: Guan Xuetao
    Cc: Ingo Molnar
    Cc: "James E.J. Bottomley"
    Cc: Jonas Bonn
    Cc: Jonathan Corbet
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Martin Schwidefsky
    Cc: Matt Turner
    Cc: Michael Ellerman
    Cc: Michal Simek
    Cc: Palmer Dabbelt
    Cc: Paul Burton
    Cc: Richard Kuo
    Cc: Richard Weinberger
    Cc: Rich Felker
    Cc: Russell King
    Cc: Serge Semin
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Cc: Vineet Gupta
    Cc: Yoshinori Sato
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     

27 Jul, 2018

1 commit

  • Memory {increase|decrease}_reservation and VA mappings update/reset
    code used in balloon driver can be made common, so other drivers can
    also re-use the same functionality without open-coding.
    Create a dedicated file for the shared code and export corresponding
    symbols for other kernel modules.

    Signed-off-by: Oleksandr Andrushchenko
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Boris Ostrovsky

    Oleksandr Andrushchenko
     

21 Dec, 2017

1 commit

  • Commit f5775e0b6116 ("x86/xen: discard RAM regions above the maximum
    reservation") left host memory not assigned to dom0 as available for
    memory hotplug.

    Unfortunately this also meant that those regions could be used by
    others. Specifically, commit fa564ad96366 ("x86/PCI: Enable a 64bit BAR
    on AMD Family 15h (Models 00-1f, 30-3f, 60-7f)") may try to map those
    addresses as MMIO.

    To prevent this mark unallocated host memory as E820_TYPE_UNUSABLE (thus
    effectively reverting f5775e0b6116) and keep track of that region as
    a hostmem resource that can be used for the hotplug.

    Signed-off-by: Boris Ostrovsky
    Reviewed-by: Juergen Gross

    Boris Ostrovsky
     

31 Aug, 2017

1 commit

  • Commit aba831a69632 ("xen: remove tests for pvh mode in pure pv paths")
    removed XENFEAT_auto_translated_physmap test in xen_alloc_p2m_entry()
    since it is assumed that the routine is never called by non-PV guests.

    However, alloc_xenballooned_pages() may make this call on a PVH guest.
    Prevent this from happening by adding XENFEAT_auto_translated_physmap
    check there.

    Signed-off-by: Boris Ostrovsky
    Reviewed-by: Juergen Gross
    Fixes: aba831a69632 ("xen: remove tests for pvh mode in pure pv paths")

    Boris Ostrovsky
     

23 Jul, 2017

1 commit

  • When setting up the Xenstore watch for the memory target size the new
    watch will fire at once. Don't try to reach the configured target size
    by onlining new memory in this case, as the current memory size will
    be smaller in almost all cases due to e.g. BIOS reserved pages.

    Onlining new memory will lead to more problems e.g. undesired conflicts
    with NVMe devices meant to be operated as block devices.

    Instead remember the difference between target size and current size
    when the watch fires for the first time and apply it to any further
    size changes, too.

    In order to avoid races between balloon.c and xen-balloon.c init calls
    do the xen-balloon.c initialization from balloon.c.

    Signed-off-by: Juergen Gross
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Juergen Gross

    Juergen Gross
     

02 May, 2017

1 commit


02 Mar, 2017

1 commit


12 Dec, 2016

1 commit

  • Only mark a page as managed when it is released back to the allocator.
    This ensures that the managed page count does not get falsely increased
    when a VM is running. Correspondingly change it so that pages are
    marked as unmanaged after getting them from the allocator.

    Signed-off-by: Ross Lagerwall
    Reviewed-by: Boris Ostrovsky
    Signed-off-by: Juergen Gross

    Ross Lagerwall
     

23 Jun, 2016

1 commit

  • Fix a declared-but-not-defined warning when building with
    XEN_BALLOON_MEMORY_HOTPLUG=n. This fixes a regression introduced by
    commit dfd74a1edfab ("xen/balloon: Fix crash when ballooning on x86 32
    bit PAE").

    Signed-off-by: Ross Lagerwall
    Acked-by: Juergen Gross
    Signed-off-by: David Vrabel

    Ross Lagerwall
     

06 Apr, 2016

1 commit

  • Commit 55b3da98a40dbb3776f7454daf0d95dde25c33d2 (xen/balloon: find
    non-conflicting regions to place hotplugged memory) caused a
    regression in 4.4.

    When ballooning on an x86 32 bit PAE system with close to 64 GiB of
    memory, the address returned by allocate_resource may be above 64 GiB.
    When using CONFIG_SPARSEMEM, this setup is limited to using physical
    addresses < 64 GiB. When adding memory at this address, it runs off
    the end of the mem_section array and causes a crash. Instead, fail
    the ballooning request.

    Signed-off-by: Ross Lagerwall
    Cc: # 4.4+
    Signed-off-by: David Vrabel

    Ross Lagerwall
     

23 Mar, 2016

1 commit

  • Pull xen updates from David Vrabel:
    "Features and fixes for 4.6:

    - Make earlyprintk=xen work for HVM guests

    - Remove module support for things never built as modules"

    * tag 'for-linus-4.6-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
    drivers/xen: make platform-pci.c explicitly non-modular
    drivers/xen: make sys-hypervisor.c explicitly non-modular
    drivers/xen: make xenbus_dev_[front/back]end explicitly non-modular
    drivers/xen: make [xen-]ballon explicitly non-modular
    xen: audit usages of module.h ; remove unnecessary instances
    xen/x86: Drop mode-selecting ifdefs in startup_xen()
    xen/x86: Zero out .bss for PV guests
    hvc_xen: make early_printk work with HVM guests
    hvc_xen: fix xenboot for DomUs
    hvc_xen: add earlycon support

    Linus Torvalds
     

21 Mar, 2016

1 commit

  • The Makefile / Kconfig currently controlling compilation here is:

    obj-y += grant-table.o features.o balloon.o manage.o preempt.o time.o
    [...]
    obj-$(CONFIG_XEN_BALLOON) += xen-balloon.o

    ...with:

    drivers/xen/Kconfig:config XEN_BALLOON
    drivers/xen/Kconfig: bool "Xen memory balloon driver"

    ...meaning that they currently are not being built as modules by anyone.

    Lets remove the modular code that is essentially orphaned, so that
    when reading the driver there is no doubt it is builtin-only.

    In doing so we uncover two implict includes that were obtained
    by module.h having such a wide include scope itself:

    In file included from drivers/xen/xen-balloon.c:41:0:
    include/xen/balloon.h:26:51: warning: ‘struct page’ declared inside parameter list [enabled by default]
    int alloc_xenballooned_pages(int nr_pages, struct page **pages);
    ^
    include/xen/balloon.h: In function ‘register_xen_selfballooning’:
    include/xen/balloon.h:35:10: error: ‘ENOSYS’ undeclared (first use in this function)
    return -ENOSYS;
    ^

    This is fixed by adding mm-types.h and errno.h to the list.

    We also delete the MODULE_LICENSE tags since all that information
    is already contained at the top of the file in the comments.

    Signed-off-by: Paul Gortmaker
    Reviewed-by: Stefano Stabellini
    Signed-off-by: David Vrabel

    Paul Gortmaker
     

16 Mar, 2016

1 commit

  • Add support for the newly added kernel memory auto onlining policy to
    Xen ballon driver.

    Signed-off-by: Vitaly Kuznetsov
    Suggested-by: Daniel Kiper
    Reviewed-by: Daniel Kiper
    Acked-by: David Vrabel
    Cc: Jonathan Corbet
    Cc: Greg Kroah-Hartman
    Cc: Daniel Kiper
    Cc: Dan Williams
    Cc: Tang Chen
    Cc: David Rientjes
    Cc: Naoya Horiguchi
    Cc: Xishi Qiu
    Cc: Mel Gorman
    Cc: "K. Y. Srinivasan"
    Cc: Igor Mammedov
    Cc: Kay Sievers
    Cc: Konrad Rzeszutek Wilk
    Cc: Boris Ostrovsky
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vitaly Kuznetsov