https://github.com/torvalds/linux
Revision 60bd04f258b7816af851d22821d5e6ce5b09c326 authored by Michael S. Tsirkin on 19 November 2019, 09:50:35 UTC, committed by Michael S. Tsirkin on 20 November 2019, 07:15:57 UTC
virtio_balloon_shrinker_scan should return number of system pages freed,
but because it's calling functions that deal with balloon pages, it gets
confused and sometimes returns the number of balloon pages.

It does not matter practically as the exact number isn't
used, but it seems better to be consistent in case someone
starts using this API.

Further, if we ever tried to iteratively leak pages as
virtio_balloon_shrinker_scan tries to do, we'd run into issues - this is
because freed_pages was accumulating total freed pages, but was also
subtracted on each iteration from pages_to_free, which can result in
either leaking less memory than we were supposed to free, or more if
pages_to_free underruns.

On a system with 4K pages we are lucky that we are never asked to leak
more than 128 pages while we can leak up to 256 at a time,
but it looks like a real issue for systems with page size != 4K.

Fixes: 71994620bb25 ("virtio_balloon: replace oom notifier with shrinker")
Reported-by: Khazhismel Kumykov <khazhy@google.com>
Reviewed-by: Wei Wang <wei.w.wang@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent d791cfc
History
Tip revision: 60bd04f258b7816af851d22821d5e6ce5b09c326 authored by Michael S. Tsirkin on 19 November 2019, 09:50:35 UTC
virtio_balloon: fix shrinker scan number of pages
Tip revision: 60bd04f
File Mode Size
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format -rw-r--r-- 15.0 KB
.cocciconfig -rw-r--r-- 59 bytes
.get_maintainer.ignore -rw-r--r-- 71 bytes
.gitattributes -rw-r--r-- 30 bytes
.gitignore -rw-r--r-- 1.7 KB
.mailmap -rw-r--r-- 13.5 KB
COPYING -rw-r--r-- 423 bytes
CREDITS -rw-r--r-- 97.2 KB
Kbuild -rw-r--r-- 1.3 KB
Kconfig -rw-r--r-- 595 bytes
MAINTAINERS -rw-r--r-- 516.8 KB
Makefile -rw-r--r-- 59.5 KB
README -rw-r--r-- 727 bytes

README

back to top