Skip to content

Improve swap page error handling

Richard Purdie lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4swap: Have swap_free() mark pages with errors as badinclude/linux/swap.h kernel/power/swsusp.c mm/memory.c +4 more+26 -180 replies
2/4swap: Add try_to_unuse_page_entry()include/linux/rmap.h include/linux/swap.h mm/rmap.c +1 more+63 -10 replies
3/4swap: Catch pages with errors and mark as badmm/page_io.c mm/vmscan.c+9 -30 replies
4/4swap: Simplify shmem_unuse() usagemm/shmem.c mm/swapfile.c+7 -280 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] Improve swap page error handling

Improve the error handling when writes fail to a swap page.

Currently, the kernel will repeatedly retry the write which is unlikely to ever succeed. Instead we allow the pages to be unused and then marked as bad at which prevents reuse. It should hopefully be suitable for testing in -mm.

Hugh Dickins (on a previous incarnation of this series):

Quoted 3 lines

No, not this way, I'm afraid. Sorry, I don't remember the prior discussion on LKML, must have flooded past when my attention was elsewhere.

I think you were cc'd on some of it but you never commented. Anyhow, I've reworked this patch series based on your comments. The hints were appreciated, thanks. This was the way I'd originally hoped to be able to work things, I just couldn't find the right way to do it.

Quoted 6 lines

Is it worth doing this at all? Probably, but I've no experience whatsoever of swap write errors, so it's hard for me to judge: my guess is that many cases would turn out to be software errors (e.g. lower level needing more memory to perform the write). But you'd be right to counter: let's assume they're hardware errors, and then fix up any software errors when reported.

I have a swap block driver where hardware write errors are more likely and hence have a need to handle them more gracefully than IO loops. It seems like a good idea to avoid the IO loops anyway.

Quoted 4 lines

If it is worth doing this, then you'll need to add code to write back the swap header, to note the bad pages permanently: you may well have been waiting to see what reception the patches so far get, before embarking on that.

You can't proceed to do that until you're able to identify the bad pages so this would be a necessary first step towards that, yes.

Quoted 2 lines

I was uneasy with 2/4, wondered if swap_free(entry, page) would be a better direction to go than your swap_free_markbad(entry).

Agreed, see the following 1/4.

Patch 4/4 in this series is optional but its appended in hope. It cleans up code at the expense of what looks like a performance optimisation. I found the code as it stands rather confusing as a newcomer to that code.

Richard