1
0
Fork 0
remarkable-linux/drivers/virtio
Wei Wang 71994620bb virtio_balloon: replace oom notifier with shrinker
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: Wei 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: Michael S. Tsirkin <mst@redhat.com>
2018-08-22 00:56:24 +03:00
..
Kconfig virtio: make VIRTIO a menuconfig to ease disabling it all 2018-02-01 16:26:43 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
virtio.c virtio: split device_register into device_initialize and device_add 2018-02-01 16:26:45 +02:00
virtio_balloon.c virtio_balloon: replace oom notifier with shrinker 2018-08-22 00:56:24 +03:00
virtio_input.c virtio: wrap find_vqs 2017-05-02 23:41:42 +03:00
virtio_mmio.c virtio: virtio_mmio: make of_device_ids const. 2018-01-31 01:47:35 +02:00
virtio_pci_common.c virtio, vhost: features, fixes 2018-06-16 06:35:02 +09:00
virtio_pci_common.h virtio: add context flag to find vqs 2017-05-02 23:41:43 +03:00
virtio_pci_legacy.c virtio: add context flag to find vqs 2017-05-02 23:41:43 +03:00
virtio_pci_modern.c virtio_pci: support enabling VFs 2018-06-12 04:59:29 +03:00
virtio_ring.c treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00