Re: [PATCH] mm, swap: ratelimit bad swap entry reports

From: Andrew Morton

Date: Tue Aug 18 2026 - 15:37:25 EST


On Tue, 18 Aug 2026 02:03:40 -0700 Breno Leitao <leitao@xxxxxxxxxx> wrote:

> A corrupt page table hands the same bogus entry to get_swap_device() on
> every access to the mapping, and every rejection is logged. One machine
> logged 6185620 copies of the same line in a few hours.
>
> swap_dup_entry_direct() prints the same message from the fork path, once
> per call: the WARN_ON_ONCE() guarding it warns once, the pr_err() inside
> does not.
>
> Rate limit all three prints.

Sashiko suggests that ratelimiting these might cause pre-existing
problems to become worse:
https://sashiko.dev/#/patchset/20260818-swap_part_one-v1-1-a4fc58119fc0@xxxxxxxxxx

The problem it's identifying does require that unrelated things go
wrong first - get_swap_device() failed, swap_retry_table_alloc() did a
retry. So presumably you wouldn't have hit this in testing.

Sigh, so much to fix.