[2/2] migrate_pages_batch: code cleanup: remove is_large

Message ID 20230509022014.380493-2-ying.huang@intel.com
State New
Headers
Series [1/2] migrate_pages_batch: simplify retrying and failure counting of large folios |

Commit Message

Huang, Ying May 9, 2023, 2:20 a.m. UTC
  Previously, in migrate_pages_batch we need to track whether the source
folio is large/THP before splitting.  So is_large is used to cache
folio_test_large() result.  Now, we don't need that variable any more
because we don't count retrying and failure of large folios (only
counting that of THP folios).  So, in this patch, is_large is removed
to simplify the code.

This is just code cleanup, no functionality changes are expected.

Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Xin Hao <xhao@linux.alibaba.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Alistair Popple <apopple@nvidia.com>
---
 mm/migrate.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
  

Comments

Alistair Popple May 9, 2023, 4:33 a.m. UTC | #1
Huang Ying <ying.huang@intel.com> writes:

> Previously, in migrate_pages_batch we need to track whether the source
> folio is large/THP before splitting.  So is_large is used to cache
> folio_test_large() result.  Now, we don't need that variable any more
> because we don't count retrying and failure of large folios (only
> counting that of THP folios).  So, in this patch, is_large is removed
> to simplify the code.
>
> This is just code cleanup, no functionality changes are expected.

Reviewed-by: Alistair Popple <apopple@nvidia.com>

> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
> Cc: Xin Hao <xhao@linux.alibaba.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Yang Shi <shy828301@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Alistair Popple <apopple@nvidia.com>
> ---
>  mm/migrate.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 10709aed76d3..2ac927a82bbc 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1618,7 +1618,6 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
>  	int nr_failed = 0;
>  	int nr_retry_pages = 0;
>  	int pass = 0;
> -	bool is_large = false;
>  	bool is_thp = false;
>  	struct folio *folio, *folio2, *dst = NULL, *dst2;
>  	int rc, rc_saved = 0, nr_pages;
> @@ -1635,13 +1634,7 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
>  		nr_retry_pages = 0;
>  
>  		list_for_each_entry_safe(folio, folio2, from, lru) {
> -			/*
> -			 * Large folio statistics is based on the source large
> -			 * folio. Capture required information that might get
> -			 * lost during migration.
> -			 */
> -			is_large = folio_test_large(folio);
> -			is_thp = is_large && folio_test_pmd_mappable(folio);
> +			is_thp = folio_test_large(folio) && folio_test_pmd_mappable(folio);
>  			nr_pages = folio_nr_pages(folio);
>  
>  			cond_resched();
> @@ -1688,7 +1681,7 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
>  				nr_failed++;
>  				stats->nr_thp_failed += is_thp;
>  				/* Large folio NUMA faulting doesn't split to retry. */
> -				if (is_large && !nosplit) {
> +				if (folio_test_large(folio) && !nosplit) {
>  					int ret = try_split_folio(folio, split_folios);
>  
>  					if (!ret) {
  
Zi Yan May 9, 2023, 2:26 p.m. UTC | #2
On 8 May 2023, at 22:20, Huang Ying wrote:

> Previously, in migrate_pages_batch we need to track whether the source
> folio is large/THP before splitting.  So is_large is used to cache
> folio_test_large() result.  Now, we don't need that variable any more
> because we don't count retrying and failure of large folios (only
> counting that of THP folios).  So, in this patch, is_large is removed
> to simplify the code.
>
> This is just code cleanup, no functionality changes are expected.
>
> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
> Cc: Xin Hao <xhao@linux.alibaba.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Yang Shi <shy828301@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Alistair Popple <apopple@nvidia.com>
> ---
>  mm/migrate.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
>


LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>

--
Best Regards,
Yan, Zi
  
haoxin May 10, 2023, 1:50 a.m. UTC | #3
在 2023/5/9 上午10:20, Huang Ying 写道:
> Previously, in migrate_pages_batch we need to track whether the source
> folio is large/THP before splitting.  So is_large is used to cache
> folio_test_large() result.  Now, we don't need that variable any more
> because we don't count retrying and failure of large folios (only
> counting that of THP folios).  So, in this patch, is_large is removed
> to simplify the code.
>
> This is just code cleanup, no functionality changes are expected.
>
> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
> Cc: Xin Hao <xhao@linux.alibaba.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Yang Shi <shy828301@gmail.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Alistair Popple <apopple@nvidia.com>
> ---
>   mm/migrate.c | 11 ++---------
>   1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 10709aed76d3..2ac927a82bbc 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1618,7 +1618,6 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
>   	int nr_failed = 0;
>   	int nr_retry_pages = 0;
>   	int pass = 0;
> -	bool is_large = false;
>   	bool is_thp = false;
>   	struct folio *folio, *folio2, *dst = NULL, *dst2;
>   	int rc, rc_saved = 0, nr_pages;
> @@ -1635,13 +1634,7 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
>   		nr_retry_pages = 0;
>   
>   		list_for_each_entry_safe(folio, folio2, from, lru) {
> -			/*
> -			 * Large folio statistics is based on the source large
> -			 * folio. Capture required information that might get
> -			 * lost during migration.
> -			 */
> -			is_large = folio_test_large(folio);
> -			is_thp = is_large && folio_test_pmd_mappable(folio);
> +			is_thp = folio_test_large(folio) && folio_test_pmd_mappable(folio);
>   			nr_pages = folio_nr_pages(folio);
>   
>   			cond_resched();
> @@ -1688,7 +1681,7 @@ static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
>   				nr_failed++;
>   				stats->nr_thp_failed += is_thp;
>   				/* Large folio NUMA faulting doesn't split to retry. */
> -				if (is_large && !nosplit) {
> +				if (folio_test_large(folio) && !nosplit) {
>   					int ret = try_split_folio(folio, split_folios);
>   
>   					if (!ret) {
LGTM.
Reviewed-by: Xin Hao <xhao@linux.alibaba.com>
  

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index 10709aed76d3..2ac927a82bbc 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1618,7 +1618,6 @@  static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
 	int nr_failed = 0;
 	int nr_retry_pages = 0;
 	int pass = 0;
-	bool is_large = false;
 	bool is_thp = false;
 	struct folio *folio, *folio2, *dst = NULL, *dst2;
 	int rc, rc_saved = 0, nr_pages;
@@ -1635,13 +1634,7 @@  static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
 		nr_retry_pages = 0;
 
 		list_for_each_entry_safe(folio, folio2, from, lru) {
-			/*
-			 * Large folio statistics is based on the source large
-			 * folio. Capture required information that might get
-			 * lost during migration.
-			 */
-			is_large = folio_test_large(folio);
-			is_thp = is_large && folio_test_pmd_mappable(folio);
+			is_thp = folio_test_large(folio) && folio_test_pmd_mappable(folio);
 			nr_pages = folio_nr_pages(folio);
 
 			cond_resched();
@@ -1688,7 +1681,7 @@  static int migrate_pages_batch(struct list_head *from, new_page_t get_new_page,
 				nr_failed++;
 				stats->nr_thp_failed += is_thp;
 				/* Large folio NUMA faulting doesn't split to retry. */
-				if (is_large && !nosplit) {
+				if (folio_test_large(folio) && !nosplit) {
 					int ret = try_split_folio(folio, split_folios);
 
 					if (!ret) {