[PATCH -mm -v2 04/12] mm, THP, swap: Don't allocate huge cluster for file backed swap device

2017-06-23 Thread Huang, Ying
From: Huang Ying It's hard to write a whole transparent huge page (THP) to a file backed swap device during swapping out and the file backed swap device isn't very popular. So the huge cluster allocation for the file backed swap device is disabled. Signed-off-by: "Huang, Ying

[PATCH -mm -v2 12/12] mm, THP, swap: Add THP swapping out fallback counting

2017-06-23 Thread Huang, Ying
From: Huang Ying When swapping out THP (Transparent Huge Page), instead of swapping out the THP as a whole, sometimes we have to fallback to split the THP into normal pages before swapping, because no free swap clusters are available, or cgroup limit is exceeded, etc. To count the number of the

[PATCH -mm -v2 08/12] memcg, THP, swap: Support move mem cgroup charge for THP swapped out

2017-06-23 Thread Huang, Ying
From: Huang Ying PTE mapped THP (Transparent Huge Page) will be ignored when moving memory cgroup charge. But for THP which is in the swap cache, the memory cgroup charge for the swap of a tail-page may be moved in current implementation. That isn't correct, because the swap charge for al

Re: [PATCH -mm 05/13] block, THP: Make block_device_operations.rw_page support THP

2017-06-04 Thread Huang, Ying
Ross Zwisler writes: > On Thu, May 25, 2017 at 02:46:27PM +0800, Huang, Ying wrote: >> From: Huang Ying >> >> The .rw_page in struct block_device_operations is used by the swap >> subsystem to read/write the page contents from/into the corresponding >> swap slo

Re: [PATCH -mm 06/13] block: Increase BIO_MAX_PAGES to PMD size if THP_SWAP enabled

2017-05-25 Thread Huang, Ying
Ming Lei writes: > On Thu, May 25, 2017 at 02:46:28PM +0800, Huang, Ying wrote: >> From: Huang Ying >> >> In this patch, BIO_MAX_PAGES is changed from 256 to HPAGE_PMD_NR if >> CONFIG_THP_SWAP is enabled and HPAGE_PMD_NR > 256. This is to support >&

[PATCH -mm 03/13] mm, THP, swap: Make reuse_swap_page() works for THP swapped out

2017-05-24 Thread Huang, Ying
From: Huang Ying After supporting to delay THP (Transparent Huge Page) splitting after swapped out, it is possible that some page table mappings of the THP are turned into swap entries. So reuse_swap_page() need to check the swap count in addition to the map count as before. This patch done

[PATCH -mm 04/13] mm, THP, swap: Don't allocate huge cluster for file backed swap device

2017-05-24 Thread Huang, Ying
From: Huang Ying It's hard to write a whole transparent huge page (THP) to a file backed swap device during swapping out and the file backed swap device isn't very popular. So the huge cluster allocation for the file backed swap device is disabled. Signed-off-by: "Huang, Ying

[PATCH -mm 05/13] block, THP: Make block_device_operations.rw_page support THP

2017-05-24 Thread Huang, Ying
From: Huang Ying The .rw_page in struct block_device_operations is used by the swap subsystem to read/write the page contents from/into the corresponding swap slot in the swap device. To support the THP (Transparent Huge Page) swap optimization, the .rw_page is enhanced to support to read/write

[PATCH -mm 00/13] mm, THP, swap: Delay splitting THP after swapped out

2017-05-24 Thread Huang, Ying
From: Huang Ying Hi, Andrew, could you help me to check whether the overall design is reasonable? Hi, Johannes and Minchan, Thanks a lot for your review to the first step of the THP swap optimization! Could you help me to review the second step in this patchset? Hi, Hugh, Shaohua, Minchan and

[PATCH -mm 06/13] block: Increase BIO_MAX_PAGES to PMD size if THP_SWAP enabled

2017-05-24 Thread Huang, Ying
From: Huang Ying In this patch, BIO_MAX_PAGES is changed from 256 to HPAGE_PMD_NR if CONFIG_THP_SWAP is enabled and HPAGE_PMD_NR > 256. This is to support THP (Transparent Huge Page) swap optimization. Where the THP will be write to disk as a whole instead of HPAGE_PMD_NR normal pages to ba

[PATCH -mm 09/13] memcg, THP, swap: Support move mem cgroup charge for THP swapped out

2017-05-24 Thread Huang, Ying
From: Huang Ying PTE mapped THP (Transparent Huge Page) will be ignored when moving memory cgroup charge. But for THP which is in the swap cache, the memory cgroup charge for the swap of a tail-page may be moved in current implementation. That isn't correct, because the swap charge for al

[PATCH -mm 13/13] mm, THP, swap: Add THP swapping out fallback counting

2017-05-24 Thread Huang, Ying
From: Huang Ying When swapping out THP (Transparent Huge Page), instead of swapping out the THP as a whole, sometimes we have to fallback to split the THP into normal pages before swapping, because no free swap clusters are available, or cgroup limit is exceeded, etc. To count the number of the

[PATCH -mm 11/13] memcg, THP, swap: Make mem_cgroup_swapout() support THP

