All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm:swap: do not check readahead flag with THP anon
@ 2018-02-27 23:26 ` Minchan Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Minchan Kim @ 2018-02-27 23:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, lkml, Minchan Kim, Hugh Dickins, Huang, Ying

Huang reported PG_readahead flag marked PF_NO_COMPOUND so that
we cannot use the flag for THP page. So, we need to check first
whether page is THP or not before using TestClearPageReadahead
in lookup_swap_cache.

This patch fixes it.

Furthermore, swap_[cluster|vma]_readahead cannot mark PG_readahead
for newly allocated page because the allocated page is always a
normal page, not THP at this moment. So let's clean it up, too.

Cc: Hugh Dickins <hughd@google.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 mm/swap_state.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index 8dde719e973c..1c4ac3220f41 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -348,12 +348,17 @@ struct page *lookup_swap_cache(swp_entry_t entry, struct vm_area_struct *vma,
 	INC_CACHE_INFO(find_total);
 	if (page) {
 		bool vma_ra = swap_use_vma_readahead();
-		bool readahead = TestClearPageReadahead(page);
+		bool readahead;
 
 		INC_CACHE_INFO(find_success);
+		/*
+		 * At the moment, we don't support PG_readahead for anon THP
+		 * so let's bail out rather than confusing the readahead stat.
+		 */
 		if (unlikely(PageTransCompound(page)))
 			return page;
 
+		readahead = TestClearPageReadahead(page);
 		if (vma && vma_ra) {
 			unsigned long ra_val;
 			int win, hits;
@@ -608,8 +613,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
 			continue;
 		if (page_allocated) {
 			swap_readpage(page, false);
-			if (offset != entry_offset &&
-			    likely(!PageTransCompound(page))) {
+			if (offset != entry_offset) {
 				SetPageReadahead(page);
 				count_vm_event(SWAP_RA);
 			}
@@ -772,8 +776,7 @@ struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask,
 			continue;
 		if (page_allocated) {
 			swap_readpage(page, false);
-			if (i != ra_info.offset &&
-			    likely(!PageTransCompound(page))) {
+			if (i != ra_info.offset) {
 				SetPageReadahead(page);
 				count_vm_event(SWAP_RA);
 			}
-- 
2.16.2.395.g2e18187dfd-goog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] mm:swap: do not check readahead flag with THP anon
@ 2018-02-27 23:26 ` Minchan Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Minchan Kim @ 2018-02-27 23:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, lkml, Minchan Kim, Hugh Dickins, Huang, Ying

Huang reported PG_readahead flag marked PF_NO_COMPOUND so that
we cannot use the flag for THP page. So, we need to check first
whether page is THP or not before using TestClearPageReadahead
in lookup_swap_cache.

This patch fixes it.

Furthermore, swap_[cluster|vma]_readahead cannot mark PG_readahead
for newly allocated page because the allocated page is always a
normal page, not THP at this moment. So let's clean it up, too.

Cc: Hugh Dickins <hughd@google.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 mm/swap_state.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index 8dde719e973c..1c4ac3220f41 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -348,12 +348,17 @@ struct page *lookup_swap_cache(swp_entry_t entry, struct vm_area_struct *vma,
 	INC_CACHE_INFO(find_total);
 	if (page) {
 		bool vma_ra = swap_use_vma_readahead();
-		bool readahead = TestClearPageReadahead(page);
+		bool readahead;
 
 		INC_CACHE_INFO(find_success);
+		/*
+		 * At the moment, we don't support PG_readahead for anon THP
+		 * so let's bail out rather than confusing the readahead stat.
+		 */
 		if (unlikely(PageTransCompound(page)))
 			return page;
 
+		readahead = TestClearPageReadahead(page);
 		if (vma && vma_ra) {
 			unsigned long ra_val;
 			int win, hits;
@@ -608,8 +613,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
 			continue;
 		if (page_allocated) {
 			swap_readpage(page, false);
-			if (offset != entry_offset &&
-			    likely(!PageTransCompound(page))) {
+			if (offset != entry_offset) {
 				SetPageReadahead(page);
 				count_vm_event(SWAP_RA);
 			}
@@ -772,8 +776,7 @@ struct page *swap_vma_readahead(swp_entry_t fentry, gfp_t gfp_mask,
 			continue;
 		if (page_allocated) {
 			swap_readpage(page, false);
-			if (i != ra_info.offset &&
-			    likely(!PageTransCompound(page))) {
+			if (i != ra_info.offset) {
 				SetPageReadahead(page);
 				count_vm_event(SWAP_RA);
 			}
-- 
2.16.2.395.g2e18187dfd-goog

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm:swap: do not check readahead flag with THP anon
  2018-02-27 23:26 ` Minchan Kim
@ 2018-02-27 23:29   ` Minchan Kim
  -1 siblings, 0 replies; 4+ messages in thread
From: Minchan Kim @ 2018-02-27 23:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, lkml, Hugh Dickins, Huang, Ying

On Wed, Feb 28, 2018 at 08:26:11AM +0900, Minchan Kim wrote:
> Huang reported PG_readahead flag marked PF_NO_COMPOUND so that
> we cannot use the flag for THP page. So, we need to check first
> whether page is THP or not before using TestClearPageReadahead
> in lookup_swap_cache.
> 
> This patch fixes it.
> 
> Furthermore, swap_[cluster|vma]_readahead cannot mark PG_readahead
> for newly allocated page because the allocated page is always a
> normal page, not THP at this moment. So let's clean it up, too.
> 
> Cc: Hugh Dickins <hughd@google.com>
> Cc: "Huang, Ying" <ying.huang@intel.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>

 Link:http://lkml.kernel.org/r/874lm83zho.fsf@yhuang-dev.intel.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm:swap: do not check readahead flag with THP anon
@ 2018-02-27 23:29   ` Minchan Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Minchan Kim @ 2018-02-27 23:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, lkml, Hugh Dickins, Huang, Ying

On Wed, Feb 28, 2018 at 08:26:11AM +0900, Minchan Kim wrote:
> Huang reported PG_readahead flag marked PF_NO_COMPOUND so that
> we cannot use the flag for THP page. So, we need to check first
> whether page is THP or not before using TestClearPageReadahead
> in lookup_swap_cache.
> 
> This patch fixes it.
> 
> Furthermore, swap_[cluster|vma]_readahead cannot mark PG_readahead
> for newly allocated page because the allocated page is always a
> normal page, not THP at this moment. So let's clean it up, too.
> 
> Cc: Hugh Dickins <hughd@google.com>
> Cc: "Huang, Ying" <ying.huang@intel.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>

 Link:http://lkml.kernel.org/r/874lm83zho.fsf@yhuang-dev.intel.com

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-27 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 23:26 [PATCH] mm:swap: do not check readahead flag with THP anon Minchan Kim
2018-02-27 23:26 ` Minchan Kim
2018-02-27 23:29 ` Minchan Kim
2018-02-27 23:29   ` Minchan Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.