Skip to content
Snippets Groups Projects
  • David Hildenbrand's avatar
    9181fb70
    hostmem: Wire up RAM_NORESERVE via "reserve" property · 9181fb70
    David Hildenbrand authored
    
    Let's provide a way to control the use of RAM_NORESERVE via memory
    backends using the "reserve" property which defaults to true (old
    behavior).
    
    Only Linux currently supports clearing the flag (and support is checked at
    runtime, depending on the setting of "/proc/sys/vm/overcommit_memory").
    Windows and other POSIX systems will bail out with "reserve=false".
    
    The target use case is virtio-mem, which dynamically exposes memory
    inside a large, sparse memory area to the VM. This essentially allows
    avoiding to set "/proc/sys/vm/overcommit_memory == 0") when using
    virtio-mem and also supporting hugetlbfs in the future.
    
    As really only Linux implements RAM_NORESERVE right now, let's expose
    the property only with CONFIG_LINUX. Setting the property to "false"
    will then only fail in corner cases -- for example on very old kernels
    or when memory overcommit was completely disabled by the admin.
    
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Reviewed-by: default avatarEduardo Habkost <ehabkost@redhat.com>
    Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Acked-by: Eduardo Habkost <ehabkost@redhat.com> for memory backend and machine core
    Cc: Markus Armbruster <armbru@redhat.com>
    Cc: Eric Blake <eblake@redhat.com>
    Cc: Igor Mammedov <imammedo@redhat.com>
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Message-Id: <20210510114328.21835-11-david@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    9181fb70
    History
    hostmem: Wire up RAM_NORESERVE via "reserve" property
    David Hildenbrand authored
    
    Let's provide a way to control the use of RAM_NORESERVE via memory
    backends using the "reserve" property which defaults to true (old
    behavior).
    
    Only Linux currently supports clearing the flag (and support is checked at
    runtime, depending on the setting of "/proc/sys/vm/overcommit_memory").
    Windows and other POSIX systems will bail out with "reserve=false".
    
    The target use case is virtio-mem, which dynamically exposes memory
    inside a large, sparse memory area to the VM. This essentially allows
    avoiding to set "/proc/sys/vm/overcommit_memory == 0") when using
    virtio-mem and also supporting hugetlbfs in the future.
    
    As really only Linux implements RAM_NORESERVE right now, let's expose
    the property only with CONFIG_LINUX. Setting the property to "false"
    will then only fail in corner cases -- for example on very old kernels
    or when memory overcommit was completely disabled by the admin.
    
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Reviewed-by: default avatarEduardo Habkost <ehabkost@redhat.com>
    Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Acked-by: Eduardo Habkost <ehabkost@redhat.com> for memory backend and machine core
    Cc: Markus Armbruster <armbru@redhat.com>
    Cc: Eric Blake <eblake@redhat.com>
    Cc: Igor Mammedov <imammedo@redhat.com>
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Message-Id: <20210510114328.21835-11-david@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>