From: "Huang\, Ying" <ying.huang@intel.com>
To: Tim Chen <tim.c.chen@linux.intel.com>
Cc: "Huang, Ying" <ying.huang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrea Arcangeli <aarcange@redhat.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Hugh Dickins <hughd@google.com>, Shaohua Li <shli@kernel.org>,
Minchan Kim <minchan@kernel.org>, Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH -mm -v6 5/9] mm, THP, swap: Support to clear SWAP_HAS_CACHE for huge page
Date: Wed, 15 Mar 2017 08:54:44 +0800 [thread overview]
Message-ID: <87a88ne4vf.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <1489536859.2733.53.camel@linux.intel.com> (Tim Chen's message of "Tue, 14 Mar 2017 17:14:19 -0700")
Tim Chen <tim.c.chen@linux.intel.com> writes:
> On Wed, 2017-03-08 at 15:26 +0800, Huang, Ying wrote:
>> From: Huang Ying <ying.huang@intel.com>
>>
>> __swapcache_free() is added to support to clear the SWAP_HAS_CACHE flag
>> for the huge page.A A This will free the specified swap cluster now.
>> Because now this function will be called only in the error path to free
>> the swap cluster just allocated.A A So the corresponding swap_map[i] ==
>> SWAP_HAS_CACHE, that is, the swap count is 0.A A This makes the
>> implementation simpler than that of the ordinary swap entry.
>>
>> This will be used for delaying splitting THP (Transparent Huge Page)
>> during swapping out.A A Where for one THP to swap out, we will allocate a
>> swap cluster, add the THP into the swap cache, then split the THP.A A If
>> anything fails after allocating the swap cluster and before splitting
>> the THP successfully, the swapcache_free_trans_huge() will be used to
>> free the swap space allocated.
>>
>> Cc: Andrea Arcangeli <aarcange@redhat.com>
>> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> Cc: Hugh Dickins <hughd@google.com>
>> Cc: Shaohua Li <shli@kernel.org>
>> Cc: Minchan Kim <minchan@kernel.org>
>> Cc: Rik van Riel <riel@redhat.com>
>> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
>> ---
>> A include/linux/swap.h |A A 9 +++++++--
>> A mm/swapfile.cA A A A A A A A | 34 ++++++++++++++++++++++++++++++++--
>> A 2 files changed, 39 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/linux/swap.h b/include/linux/swap.h
>> index e3a7609a8989..2f2a6c0363aa 100644
>> --- a/include/linux/swap.h
>> +++ b/include/linux/swap.h
>> @@ -394,7 +394,7 @@ extern void swap_shmem_alloc(swp_entry_t);
>> A extern int swap_duplicate(swp_entry_t);
>> A extern int swapcache_prepare(swp_entry_t);
>> A extern void swap_free(swp_entry_t);
>> -extern void swapcache_free(swp_entry_t);
>> +extern void __swapcache_free(swp_entry_t entry, bool huge);
>> A extern void swapcache_free_entries(swp_entry_t *entries, int n);
>> A extern int free_swap_and_cache(swp_entry_t);
>> A extern int swap_type_of(dev_t, sector_t, struct block_device **);
>> @@ -456,7 +456,7 @@ static inline void swap_free(swp_entry_t swp)
>> A {
>> A }
>> A
>> -static inline void swapcache_free(swp_entry_t swp)
>> +static inline void __swapcache_free(swp_entry_t swp, bool huge)
>> A {
>> A }
>> A
>> @@ -544,6 +544,11 @@ static inline swp_entry_t get_huge_swap_page(void)
>> A }
>> A #endif
>> A
>> +static inline void swapcache_free(swp_entry_t entry)
>> +{
>> + __swapcache_free(entry, false);
>> +}
>> +
>> A #ifdef CONFIG_MEMCG
>> A static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)
>> A {
>> diff --git a/mm/swapfile.c b/mm/swapfile.c
>> index 7241c937e52b..6019f94afbaf 100644
>> --- a/mm/swapfile.c
>> +++ b/mm/swapfile.c
>> @@ -855,6 +855,29 @@ static void swap_free_huge_cluster(struct swap_info_struct *si,
>> A _swap_entry_free(si, offset, true);
>> A }
>> A
>> +static void swapcache_free_trans_huge(struct swap_info_struct *si,
>> + A A A A A A swp_entry_t entry)
>> +{
>> + unsigned long offset = swp_offset(entry);
>> + unsigned long idx = offset / SWAPFILE_CLUSTER;
>> + struct swap_cluster_info *ci;
>> + unsigned char *map;
>> + unsigned int i;
>> +
>> + spin_lock(&si->lock);
>> + ci = lock_cluster(si, offset);
>> + map = si->swap_map + offset;
>> + for (i = 0; i < SWAPFILE_CLUSTER; i++) {
>> + VM_BUG_ON(map[i] != SWAP_HAS_CACHE);
>> + map[i] &= ~SWAP_HAS_CACHE;
>
> Nitpicking a bit:
> map[i] = 0 A is more readable if map[i] == SWAP_HAS_CACHE here.
OK. I will change this.
Best Regards,
Huang, Ying
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-03-15 0:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-08 7:26 [PATCH -v6 0/9] THP swap: Delay splitting THP during swapping out Huang, Ying
2017-03-08 7:26 ` [PATCH -mm -v6 1/9] mm, swap: Make swap cluster size same of THP size on x86_64 Huang, Ying
2017-03-08 12:56 ` Matthew Wilcox
2017-03-09 1:45 ` Huang, Ying
2017-03-08 7:26 ` [PATCH -mm -v6 2/9] mm, memcg: Support to charge/uncharge multiple swap entries Huang, Ying
2017-03-08 11:37 ` Balbir Singh
2017-03-09 1:28 ` Huang, Ying
2017-03-09 21:22 ` Balbir Singh
2017-03-08 7:26 ` [PATCH -mm -v6 3/9] mm, THP, swap: Add swap cluster allocate/free functions Huang, Ying
2017-03-14 23:13 ` Tim Chen
2017-03-15 1:19 ` Huang, Ying
2017-03-15 17:15 ` Tim Chen
2017-03-16 6:31 ` Huang, Ying
2017-03-08 7:26 ` [PATCH -mm -v6 4/9] mm, THP, swap: Add get_huge_swap_page() Huang, Ying
2017-03-14 23:40 ` Tim Chen
2017-03-15 1:08 ` Huang, Ying
2017-03-08 7:26 ` [PATCH -mm -v6 5/9] mm, THP, swap: Support to clear SWAP_HAS_CACHE for huge page Huang, Ying
2017-03-15 0:14 ` Tim Chen
2017-03-15 0:54 ` Huang, Ying [this message]
2017-03-08 7:26 ` [PATCH -mm -v6 6/9] mm, THP, swap: Support to add/delete THP to/from swap cache Huang, Ying
2017-03-08 7:26 ` [PATCH -mm -v6 7/9] mm, THP: Add can_split_huge_page() Huang, Ying
2017-03-08 7:26 ` [PATCH -mm -v6 8/9] mm, THP, swap: Support to split THP in swap cache Huang, Ying
2017-03-08 7:26 ` [PATCH -mm -v6 9/9] mm, THP, swap: Delay splitting THP during swap out Huang, Ying
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a88ne4vf.fsf@yhuang-dev.intel.com \
--to=ying.huang@intel.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
--cc=shli@kernel.org \
--cc=tim.c.chen@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).