2017-05-24 Thread Huang, Ying
From: Huang Ying This patch makes mem_cgroup_swapout() works for the transparent huge page (THP). Which will move the memory cgroup charge from memory to swap for a THP. This will be used for the THP swap support. Where a THP may be swapped out as a whole to a set of (HPAGE_PMD_NR) continuous

[PATCH -mm 10/13] memcg, THP, swap: Avoid to duplicated charge THP in swap cache

2017-05-24 Thread Huang, Ying
From: Huang Ying For a THP (Transparent Huge Page), tail_page->mem_cgroup is NULL. So to check whether the page is charged already, we need to check the head page. This is not an issue before because it is impossible for a THP to be in the swap cache before. But after we add delay

[PATCH -mm 12/13] mm, THP, swap: Delay splitting THP after swapped out

2017-05-24 Thread Huang, Ying
From: Huang Ying In this patch, splitting transparent huge page (THP) during swapping out is delayed from after adding the THP into the swap cache to after swapping out finishes. After the patch, more operations for the anonymous THP reclaiming, such as writing the THP to the swap device

[PATCH -mm 08/13] mm, THP, swap: Support to split THP for THP swapped out

2017-05-24 Thread Huang, Ying
From: Huang Ying After adding swapping out support for THP (Transparent Huge Page), it is possible that a THP in swap cache (partly swapped out) need to be split. To split such a THP, the swap cluster backing the THP need to be split too, that is, the CLUSTER_FLAG_HUGE flag need to be cleared

[PATCH -mm 07/13] mm, THP, swap: Support to write THP to swap device as a whole

2017-05-24 Thread Huang, Ying
From: Huang Ying In the patch, the swap writing is enhanced to support to write a THP (Transparent Huge Page) as a whole. This is a part of the THP swap optimization and will improve swap write IO performance for the more large continuous IOs. Signed-off-by: "Huang, Ying" Cc: Johan

[PATCH -mm 02/13] mm, THP, swap: Support to reclaim swap space for THP swapped out

2017-05-24 Thread Huang, Ying
From: Huang Ying The normal swap slot reclaiming can be done when the swap count reaches SWAP_HAS_CACHE. But for the swap slot which is backing a THP, all swap slots backing one THP must be reclaimed together, because the swap slot may be used again when the THP is swapped out again later. So

[PATCH -mm 01/13] mm, THP, swap: Support to clear swap cache flag for THP swapped out

2017-05-24 Thread Huang, Ying
From: Huang Ying Previously, swapcache_free_cluster() is used only in the error path of shrink_page_list() to free the swap cluster just allocated if the THP (Transparent Huge Page) is failed to be split. In this patch, it is enhanced to clear the swap cache flag (SWAP_HAS_CACHE) for the swap

[PATCH -mm -v6] mm, swap: Sort swap entries before free

2017-05-24 Thread Huang, Ying
From: Huang Ying To reduce the lock contention of swap_info_struct->lock when freeing swap entry. The freed swap entries will be collected in a per-CPU buffer firstly, and be really freed later in batch. During the batch freeing, if the consecutive swap entries in the per-CPU buffer belongs

[PATCH] mm, THP, swap: Check whether CONFIG_THP_SWAP enabled earlier

2017-05-21 Thread Huang, Ying
From: Huang Ying This patch is only a code clean up patch without functionality changes. It moves CONFIG_THP_SWAP checking from inside swap slot allocation to before we start swapping the THP. This makes the code path a little easier to be followed and understood. Signed-off-by: "Huang,

[PATCH -mm -v11 3/5] mm, THP, swap: Move anonymous THP split logic to vmscan

2017-05-15 Thread Huang, Ying
natural. Acked-by: Johannes Weiner Signed-off-by: Minchan Kim Signed-off-by: "Huang, Ying" --- include/linux/swap.h | 4 ++-- mm/swap_state.c | 23 ++- mm/vmscan.c | 17 - 3 files changed, 24 insertions(+), 20 deletions(-) diff --git

[PATCH -mm -v11 2/5] mm, THP, swap: Unify swap slot free functions to put_swap_page

2017-05-15 Thread Huang, Ying
size. [ying.hu...@intel.com: minor cleanup and fix] Acked-by: Johannes Weiner Signed-off-by: Minchan Kim Signed-off-by: "Huang, Ying" --- include/linux/swap.h | 12 ++-- mm/shmem.c | 2 +- mm/swap_state.c | 13 +++-- mm/swapfile.c| 16 +

[PATCH -mm -v11 4/5] mm, THP, swap: Check whether THP can be split firstly

2017-05-15 Thread Huang, Ying
From: Huang Ying To swap out THP (Transparent Huage Page), before splitting the THP, the swap cluster will be allocated and the THP will be added into the swap cache. But it is possible that the THP cannot be split, so that we must delete the THP from the swap cache and free the swap cluster

[PATCH -mm -v11 1/5] mm, THP, swap: Delay splitting THP during swap out

2017-05-15 Thread Huang, Ying
From: Huang Ying In this patch, splitting huge page is delayed from almost the first step of swapping out to after allocating the swap space for the THP (Transparent Huge Page) and adding the THP into the swap cache. This will batch the corresponding operation, thus improve THP swap out

