diff mbox series

[9/9] mm/z3fold: remove unneeded return value of z3fold_compact_page()

Message ID 20220219092533.12596-10-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few cleanup patches for z3fold | expand

Commit Message

Miaohe Lin Feb. 19, 2022, 9:25 a.m. UTC
Remove the unneeded return value of z3fold_compact_page() as it's
never checked.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/z3fold.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Souptick Joarder Feb. 19, 2022, 8:37 p.m. UTC | #1
On Sat, Feb 19, 2022 at 2:56 PM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> Remove the unneeded return value of z3fold_compact_page() as it's
> never checked.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Acked-by: Souptick Joarder <jrdr.linux@gmail.com>

> ---
>  mm/z3fold.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 83b5a3514427..db41b4227ec7 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -746,18 +746,18 @@ static struct z3fold_header *compact_single_buddy(struct z3fold_header *zhdr)
>
>  #define BIG_CHUNK_GAP  3
>  /* Has to be called with lock held */
> -static int z3fold_compact_page(struct z3fold_header *zhdr)
> +static void z3fold_compact_page(struct z3fold_header *zhdr)
>  {
>         struct page *page = virt_to_page(zhdr);
>
>         if (test_bit(MIDDLE_CHUNK_MAPPED, &page->private))
> -               return 0; /* can't move middle chunk, it's used */
> +               return; /* can't move middle chunk, it's used */
>
>         if (unlikely(PageIsolated(page)))
> -               return 0;
> +               return;
>
>         if (zhdr->middle_chunks == 0)
> -               return 0; /* nothing to compact */
> +               return; /* nothing to compact */
>
>         if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) {
>                 /* move to the beginning */
> @@ -766,7 +766,7 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>                 zhdr->middle_chunks = 0;
>                 zhdr->start_middle = 0;
>                 zhdr->first_num++;
> -               return 1;
> +               return;
>         }
>
>         /*
> @@ -778,7 +778,6 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>                         BIG_CHUNK_GAP) {
>                 mchunk_memmove(zhdr, zhdr->first_chunks + ZHDR_CHUNKS);
>                 zhdr->start_middle = zhdr->first_chunks + ZHDR_CHUNKS;
> -               return 1;
>         } else if (zhdr->last_chunks != 0 && zhdr->first_chunks == 0 &&
>                    TOTAL_CHUNKS - (zhdr->last_chunks + zhdr->start_middle
>                                         + zhdr->middle_chunks) >=
> @@ -787,10 +786,7 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>                         zhdr->middle_chunks;
>                 mchunk_memmove(zhdr, new_start);
>                 zhdr->start_middle = new_start;
> -               return 1;
>         }
> -
> -       return 0;
>  }
>
>  static void do_compact_page(struct z3fold_header *zhdr, bool locked)
> --
> 2.23.0
>
>
Vitaly Wool March 2, 2022, 8:40 a.m. UTC | #2
On Sat, Feb 19, 2022 at 10:26 AM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> Remove the unneeded return value of z3fold_compact_page() as it's
> never checked.

It was a sort of hook for gathering extended compaction statistics in
future. Do you really gain a lot by removing this?

~Vitaly

> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/z3fold.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index 83b5a3514427..db41b4227ec7 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -746,18 +746,18 @@ static struct z3fold_header *compact_single_buddy(struct z3fold_header *zhdr)
>
>  #define BIG_CHUNK_GAP  3
>  /* Has to be called with lock held */
> -static int z3fold_compact_page(struct z3fold_header *zhdr)
> +static void z3fold_compact_page(struct z3fold_header *zhdr)
>  {
>         struct page *page = virt_to_page(zhdr);
>
>         if (test_bit(MIDDLE_CHUNK_MAPPED, &page->private))
> -               return 0; /* can't move middle chunk, it's used */
> +               return; /* can't move middle chunk, it's used */
>
>         if (unlikely(PageIsolated(page)))
> -               return 0;
> +               return;
>
>         if (zhdr->middle_chunks == 0)
> -               return 0; /* nothing to compact */
> +               return; /* nothing to compact */
>
>         if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) {
>                 /* move to the beginning */
> @@ -766,7 +766,7 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>                 zhdr->middle_chunks = 0;
>                 zhdr->start_middle = 0;
>                 zhdr->first_num++;
> -               return 1;
> +               return;
>         }
>
>         /*
> @@ -778,7 +778,6 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>                         BIG_CHUNK_GAP) {
>                 mchunk_memmove(zhdr, zhdr->first_chunks + ZHDR_CHUNKS);
>                 zhdr->start_middle = zhdr->first_chunks + ZHDR_CHUNKS;
> -               return 1;
>         } else if (zhdr->last_chunks != 0 && zhdr->first_chunks == 0 &&
>                    TOTAL_CHUNKS - (zhdr->last_chunks + zhdr->start_middle
>                                         + zhdr->middle_chunks) >=
> @@ -787,10 +786,7 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>                         zhdr->middle_chunks;
>                 mchunk_memmove(zhdr, new_start);
>                 zhdr->start_middle = new_start;
> -               return 1;
>         }
> -
> -       return 0;
>  }
>
>  static void do_compact_page(struct z3fold_header *zhdr, bool locked)
> --
> 2.23.0
>
Miaohe Lin March 2, 2022, 8:56 a.m. UTC | #3
On 2022/3/2 16:40, Vitaly Wool wrote:
> On Sat, Feb 19, 2022 at 10:26 AM Miaohe Lin <linmiaohe@huawei.com> wrote:
>>
>> Remove the unneeded return value of z3fold_compact_page() as it's
>> never checked.
> 
> It was a sort of hook for gathering extended compaction statistics in
> future. Do you really gain a lot by removing this?

I see. So I shouldn't discard the return value though it looks unused.
This is just for cleanup purpose so let's just drop this patch.

Many thanks for your time and Reviewed-by tag in this series! :)

> 
> ~Vitaly
> 
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/z3fold.c | 14 +++++---------
>>  1 file changed, 5 insertions(+), 9 deletions(-)
>>
>> diff --git a/mm/z3fold.c b/mm/z3fold.c
>> index 83b5a3514427..db41b4227ec7 100644
>> --- a/mm/z3fold.c
>> +++ b/mm/z3fold.c
>> @@ -746,18 +746,18 @@ static struct z3fold_header *compact_single_buddy(struct z3fold_header *zhdr)
>>
>>  #define BIG_CHUNK_GAP  3
>>  /* Has to be called with lock held */
>> -static int z3fold_compact_page(struct z3fold_header *zhdr)
>> +static void z3fold_compact_page(struct z3fold_header *zhdr)
>>  {
>>         struct page *page = virt_to_page(zhdr);
>>
>>         if (test_bit(MIDDLE_CHUNK_MAPPED, &page->private))
>> -               return 0; /* can't move middle chunk, it's used */
>> +               return; /* can't move middle chunk, it's used */
>>
>>         if (unlikely(PageIsolated(page)))
>> -               return 0;
>> +               return;
>>
>>         if (zhdr->middle_chunks == 0)
>> -               return 0; /* nothing to compact */
>> +               return; /* nothing to compact */
>>
>>         if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) {
>>                 /* move to the beginning */
>> @@ -766,7 +766,7 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>>                 zhdr->middle_chunks = 0;
>>                 zhdr->start_middle = 0;
>>                 zhdr->first_num++;
>> -               return 1;
>> +               return;
>>         }
>>
>>         /*
>> @@ -778,7 +778,6 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>>                         BIG_CHUNK_GAP) {
>>                 mchunk_memmove(zhdr, zhdr->first_chunks + ZHDR_CHUNKS);
>>                 zhdr->start_middle = zhdr->first_chunks + ZHDR_CHUNKS;
>> -               return 1;
>>         } else if (zhdr->last_chunks != 0 && zhdr->first_chunks == 0 &&
>>                    TOTAL_CHUNKS - (zhdr->last_chunks + zhdr->start_middle
>>                                         + zhdr->middle_chunks) >=
>> @@ -787,10 +786,7 @@ static int z3fold_compact_page(struct z3fold_header *zhdr)
>>                         zhdr->middle_chunks;
>>                 mchunk_memmove(zhdr, new_start);
>>                 zhdr->start_middle = new_start;
>> -               return 1;
>>         }
>> -
>> -       return 0;
>>  }
>>
>>  static void do_compact_page(struct z3fold_header *zhdr, bool locked)
>> --
>> 2.23.0
>>
> .
>
diff mbox series

Patch

diff --git a/mm/z3fold.c b/mm/z3fold.c
index 83b5a3514427..db41b4227ec7 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -746,18 +746,18 @@  static struct z3fold_header *compact_single_buddy(struct z3fold_header *zhdr)
 
 #define BIG_CHUNK_GAP	3
 /* Has to be called with lock held */
