Skip to contentSkip to conversation

mm: zswap: remove unnecessary check in zswap_find_zpool()

PATCH Applied Yosry Ahmed 4 participants 5 messages Mar 11, 2024 – Mar 12, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: zswap: remove unnecessary check in zswap_find_zpool()

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.

---
 mm/zswap.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
mm/zswap.c +1 -6
index 9a32377520827..c6267b5e0999a 100644
@@ -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))];
 }
 
 /*
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Yosry Ahmed

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.

Looks good to me!

Thanks.

Quoted 22 lines
---
 mm/zswap.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
mm/zswap.c +1 -6
index 9a32377520827..c6267b5e0999a 100644
@@ -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))];
 }
 
 /*
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Yosry Ahmed
Quoted 4 lines · Yosry Ahmed

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.

Quoted 2 lines
#3 lore raw
Quoted 8 lines · Nhat Pham
Quoted 4 lines · Yosry Ahmed

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.

Quoted 5 lines
Quoted 3 lines

Thanks!