[PATCH -mm -v11 5/5] mm, THP, swap: Enable THP swap optimization only if has compound map

2017-05-15 Thread Huang, Ying
From: Huang Ying If there is no compound map for a THP (Transparent Huge Page), it is possible that the map count of some sub-pages of the THP is 0. So it is better to split the THP before swapping out. In this way, the sub-pages not mapped will be freed, and we can avoid the unnecessary swap

[PATCH -mm -v11 0/5] THP swap: Delay splitting THP during swapping out

2017-05-15 Thread Huang, Ying
From: Huang Ying This patchset is to optimize the performance of Transparent Huge Page (THP) swap. Recently, the performance of the storage devices improved so fast that we cannot saturate the disk bandwidth with single logical CPU when do page swap out even on a high-end server machine

Re: [PATCH -mm -v10 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-05-10 Thread Huang, Ying
e) && >> > +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 :) > > Sure. > > It could be a separate patch which makes add_to_swap clean via > removing page_list argument but I hope Huang take/fold it when he > resend it because it would be more important with THP swap. Sure. I will take this patch as one patch of the THP swap series. Because the first patch of the THP swap series is a little big, I don't think it is a good idea to fold this patch into it. Could you update the patch according to Johannes' comments and resend it? Best Regards, Huang, Ying

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-05-01 Thread Huang, Ying
Minchan Kim writes: > Hi Huang, > > On Tue, May 02, 2017 at 01:35:24PM +0800, Huang, Ying wrote: >> Hi, Minchan, >> >> Minchan Kim writes: >> >> > On Fri, Apr 28, 2017 at 09:35:37PM +0800, Huang, Ying wrote: >> >> In fact, during

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-05-01 Thread Huang, Ying
Hi, Minchan, Minchan Kim writes: > On Fri, Apr 28, 2017 at 09:35:37PM +0800, Huang, Ying wrote: >> In fact, during the test, I found the overhead of sort() is comparable >> with the performance difference of adding likely()/unlikely() to the >> "if" in th

Re: [LKP] [lkp-robot] [sched/fair] 4c77b18cf8: hackbench.throughput -14.4% regression

2017-05-01 Thread Huang, Ying
te it. > > But given it was fingered by a human doing desktopy things that trumps > artificial benchmark. > > Still, I'll try and see if I can fix thing once I find a spare moment. Do you have any update for this regression? Don't want to push you, just want to get the latest status. Best Regards, Huang, Ying

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-28 Thread Huang, Ying
"Huang, Ying" writes: > Minchan Kim writes: > >> On Fri, Apr 28, 2017 at 04:05:26PM +0800, Huang, Ying wrote: >>> Minchan Kim writes: >>> >>> > On Fri, Apr 28, 2017 at 09:09:53AM +0800, Huang, Ying wrote: >>> >> Minchan Kim

