diff mbox series

mm: zswap: remove unnecessary check in zswap_find_zpool()

Message ID 20240311235210.2937484-1-yosryahmed@google.com (mailing list archive)
State New
Headers show
Series mm: zswap: remove unnecessary check in zswap_find_zpool() | expand

Commit Message

Yosry Ahmed March 11, 2024, 11:52 p.m. UTC
zswap_find_zpool() checks if ZSWAP_NR_ZPOOLS > 1, which is always true.
This is a remnant from a patch version that had ZSWAP_NR_ZPOOLS as a
config option and never made it upstream. Remove the unnecessary check.

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
---
 mm/zswap.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Chengming Zhou March 12, 2024, 4:57 a.m. UTC | #1
On 2024/3/12 07:52, Yosry Ahmed wrote:
> zswap_find_zpool() checks if ZSWAP_NR_ZPOOLS > 1, which is always true.
> This is a remnant from a patch version that had ZSWAP_NR_ZPOOLS as a
> config option and never made it upstream. Remove the unnecessary check.
> 
> Signed-off-by: Yosry Ahmed <yosryahmed@google.com>

Looks good to me!

Reviewed-by: Chengming Zhou <chengming.zhou@linux.dev>

Thanks.

> ---
>  mm/zswap.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 9a32377520827..c6267b5e0999a 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -884,12 +884,7 @@ static void zswap_entry_cache_free(struct zswap_entry *entry)
>  
>  static struct zpool *zswap_find_zpool(struct zswap_entry *entry)
>  {
> -	int i = 0;
> -
> -	if (ZSWAP_NR_ZPOOLS > 1)
> -		i = hash_ptr(entry, ilog2(ZSWAP_NR_ZPOOLS));
> -
> -	return entry->pool->zpools[i];
> +	return entry->pool->zpools[hash_ptr(entry, ilog2(ZSWAP_NR_ZPOOLS))];
>  }
>  
>  /*
Nhat Pham March 12, 2024, 9:35 a.m. UTC | #2
On Tue, Mar 12, 2024 at 6:52 AM Yosry Ahmed <yosryahmed@google.com> wrote:
>
> zswap_find_zpool() checks if ZSWAP_NR_ZPOOLS > 1, which is always true.
> This is a remnant from a patch version that had ZSWAP_NR_ZPOOLS as a
> config option and never made it upstream. Remove the unnecessary check.

Do we need a Fixes: tag for this? I guess it's not a bug hmmm.

>
> Signed-off-by: Yosry Ahmed <yosryahmed@google.com>

Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Yosry Ahmed March 12, 2024, 10:22 a.m. UTC | #3
On Tue, Mar 12, 2024 at 2:35 AM Nhat Pham <nphamcs@gmail.com> wrote:
>
> On Tue, Mar 12, 2024 at 6:52 AM Yosry Ahmed <yosryahmed@google.com> wrote:
> >
> > zswap_find_zpool() checks if ZSWAP_NR_ZPOOLS > 1, which is always true.
> > This is a remnant from a patch version that had ZSWAP_NR_ZPOOLS as a
> > config option and never made it upstream. Remove the unnecessary check.
>
> Do we need a Fixes: tag for this? I guess it's not a bug hmmm.

The compiler should be producing the exact same code either way, so I
would say no. It's just a cleanup.

>
> >
> > Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
>
> Reviewed-by: Nhat Pham <nphamcs@gmail.com>

Thanks!
Johannes Weiner March 12, 2024, 7:17 p.m. UTC | #4
On Mon, Mar 11, 2024 at 11:52:10PM +0000, Yosry Ahmed wrote:
> zswap_find_zpool() checks if ZSWAP_NR_ZPOOLS > 1, which is always true.
> This is a remnant from a patch version that had ZSWAP_NR_ZPOOLS as a
> config option and never made it upstream. Remove the unnecessary check.
> 
> Signed-off-by: Yosry Ahmed <yosryahmed@google.com>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>
diff mbox series

Patch

diff --git a/mm/zswap.c b/mm/zswap.c
index 9a32377520827..c6267b5e0999a 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -884,12 +884,7 @@  static void zswap_entry_cache_free(struct zswap_entry *entry)
 
 static struct zpool *zswap_find_zpool(struct zswap_entry *entry)
 {
-	int i = 0;
-
-	if (ZSWAP_NR_ZPOOLS > 1)
-		i = hash_ptr(entry, ilog2(ZSWAP_NR_ZPOOLS));
-
-	return entry->pool->zpools[i];
+	return entry->pool->zpools[hash_ptr(entry, ilog2(ZSWAP_NR_ZPOOLS))];
 }
 
 /*