-static int z3fold_compact_page(struct z3fold_header *zhdr)
+static void z3fold_compact_page(struct z3fold_header *zhdr)
 {
 	struct page *page = virt_to_page(zhdr);
 
 	if (test_bit(MIDDLE_CHUNK_MAPPED, &page->private))
-		return 0; /* can't move middle chunk, it's used */
+		return; /* can't move middle chunk, it's used */
 
 	if (unlikely(PageIsolated(page)))
-		return 0;
+		return;
 
 	if (zhdr->middle_chunks == 0)
-		return 0; /* nothing to compact */
+		return; /* nothing to compact */
 
 	if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) {
 		/* move to the beginning */
@@ -766,7 +766,7 @@  static int z3fold_compact_page(struct z3fold_header *zhdr)
 		zhdr->middle_chunks = 0;
 		zhdr->start_middle = 0;
 		zhdr->first_num++;
-		return 1;
+		return;
 	}
 
 	/*
@@ -778,7 +778,6 @@  static int z3fold_compact_page(struct z3fold_header *zhdr)
 			BIG_CHUNK_GAP) {
 		mchunk_memmove(zhdr, zhdr->first_chunks + ZHDR_CHUNKS);
 		zhdr->start_middle = zhdr->first_chunks + ZHDR_CHUNKS;
-		return 1;
 	} else if (zhdr->last_chunks != 0 && zhdr->first_chunks == 0 &&
 		   TOTAL_CHUNKS - (zhdr->last_chunks + zhdr->start_middle
 					+ zhdr->middle_chunks) >=
@@ -787,10 +786,7 @@  static int z3fold_compact_page(struct z3fold_header *zhdr)
 			zhdr->middle_chunks;
 		mchunk_memmove(zhdr, new_start);
 		zhdr->start_middle = new_start;
-		return 1;
 	}
-
-	return 0;
 }
 
 static void do_compact_page(struct z3fold_header *zhdr, bool locked)