Re: [PATCH -mm -v10 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-28 Thread Huang, Ying
Minchan Kim writes: > On Thu, Apr 27, 2017 at 03:12:34PM +0800, Huang, Ying wrote: >> Minchan Kim writes: >> >> > On Tue, Apr 25, 2017 at 08:56:56PM +0800, Huang, Ying wrote: >> >> From: Huang Ying >> >> >> >> In this patch, splitt

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-28 Thread Huang, Ying
Minchan Kim writes: > On Fri, Apr 28, 2017 at 04:05:26PM +0800, Huang, Ying wrote: >> Minchan Kim writes: >> >> > On Fri, Apr 28, 2017 at 09:09:53AM +0800, Huang, Ying wrote: >> >> Minchan Kim writes: >> >> >> >> > On Wed, Apr 26

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-28 Thread Huang, Ying
Minchan Kim writes: > On Fri, Apr 28, 2017 at 09:09:53AM +0800, Huang, Ying wrote: >> Minchan Kim writes: >> >> > On Wed, Apr 26, 2017 at 08:42:10PM +0800, Huang, Ying wrote: >> >> Minchan Kim writes: >> >> >> >> > On Fri, Apr 2

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-27 Thread Huang, Ying
Minchan Kim writes: > On Wed, Apr 26, 2017 at 08:42:10PM +0800, Huang, Ying wrote: >> Minchan Kim writes: >> >> > On Fri, Apr 21, 2017 at 08:29:30PM +0800, Huang, Ying wrote: >> >> "Huang, Ying" writes: >> >> >> >> >

Re: [PATCH -mm -v10 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-27 Thread Huang, Ying
Minchan Kim writes: > On Tue, Apr 25, 2017 at 08:56:56PM +0800, Huang, Ying wrote: >> From: Huang Ying >> >> In this patch, splitting huge page is delayed from almost the first >> step of swapping out to after allocating the swap space for the >> THP (Transpar

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-26 Thread Huang, Ying
Tim Chen writes: >> >> From 7bd903c42749c448ef6acbbdee8dcbc1c5b498b9 Mon Sep 17 00:00:00 2001 >> From: Huang Ying >> Date: Thu, 23 Feb 2017 13:05:20 +0800 >> Subject: [PATCH -v5] mm, swap: Sort swap entries before free >>

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-26 Thread Huang, Ying
Minchan Kim writes: > On Fri, Apr 21, 2017 at 08:29:30PM +0800, Huang, Ying wrote: >> "Huang, Ying" writes: >> >> > Minchan Kim writes: >> > >> >> On Wed, Apr 19, 2017 at 04:14:43PM +0800, Huang, Ying wrote: >> >>> Minchan

[PATCH -mm -v10 3/3] mm, THP, swap: Enable THP swap optimization only if has compound map

2017-04-25 Thread Huang, Ying
From: Huang Ying If there is no compound map for a THP (Transparent Huge Page), it is possible that the map count of some sub-pages of the THP is 0. So it is better to split the THP before swapping out. In this way, the sub-pages not mapped will be freed, and we can avoid the unnecessary swap

[PATCH -mm -v10 2/3] mm, THP, swap: Check whether THP can be split firstly

2017-04-25 Thread Huang, Ying
From: Huang Ying To swap out THP (Transparent Huage Page), before splitting the THP, the swap cluster will be allocated and the THP will be added into the swap cache. But it is possible that the THP cannot be split, so that we must delete the THP from the swap cache and free the swap cluster

[PATCH -mm -v10 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-25 Thread Huang, Ying
From: Huang Ying In this patch, splitting huge page is delayed from almost the first step of swapping out to after allocating the swap space for the THP (Transparent Huge Page) and adding the THP into the swap cache. This will batch the corresponding operation, thus improve THP swap out

[PATCH -mm -v10 0/3] THP swap: Delay splitting THP during swapping out

2017-04-25 Thread Huang, Ying
From: Huang Ying This patchset is to optimize the performance of Transparent Huge Page (THP) swap. Recently, the performance of the storage devices improved so fast that we cannot saturate the disk bandwidth with single logical CPU when do page swap out even on a high-end server machine

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-23 Thread Huang, Ying
Minchan Kim writes: > On Fri, Apr 21, 2017 at 08:29:30PM +0800, Huang, Ying wrote: >> "Huang, Ying" writes: >> >> > Minchan Kim writes: >> > >> >> On Wed, Apr 19, 2017 at 04:14:43PM +0800, Huang, Ying wrote: >> >>> Minchan

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-23 Thread Huang, Ying
Tim Chen writes: > On Fri, 2017-04-21 at 20:29 +0800, Huang, Ying wrote: >> "Huang, Ying" writes: >> >> > >> > Minchan Kim writes: >> > >> > > >> > > On Wed, Apr 19, 2017 at 04:14:43PM +0800, Huang, Ying wrote:

Re: [PATCH -mm -v9 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-21 Thread Huang, Ying
;swap_map + offset; >> > + for (i = 0; i < SWAPFILE_CLUSTER; i++) { >> > + VM_BUG_ON(map[i] != SWAP_HAS_CACHE); >> > + map[i] = 0; >> > + } >> > + unlock_cluster(ci); >> > + mem_cgroup_uncharge_swap(entry, SWAPFILE_CLUSTER); >> > + swap_free_cluster(si, idx); >> > + spin_unlock(&si->lock); >> > +} >> > +#endif /* CONFIG_THP_SWAP */ >> > + >> > static int swp_entry_cmp(const void *ent1, const void *ent2) >> > { >> >const swp_entry_t *e1 = ent1, *e2 = ent2; >> >> >> This is a massive patch, I presume you've got recommendations to keep it >> this way? > > It used to be split into patches that introduce API and helpers on one > hand and patches that use these functions on the other hand. That was > impossible to review, because you had to jump between emails. > > If you have ideas about which parts could be split out and be > stand-alone changes in their own right, I'd be all for that. Best Regards, Huang, Ying

[PATCH -mm] mm, swap: Fix swap space leak in error path of swap_free_entries()

2017-04-21 Thread Huang, Ying
From: Huang Ying In swapcache_free_entries(), if swap_info_get_cont() return NULL, something wrong occurs for the swap entry. But we should still continue to free the following swap entries in the array instead of skip them to avoid swap space leak. This is just problem in error path, where

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-21 Thread Huang, Ying
"Huang, Ying" writes: > Minchan Kim writes: > >> On Wed, Apr 19, 2017 at 04:14:43PM +0800, Huang, Ying wrote: >>> Minchan Kim writes: >>> >>> > Hi Huang, >>> > >>> > On Fri, Apr 07, 2017 at 02:49:

Re: [PATCH -mm -v9 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-21 Thread Huang, Ying
Balbir Singh writes: > On Wed, 2017-04-19 at 15:06 +0800, Huang, Ying wrote: >> From: Huang Ying >> >> In this patch, splitting huge page is delayed from almost the first >> step of swapping out to after allocating the swap space for the >> THP (Transparent H

Re: [PATCH -mm -v9 2/3] mm, THP, swap: Check whether THP can be split firstly

2017-04-20 Thread Huang, Ying
Johannes Weiner writes: > On Thu, Apr 20, 2017 at 08:50:43AM +0800, Huang, Ying wrote: >> Johannes Weiner writes: >> > On Wed, Apr 19, 2017 at 03:06:24PM +0800, Huang, Ying wrote: >> >> With the patchset, the swap out throughput improves 3.6% (from about >> &

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-20 Thread Huang, Ying
Minchan Kim writes: > On Wed, Apr 19, 2017 at 04:14:43PM +0800, Huang, Ying wrote: >> Minchan Kim writes: >> >> > Hi Huang, >> > >> > On Fri, Apr 07, 2017 at 02:49:01PM +0800, Huang, Ying wrote: >> >> From: Huang Ying >> >>

Re: [PATCH -mm -v9 3/3] mm, THP, swap: Enable THP swap optimization only if has compound map

2017-04-19 Thread Huang, Ying
Johannes Weiner writes: > On Wed, Apr 19, 2017 at 03:06:25PM +0800, Huang, Ying wrote: >> From: Huang Ying >> >> If there is no compound map for a THP (Transparent Huge Page), it is >> possible that the map count of some sub-pages of the THP is 0. So it >>

Re: [PATCH -mm -v9 2/3] mm, THP, swap: Check whether THP can be split firstly

2017-04-19 Thread Huang, Ying
Johannes Weiner writes: > On Wed, Apr 19, 2017 at 03:06:24PM +0800, Huang, Ying wrote: >> From: Huang Ying >> >> To swap out THP (Transparent Huage Page), before splitting the THP, >> the swap cluster will be allocated and the THP will be added into the >> swa

Re: [PATCH -mm -v9 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-19 Thread Huang, Ying
Hi, Johannes, Johannes Weiner writes: > On Wed, Apr 19, 2017 at 03:06:23PM +0800, Huang, Ying wrote: >> @@ -206,17 +212,34 @@ int add_to_swap(struct page *page, struct list_head >> *list) >> */ >> err = add_to_swap_cache(page, entry, >>

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-19 Thread Huang, Ying
Minchan Kim writes: > Hi Huang, > > On Fri, Apr 07, 2017 at 02:49:01PM +0800, Huang, Ying wrote: >> From: Huang Ying >> >> To reduce the lock contention of swap_info_struct->lock when freeing >> swap entry. The freed swap entries will be collected in a per-

[PATCH -mm -v9 2/3] mm, THP, swap: Check whether THP can be split firstly

2017-04-19 Thread Huang, Ying
From: Huang Ying To swap out THP (Transparent Huage Page), before splitting the THP, the swap cluster will be allocated and the THP will be added into the swap cache. But it is possible that the THP cannot be split, so that we must delete the THP from the swap cache and free the swap cluster

[PATCH -mm -v9 3/3] mm, THP, swap: Enable THP swap optimization only if has compound map

2017-04-19 Thread Huang, Ying
From: Huang Ying If there is no compound map for a THP (Transparent Huge Page), it is possible that the map count of some sub-pages of the THP is 0. So it is better to split the THP before swapping out. In this way, the sub-pages not mapped will be freed, and we can avoid the unnecessary swap

[PATCH -mm -v9 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-19 Thread Huang, Ying
From: Huang Ying In this patch, splitting huge page is delayed from almost the first step of swapping out to after allocating the swap space for the THP (Transparent Huge Page) and adding the THP into the swap cache. This will batch the corresponding operation, thus improve THP swap out

[PATCH -mm -v9 0/3] THP swap: Delay splitting THP during swapping out

2017-04-19 Thread Huang, Ying
From: Huang Ying This patchset is to optimize the performance of Transparent Huge Page (THP) swap. Recently, the performance of the storage devices improved so fast that we cannot saturate the disk bandwidth with single logical CPU when do page swap out even on a high-end server machine

Re: [PATCH -mm -v8 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-17 Thread Huang, Ying
Johannes Weiner writes: > On Sat, Apr 15, 2017 at 09:17:04AM +0800, Huang, Ying wrote: >> Hi, Johannes, >> >> Johannes Weiner writes: >> >> > Hi Huang, >> > >> > I reviewed this patch based on the feedback I already provided, but >

Re: [PATCH -mm -v8 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-14 Thread Huang, Ying
. Is 'XXX' here intended. > + > + For selection by architectures with reasonable THP sizes. > + > config TRANSPARENT_HUGE_PAGECACHE > def_bool y > depends on TRANSPARENT_HUGEPAGE > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index d14dd961f626..4a5c1ca21894 100644 [...] Best Regards, Huang, Ying

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-13 Thread Huang, Ying
Andrew Morton writes: > On Fri, 7 Apr 2017 14:49:01 +0800 "Huang, Ying" wrote: > >> To reduce the lock contention of swap_info_struct->lock when freeing >> swap entry. The freed swap entries will be collected in a per-CPU >> buffer firstly, and be rea

Re: [PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-11 Thread Huang, Ying
Andrew Morton writes: > On Fri, 7 Apr 2017 14:49:01 +0800 "Huang, Ying" wrote: > >> To reduce the lock contention of swap_info_struct->lock when freeing >> swap entry. The freed swap entries will be collected in a per-CPU >> buffer firstly, and be rea

[PATCH -mm -v3] mm, swap: Sort swap entries before free

2017-04-06 Thread Huang, Ying
From: Huang Ying To reduce the lock contention of swap_info_struct->lock when freeing swap entry. The freed swap entries will be collected in a per-CPU buffer firstly, and be really freed later in batch. During the batch freeing, if the consecutive swap entries in the per-CPU buffer belongs

[PATCH -mm -v3] mm, swap: Use kvzalloc to allocate some swap data structure

2017-04-06 Thread Huang, Ying
From: Huang Ying Now vzalloc() is used in swap code to allocate various data structures, such as swap cache, swap slots cache, cluster info, etc. Because the size may be too large on some system, so that normal kzalloc() may fail. But using kzalloc() has some advantages, for example, less

Re: [PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-04-06 Thread Huang, Ying
Hi, Matthew, Matthew Wilcox writes: > On Wed, Apr 05, 2017 at 03:10:58PM +0800, Huang, Ying wrote: >> In general, kmalloc() will have less memory fragmentation than >> vmalloc(). From Dave Hansen: For example, we have a two-page data >> structure. vmalloc() takes two eff

[PATCH -mm -v8 3/3] mm, THP, swap: Enable THP swap optimization only if has compound map

2017-04-05 Thread Huang, Ying
From: Huang Ying If there is no compound map for a THP (Transparent Huge Page), it is possible that the map count of some sub-pages of the THP is 0. So it is better to split the THP before swapping out. In this way, the sub-pages not mapped will be freed, and we can avoid the unnecessary swap

[PATCH -mm -v8 2/3] mm, THP, swap: Check whether THP can be split firstly

2017-04-05 Thread Huang, Ying
From: Huang Ying In the original THP swapping out implementation, before splitting the THP (Transparent Huage Page), the swap cluster will be allocated and the THP will be added into the swap cache. But it is possible that the THP cannot be split, and we must delete the THP from the swap cache

[PATCH -mm -v8 1/3] mm, THP, swap: Delay splitting THP during swap out

2017-04-05 Thread Huang, Ying
From: Huang Ying In this patch, splitting huge page is delayed from almost the first step of swapping out to after allocating the swap space for the THP (Transparent Huge Page) and adding the THP into the swap cache. This will batch the corresponding operation, thus improve THP swap out

[PATCH -mm -v8 0/3] THP swap: Delay splitting THP during swapping out

2017-04-05 Thread Huang, Ying
From: Huang Ying This patchset is to optimize the performance of Transparent Huge Page (THP) swap. Hi, Andrew, could you help me to check whether the overall design is reasonable? Hi, Hugh, Shaohua, Minchan and Rik, could you help me to review the swap part of the patchset? Hi, Andrea could

Re: [PATCH -mm -v2] mm, swap: Sort swap entries before free

2017-04-05 Thread Huang, Ying
Rik van Riel writes: > On Wed, 2017-04-05 at 15:10 +0800, Huang, Ying wrote: >> To solve the issue, the per-CPU buffer is sorted according to the >> swap >> device before freeing the swap entries.  Test shows that the time >> spent by swapcache_free_entries() could

[PATCH -mm -v2] mm, swap: Sort swap entries before free

2017-04-05 Thread Huang, Ying
From: Huang Ying To reduce the lock contention of swap_info_struct->lock when freeing swap entry. The freed swap entries will be collected in a per-CPU buffer firstly, and be really freed later in batch. During the batch freeing, if the consecutive swap entries in the per-CPU buffer belongs

[PATCH -mm -v2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-04-05 Thread Huang, Ying
From: Huang Ying Now vzalloc() is used in swap code to allocate various data structures, such as swap cache, swap slots cache, cluster info, etc. Because the size may be too large on some system, so that normal kzalloc() may fail. But using kzalloc() has some advantages, for example, less

[PATCH -mm] mm, swap: Remove unused function prototype

2017-04-05 Thread Huang, Ying
From: Huang Ying This is a code cleanup patch, no functionality changes. There are 2 unused function prototype in swap.h, they are removed. Signed-off-by: "Huang, Ying" Cc: Tim Chen --- include/linux/swap.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/swap.h

Re: [PATCH -v2 1/2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-04-04 Thread Huang, Ying
Michal Hocko writes: > On Sat 01-04-17 12:47:56, Huang, Ying wrote: >> Hi, Michal, >> >> Michal Hocko writes: >> >> > On Fri 24-03-17 06:56:10, Dave Hansen wrote: >> >> On 03/24/2017 12:33 AM, John Hubbard wrote: >> >> > There mig

Re: [PATCH -v2 1/2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-03-31 Thread Huang, Ying
More 2M pages == less fragmentation. > > Yes I agree with this. And the patch is no brainer. kvmalloc makes sure > to not try too hard on the kmalloc side so I really didn't get the > objection about direct compaction and reclaim which initially started > this discussion. Besides that the swapon path usually happens early > during the boot where we should have those larger blocks available. Could I add your Acked-by for this patch? Best Regards, Huang, Ying

Re: [PATCH -mm -v7 4/9] mm, THP, swap: Add get_huge_swap_page()

2017-03-31 Thread Huang, Ying
Johannes Weiner writes: > On Thu, Mar 30, 2017 at 12:28:17PM +0800, Huang, Ying wrote: >> Johannes Weiner writes: >> > On Tue, Mar 28, 2017 at 01:32:04PM +0800, Huang, Ying wrote: >> >> @@ -527,6 +527,23 @@ static inline swp_entry_t get_swap_page(void) >&g

Re: [PATCH -mm -v7 1/9] mm, swap: Make swap cluster size same of THP size on x86_64

2017-03-31 Thread Huang, Ying
Johannes Weiner writes: > On Thu, Mar 30, 2017 at 08:45:56AM +0800, Huang, Ying wrote: >> Johannes Weiner writes: >> >> > On Tue, Mar 28, 2017 at 01:32:01PM +0800, Huang, Ying wrote: >> >> @@ -499,6 +499,19 @@ config FRONTSWAP >> >>

Re: [PATCH -mm -v7 9/9] mm, THP, swap: Delay splitting THP during swap out

2017-03-31 Thread Huang, Ying
Johannes Weiner writes: > On Thu, Mar 30, 2017 at 12:15:13PM +0800, Huang, Ying wrote: >> Johannes Weiner writes: >> > On Tue, Mar 28, 2017 at 01:32:09PM +0800, Huang, Ying wrote: >> >> @@ -198,6 +240,18 @@ int add_to_swap(struct page *page, struct list_head >&

Re: [PATCH -mm -v7 4/9] mm, THP, swap: Add get_huge_swap_page()

2017-03-29 Thread Huang, Ying
Johannes Weiner writes: > On Tue, Mar 28, 2017 at 01:32:04PM +0800, Huang, Ying wrote: >> @@ -527,6 +527,23 @@ static inline swp_entry_t get_swap_page(void) >> >> #endif /* CONFIG_SWAP */ >> >> +#ifdef CONFIG_THP_SWAP_CLUSTER >> +static inl

Re: [PATCH -mm -v7 9/9] mm, THP, swap: Delay splitting THP during swap out

2017-03-29 Thread Huang, Ying
Johannes Weiner writes: > On Tue, Mar 28, 2017 at 01:32:09PM +0800, Huang, Ying wrote: >> @@ -183,12 +184,53 @@ void __delete_from_swap_cache(struct page *page) >> ADD_CACHE_INFO(del_total, nr); >> } >> >> +#ifdef CONFIG_THP_SWAP_CLUSTER >> +int a

Re: [PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries

2017-03-29 Thread Huang, Ying
Johannes Weiner writes: > On Tue, Mar 28, 2017 at 01:32:02PM +0800, Huang, Ying wrote: >> @@ -5908,16 +5907,19 @@ void mem_cgroup_swapout(struct page *page, >> swp_entry_t entry) >> css_put(&memcg->css); >> } >> >> -/* >>

Re: [PATCH -mm -v7 1/9] mm, swap: Make swap cluster size same of THP size on x86_64

2017-03-29 Thread Huang, Ying
Johannes Weiner writes: > On Tue, Mar 28, 2017 at 01:32:01PM +0800, Huang, Ying wrote: >> @@ -499,6 +499,19 @@ config FRONTSWAP >> >>If unsure, say Y to enable frontswap. >> >> +config ARCH_USES_THP_SWAP_CLUSTER >> +bool >>

Re: [PATCH -mm -v7 0/9] THP swap: Delay splitting THP during swapping out

2017-03-29 Thread Huang, Ying
Hi, Andrew, Andrew Morton writes: > On Tue, 28 Mar 2017 13:32:00 +0800 "Huang, Ying" wrote: > >> Hi, Andrew, could you help me to check whether the overall design is >> reasonable? >> >> Hi, Hugh, Shaohua, Minchan and Rik, could you help me to

Re: [PATCH -mm -v7 1/9] mm, swap: Make swap cluster size same of THP size on x86_64

2017-03-28 Thread Huang, Ying
"Kirill A. Shutemov" writes: > On Tue, Mar 28, 2017 at 01:32:01PM +0800, Huang, Ying wrote: >> From: Huang Ying >> >> In this patch, the size of the swap cluster is changed to that of the >> THP (Transparent Huge Page) on x86_64 architecture (512). T

[PATCH -mm -v7 8/9] mm, THP, swap: Support to split THP in swap cache

2017-03-27 Thread Huang, Ying
From: Huang Ying This patch enhanced the split_huge_page_to_list() to work properly for the THP (Transparent Huge Page) in the swap cache during swapping out. This is used for delaying splitting the THP during swapping out. Where for a THP to be swapped out, we will allocate a swap cluster

[PATCH -mm -v7 4/9] mm, THP, swap: Add get_huge_swap_page()

2017-03-27 Thread Huang, Ying
From: Huang Ying A variation of get_swap_page(), get_huge_swap_page(), is added to allocate a swap cluster (HPAGE_PMD_NR swap slots) based on the swap cluster allocation function. A fair simple algorithm is used, that is, only the first swap device in priority list will be tried to allocate the

[PATCH -mm -v7 2/9] mm, memcg: Support to charge/uncharge multiple swap entries

2017-03-27 Thread Huang, Ying
From: Huang Ying This patch make it possible to charge or uncharge a set of continuous swap entries in the swap cgroup. The number of swap entries is specified via an added parameter. This will be used for the THP (Transparent Huge Page) swap support. Where a swap cluster backing a THP may be

[PATCH -mm -v7 6/9] mm, THP, swap: Support to add/delete THP to/from swap cache

2017-03-27 Thread Huang, Ying
From: Huang Ying With this patch, a THP (Transparent Huge Page) can be added/deleted to/from the swap cache as a set of (HPAGE_PMD_NR) sub-pages. This will be used for the THP (Transparent Huge Page) swap support. Where one THP may be added/delted to/from the swap cache. This will batch the

[PATCH -mm -v7 0/9] THP swap: Delay splitting THP during swapping out

2017-03-27 Thread Huang, Ying
From: Huang Ying Hi, Andrew, could you help me to check whether the overall design is reasonable? Hi, Hugh, Shaohua, Minchan and Rik, could you help me to review the swap part of the patchset? Especially [1/9], [3/9], [4/9], [5/9], [6/9], [9/9]. Hi, Andrea could you help me to review the THP

[PATCH -mm -v7 9/9] mm, THP, swap: Delay splitting THP during swap out

2017-03-27 Thread Huang, Ying
From: Huang Ying In this patch, splitting huge page is delayed from almost the first step of swapping out to after allocating the swap space for the THP (Transparent Huge Page) and adding the THP into the swap cache. This will reduce lock acquiring/releasing for the locks used for the swap cache

[PATCH -mm -v7 3/9] mm, THP, swap: Add swap cluster allocate/free functions

2017-03-27 Thread Huang, Ying
From: Huang Ying The swap cluster allocation/free functions are added based on the existing swap cluster management mechanism for SSD. These functions don't work for the rotating hard disks because the existing swap cluster management mechanism doesn't work for them. The hard disks s

[PATCH -mm -v7 5/9] mm, THP, swap: Support to clear SWAP_HAS_CACHE for huge page

2017-03-27 Thread Huang, Ying
From: Huang Ying __swapcache_free() is added to support to clear the SWAP_HAS_CACHE flag for the huge page. 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. So the corresponding swap_map[i

[PATCH -mm -v7 7/9] mm, THP: Add can_split_huge_page()

2017-03-27 Thread Huang, Ying
From: Huang Ying Separates checking whether we can split the huge page from split_huge_page_to_list() into a function. This will help to check that before splitting the THP (Transparent Huge Page) really. This will be used for delaying splitting THP during swapping out. Where for a THP, we

[PATCH -mm -v7 1/9] mm, swap: Make swap cluster size same of THP size on x86_64

2017-03-27 Thread Huang, Ying
From: Huang Ying In this patch, the size of the swap cluster is changed to that of the THP (Transparent Huge Page) on x86_64 architecture (512). This is for the THP swap support on x86_64. Where one swap cluster will be used to hold the contents of each THP swapped out. And some information

Re: [PATCH -v2 1/2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-03-24 Thread Huang, Ying
John Hubbard writes: > On 03/23/2017 09:52 PM, Huang, Ying wrote: >> John Hubbard writes: >> >>> On 03/23/2017 07:41 PM, Huang, Ying wrote: >>>> David Rientjes writes: >>>> >>>>> On Mon, 20 Mar 2017, Huang, Ying wrote: >>>

Re: [PATCH -v2 1/2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-03-23 Thread Huang, Ying
John Hubbard writes: > On 03/23/2017 07:41 PM, Huang, Ying wrote: >> David Rientjes writes: >> >>> On Mon, 20 Mar 2017, Huang, Ying wrote: >>> >>>> From: Huang Ying >>>> >>>> Now vzalloc() is used in swap code to alloca

Re: [PATCH -v2 1/2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-03-23 Thread Huang, Ying
David Rientjes writes: > On Mon, 20 Mar 2017, Huang, Ying wrote: > >> From: Huang Ying >> >> Now vzalloc() is used in swap code to allocate various data >> structures, such as swap cache, swap slots cache, cluster info, etc. >> Because the size may be too

[PATCH -v2 1/2] mm, swap: Use kvzalloc to allocate some swap data structure

2017-03-20 Thread Huang, Ying
From: Huang Ying Now vzalloc() is used in swap code to allocate various data structures, such as swap cache, swap slots cache, cluster info, etc. Because the size may be too large on some system, so that normal kzalloc() may fail. But using kzalloc() has some advantages, for example, less

[PATCH -v2 2/2] mm, swap: Sort swap entries before free

2017-03-20 Thread Huang, Ying
From: Huang Ying To reduce the lock contention of swap_info_struct->lock when freeing swap entry. The freed swap entries will be collected in a per-CPU buffer firstly, and be really freed later in batch. During the batch freeing, if the consecutive swap entries in the per-CPU buffer belongs

<    5   6   7   8   9   10   11   12   13   14   >