[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170510135654.GD17121@cmpxchg.org>
Date: Wed, 10 May 2017 09:56:54 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Minchan Kim <minchan@...nel.org>
Cc: "Huang, Ying" <ying.huang@...el.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Andrea Arcangeli <aarcange@...hat.com>,
Ebru Akagunduz <ebru.akagunduz@...il.com>,
Michal Hocko <mhocko@...nel.org>, Tejun Heo <tj@...nel.org>,
Hugh Dickins <hughd@...gle.com>, Shaohua Li <shli@...nel.org>,
Rik van Riel <riel@...hat.com>, cgroups@...r.kernel.org
Subject: Re: [PATCH -mm -v10 1/3] mm, THP, swap: Delay splitting THP during
swap out
Hi Michan,
On Tue, May 02, 2017 at 08:53:32AM +0900, Minchan Kim wrote:
> @@ -1144,7 +1144,7 @@ void swap_free(swp_entry_t entry)
> /*
> * Called after dropping swapcache to decrease refcnt to swap entries.
> */
> -void swapcache_free(swp_entry_t entry)
> +void __swapcache_free(swp_entry_t entry)
> {
> struct swap_info_struct *p;
>
> @@ -1156,7 +1156,7 @@ void swapcache_free(swp_entry_t entry)
> }
>
> #ifdef CONFIG_THP_SWAP
> -void swapcache_free_cluster(swp_entry_t entry)
> +void __swapcache_free_cluster(swp_entry_t entry)
> {
> unsigned long offset = swp_offset(entry);
> unsigned long idx = offset / SWAPFILE_CLUSTER;
> @@ -1182,6 +1182,14 @@ void swapcache_free_cluster(swp_entry_t entry)
> }
> #endif /* CONFIG_THP_SWAP */
>
> +void swapcache_free(struct page *page, swp_entry_t entry)
> +{
> + if (!PageTransHuge(page))
> + __swapcache_free(entry);
> + else
> + __swapcache_free_cluster(entry);
> +}
I don't think this is cleaner :/
On your second patch:
> @@ -1125,8 +1125,28 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> !PageSwapCache(page)) {
> if (!(sc->gfp_mask & __GFP_IO))
> goto keep_locked;
> - if (!add_to_swap(page, page_list))
> +swap_retry:
> + /*
> + * Retry after split if we fail to allocate
> + * swap space of a THP.
> + */
> + if (!add_to_swap(page)) {
> + if (!PageTransHuge(page) ||
> + split_huge_page_to_list(page, page_list))
> + goto activate_locked;
> + goto swap_retry;
> + }
This is definitely better.
However, I think it'd be cleaner without the label here:
if (!add_to_swap(page)) {
if (!PageTransHuge(page))
goto activate_locked;
/* Split THP and swap individual base pages */
if (split_huge_page_to_list(page, page_list))
goto activate_locked;
if (!add_to_swap(page))
goto activate_locked;
}
> + /*
> + * Got swap space successfully. But unfortunately,
> + * we don't support a THP page writeout so split it.
> + */
> + if (PageTransHuge(page) &&
> + split_huge_page_to_list(page, page_list)) {
> + delete_from_swap_cache(page);
> goto activate_locked;
> + }
Pulling this out of add_to_swap() is an improvement for sure. Add an
XXX: before that "we don't support THP writes" comment for good
measure :)
Powered by blists - more mailing lists