diff options
| author | Link Lin <linkl@google.com> | 2026-07-17 00:22:21 +0000 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2026-09-04 17:06:03 -0400 |
| commit | 612cf35c16f3d7b63a1fb36cdc2e1da9649e3c0d (patch) | |
| tree | 79f6d1dfe11bb85896d68cb3089672bd153852a6 /scripts/Makefile.thinlto | |
| parent | 1b3779dd63edfb45777efb31d99a9029cb011bf3 (diff) | |
| download | linux-next-612cf35c16f3d7b63a1fb36cdc2e1da9649e3c0d.tar.gz linux-next-612cf35c16f3d7b63a1fb36cdc2e1da9649e3c0d.zip | |
virtio_balloon: avoid shrinker execution during PM suspend
During PM freeze (e.g. S4 hibernation), virtballoon_freeze() calls
remove_common() which resets the virtio device and deletes all virtqueues.
However, the balloon shrinker remains registered with core MM.
If memory pressure occurs during S4 hibernation image creation/saving, MM
invokes virtio_balloon_shrinker_scan(), which attempts to reclaim free
pages. Although return_free_pages_to_mm() only frees pages back to MM,
reclaiming free pages under memory pressure can trigger page reporting
which might access the deleted reporting virtqueue if it is not yet
frozen, or interact with other parts of the driver in a teardown state.
Avoid this by adding a `suspended` flag to `struct virtio_balloon`. Set
this flag to true in virtballoon_freeze() and false in
virtballoon_restore(). Check this flag in both shrinker callbacks (scan
and count) and return 0 if the device is suspended, preventing any
shrinker execution while virtqueues are deleted. Wrap the lockless reads
in READ_ONCE() and writes in WRITE_ONCE() to prevent compiler
optimization issues and KCSAN data race warnings.
Fixes: 71019de8219b ("virtio_balloon: Add free page hinting support")
Cc: stable@vger.kernel.org
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Link Lin <linkl@google.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260717002311.681748-3-linkl@google.com>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
