On Tue, 1 Jan 2019, Vineeth Pillai wrote: > Thanks a lot for the fixes and detailed explanation Hugh! I shall fold all > the changes from you and Huang in the next iteration. > > Thanks for all the suggestions and comments as well. I am looking into all > those and will include all the changes in the next version. Will discuss > over mail in case of any clarifications. One more fix on top of what I sent yesterday: once I delved into the retries, I found that the major cause of exceeding MAX_RETRIES was the way the retry code neatly avoided retrying the last part of its work. With this fix in, I have not yet seen retries go above 1: no doubt it could, but at present I have no actual evidence that the MAX_RETRIES-or-livelock issue needs to be dealt with urgently. Fix sent for completeness, but it reinforces the point that the structure of try_to_unuse() should be reworked, and oldi gone. Hugh --- mm/swapfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- mmotm/mm/swapfile.c 2018-12-31 12:30:55.822407154 -0800 +++ linux/mm/swapfile.c 2019-01-01 19:50:34.377277830 -0800 @@ -2107,8 +2107,8 @@ int try_to_unuse(unsigned int type, bool struct swap_info_struct *si = swap_info[type]; struct page *page; swp_entry_t entry; - unsigned int i = 0; - unsigned int oldi = 0; + unsigned int i; + unsigned int oldi; int retries = 0; if (!frontswap) @@ -2154,6 +2154,7 @@ retry: goto out; } + i = oldi = 0; while ((i = find_next_to_unuse(si, i, frontswap)) != 0) { /* * Under global memory pressure, swap entries