• Wei Wang's avatar
    virtio_balloon: replace oom notifier with shrinker · 71994620
    Wei Wang authored
    The OOM notifier is getting deprecated to use for the reasons:
    - As a callout from the oom context, it is too subtle and easy to
      generate bugs and corner cases which are hard to track;
    - It is called too late (after the reclaiming has been performed).
      Drivers with large amuont of reclaimable memory is expected to
      release them at an early stage of memory pressure;
    - The notifier callback isn't aware of oom contrains;
    Link: https://lkml.org/lkml/2018/7/12/314
    
    This patch replaces the virtio-balloon oom notifier with a shrinker
    to release balloon pages on memory pressure. The balloon pages are
    given back to mm adaptively by returning the number of pages that the
    reclaimer is asking for (i.e. sc->nr_to_scan).
    
    Currently the max possible value of sc->nr_to_scan passed to the balloon
    shrinker is SHRINK_BATCH, which is 128. This is smaller than the
    limitation that only VIRTIO_BALLOON_ARRAY_PFNS_MAX (256) pages can be
    returned via one invocation of leak_balloon. But this patch still
    considers the case that SHRINK_BATCH or shrinker->batch could be changed
    to a value larger than VIRTIO_BALLOON_ARRAY_PFNS_MAX, which will need to
    do multiple invocations of leak_balloon.
    
    Historically, the feature VIRTIO_BALLOON_F_DEFLATE_ON_OOM has been used
    to release balloon pages on OOM. We continue to use this feature bit for
    the shrinker, so the shrinker is only registered when this feature bit
    has been negotiated with host.
    Signed-off-by: default avatarWei Wang <wei.w.wang@intel.com>
    Cc: Michael S. Tsirkin <mst@redhat.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    71994620
Name
Last commit
Last update
Documentation Loading commit data...
LICENSES Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.clang-format Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...