Re: [PATCH 3/3] mm: fail the fault on a malformed swap entry instead of retrying it

From: David Hildenbrand (Arm)

Date: Wed Aug 12 2026 - 07:10:29 EST


On 8/12/26 12:59, Pedro Falcato wrote:
> On Mon, Aug 10, 2026 at 09:26:51AM -0700, Breno Leitao wrote:
>> do_swap_page() returns 0 when get_swap_device() fails, which the fault
>> handler reads as "handled". For an entry that can never become valid
>> the retry takes the same fault again, so the thread spins until it is
>> killed.
>>
>> Return VM_FAULT_SIGBUS for a malformed entry, as the sibling arm
>> already does for an unrecognised non-swap entry. A NULL return still
>> means swapoff, which is still worth retrying.
>
> What kind of SIGBUS do you get from this? as in the si_code. Out of all
> the options
>
> #define BUS_ADRALN 1 /* invalid address alignment */
> #define BUS_ADRERR 2 /* non-existent physical address */
> #define BUS_OBJERR 3 /* object specific hardware error */
> /* hardware memory error consumed on a machine check: action required */
> #define BUS_MCEERR_AR 4
> /* hardware memory error detected in process but not consumed: action optional*/
> #define BUS_MCEERR_AO 5
>
> I would say this would fit none of them. The default (AFAICT) would be
> BUS_ADRERR, and I think that one is quite overloaded with meaning (namely,
> with regards to memory-mapped IO past EOF, or EIO on file IO). I wouldn't
> love to also use it for this, IMO.

Note that what is discussed here that should usually happen unless kernel bug.
So I don't think we have to worry about the details here, really.

It's similar to the VM_FAULT_SIGBUS handling earlier in the function after the
print_bad_pte().

--
Cheers,

David