Re: [RFC 07/11] mm: remove SWAP_AGAIN in ttu

From: Anshuman Khandual
Date: Fri Mar 03 2017 - 11:12:00 EST


On 03/02/2017 12:09 PM, Minchan Kim wrote:
> In 2002, [1] introduced SWAP_AGAIN.
> At that time, ttuo used spin_trylock(&mm->page_table_lock) so it's

Small nit: Please expand "ttuo" here. TTU in the first place is also
not very clear but we have that in many places.

> really easy to contend and fail to hold a lock so SWAP_AGAIN to keep
> LRU status makes sense.

Okay.

>
> However, now we changed it to mutex-based lock and be able to block
> without skip pte so there is a few of small window to return
> SWAP_AGAIN so remove SWAP_AGAIN and just return SWAP_FAIL.

Makes sense.

>
> [1] c48c43e, minimal rmap
> Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
> ---
> mm/rmap.c | 11 +++--------
> mm/vmscan.c | 2 --
> 2 files changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 47898a1..da18f21 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1492,13 +1492,10 @@ static int page_mapcount_is_zero(struct page *page)
> * Return values are:
> *
> * SWAP_SUCCESS - we succeeded in removing all mappings
> - * SWAP_AGAIN - we missed a mapping, try again later
> * SWAP_FAIL - the page is unswappable
> */
> int try_to_unmap(struct page *page, enum ttu_flags flags)
> {
> - int ret;
> -
> struct rmap_walk_control rwc = {
> .rmap_one = try_to_unmap_one,
> .arg = (void *)flags,
> @@ -1518,13 +1515,11 @@ int try_to_unmap(struct page *page, enum ttu_flags flags)
> rwc.invalid_vma = invalid_migration_vma;
>
> if (flags & TTU_RMAP_LOCKED)
> - ret = rmap_walk_locked(page, &rwc);
> + rmap_walk_locked(page, &rwc);
> else
> - ret = rmap_walk(page, &rwc);
> + rmap_walk(page, &rwc);
>
> - if (!page_mapcount(page))
> - ret = SWAP_SUCCESS;
> - return ret;
> + return !page_mapcount(page) ? SWAP_SUCCESS: SWAP_FAIL;

Its very simple now. So after the rmap_walk() if page is not mapped any
more return SWAP_SUCCESS otherwise SWAP_FAIL.