Skip to contentSkip to conversation

libceph: Remove crush deadcode

PATCH In review [email protected] 3 participants 5 messages Oct 11, 2024 – Oct 27, 2024

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

PATCH 1/1 libceph: Remove crush deadcode

From: "Dr. David Alan Gilbert" <[email protected]>

crush_bucket_alg_name(), crush_get_bucket_item_weight(), crush_hash32(), and crush_hash32_5() were added by commit
5ecc0a0f8128 ("ceph: CRUSH mapping algorithm")
in 2009 but never used.

crush_hash_name() was added a little later by commit fb690390e305 ("ceph: make CRUSH hash function a bucket property") and also not used.

Remove them.

They called a couple of static functions crush_hash32_rjenkins1() and crush_hash32_rjenkins1_5() which are now unused.

Also remove them.

---
 include/linux/crush/crush.h |  2 --
 include/linux/crush/hash.h  |  5 ----
 net/ceph/crush/crush.c      | 37 -----------------------
 net/ceph/crush/hash.c       | 59 -------------------------------------
 4 files changed, 103 deletions(-)
include/linux/crush/crush.h +0 -2
index 30dba392b730..ed26099957df 100644
@@ -117,7 +117,6 @@ enum {
 	CRUSH_BUCKET_STRAW = 4,
 	CRUSH_BUCKET_STRAW2 = 5,
 };
-extern const char *crush_bucket_alg_name(int alg);
 
 /*
  * although tree was a legacy algorithm, it has been buggy, so
@@ -314,7 +313,6 @@ struct crush_map {
 
 
 /* crush.c */
-extern int crush_get_bucket_item_weight(const struct crush_bucket *b, int pos);
 extern void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b);
 extern void crush_destroy_bucket_list(struct crush_bucket_list *b);
 extern void crush_destroy_bucket_tree(struct crush_bucket_tree *b);
include/linux/crush/hash.h +0 -5
index 904df41f7847..0ee007a98236 100644
@@ -12,13 +12,8 @@
 
 #define CRUSH_HASH_DEFAULT CRUSH_HASH_RJENKINS1
 
-extern const char *crush_hash_name(int type);
-
-extern __u32 crush_hash32(int type, __u32 a);
 extern __u32 crush_hash32_2(int type, __u32 a, __u32 b);
 extern __u32 crush_hash32_3(int type, __u32 a, __u32 b, __u32 c);
 extern __u32 crush_hash32_4(int type, __u32 a, __u32 b, __u32 c, __u32 d);
-extern __u32 crush_hash32_5(int type, __u32 a, __u32 b, __u32 c, __u32 d,
-			    __u32 e);
 
 #endif
net/ceph/crush/crush.c +0 -37
index 254ded0b05f6..9331f91f1242 100644
@@ -7,43 +7,6 @@
 # include "crush.h"
 #endif
 
-const char *crush_bucket_alg_name(int alg)
-{
-	switch (alg) {
-	case CRUSH_BUCKET_UNIFORM: return "uniform";
-	case CRUSH_BUCKET_LIST: return "list";
-	case CRUSH_BUCKET_TREE: return "tree";
-	case CRUSH_BUCKET_STRAW: return "straw";
-	case CRUSH_BUCKET_STRAW2: return "straw2";
-	default: return "unknown";
-	}
-}
-
-/**
- * crush_get_bucket_item_weight - Get weight of an item in given bucket
- * @b: bucket pointer
- * @p: item index in bucket
- */
-int crush_get_bucket_item_weight(const struct crush_bucket *b, int p)
-{
-	if ((__u32)p >= b->size)
-		return 0;
-
-	switch (b->alg) {
-	case CRUSH_BUCKET_UNIFORM:
-		return ((struct crush_bucket_uniform *)b)->item_weight;
-	case CRUSH_BUCKET_LIST:
-		return ((struct crush_bucket_list *)b)->item_weights[p];
-	case CRUSH_BUCKET_TREE:
-		return ((struct crush_bucket_tree *)b)->node_weights[crush_calc_tree_node(p)];
-	case CRUSH_BUCKET_STRAW:
-		return ((struct crush_bucket_straw *)b)->item_weights[p];
-	case CRUSH_BUCKET_STRAW2:
-		return ((struct crush_bucket_straw2 *)b)->item_weights[p];
-	}
-	return 0;
-}
-
 void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b)
 {
 	kfree(b->h.items);
net/ceph/crush/hash.c +0 -59

74 lines not on this page · raw message

Signature · 1 line
2.47.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Fri, Oct 11, 2024 at 11:47:36PM +0100, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

crush_bucket_alg_name(), crush_get_bucket_item_weight(), crush_hash32(), and crush_hash32_5() were added by commit
5ecc0a0f8128 ("ceph: CRUSH mapping algorithm")
in 2009 but never used.

crush_hash_name() was added a little later by commit fb690390e305 ("ceph: make CRUSH hash function a bucket property") and also not used.

Quoted 8 lines

Remove them.

They called a couple of static functions crush_hash32_rjenkins1() and crush_hash32_rjenkins1_5() which are now unused.

Also remove them.

maintainer
#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Sat, Oct 12, 2024 at 12:47 AM <[email protected]> wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

crush_bucket_alg_name(), crush_get_bucket_item_weight(), crush_hash32(), and crush_hash32_5() were added by commit
5ecc0a0f8128 ("ceph: CRUSH mapping algorithm")
in 2009 but never used.

Quoted 5 lines

crush_hash_name() was added a little later by commit fb690390e305 ("ceph: make CRUSH hash function a bucket property") and also not used.

Remove them.

Hi David,

The implementation of the CRUSH algorithm is shared with userspace and these functions are used there (except for crush_hash32_5() perhaps). They are all trivial code, so I'd prefer to keep them for convenience.

Thanks,

Ilya

#3 lore raw
Quoted 13 lines · * Ilya Dryomov ([email protected]) wrote:
Quoted 12 lines · On Sat, Oct 12, 2024 at 12:47 AM <[email protected]> wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

crush_bucket_alg_name(), crush_get_bucket_item_weight(), crush_hash32(), and crush_hash32_5() were added by commit
5ecc0a0f8128 ("ceph: CRUSH mapping algorithm")
in 2009 but never used.

crush_hash_name() was added a little later by commit fb690390e305 ("ceph: make CRUSH hash function a bucket property") and also not used.

Quoted 7 lines
Quoted 1 line

Remove them.

Hi David,

The implementation of the CRUSH algorithm is shared with userspace and these functions are used there (except for crush_hash32_5() perhaps). They are all trivial code, so I'd prefer to keep them for convenience.

OK, no problem.
(Although perhaps an ifndef __KERNEL__ might save a few bytes?)

Dave

Quoted 4 lines

Thanks,

Ilya

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
maintainer
#4 lore raw
Quoted 17 lines · Dr. David Alan Gilbert
Quoted 15 lines · * Ilya Dryomov ([email protected]) wrote:
Quoted 13 lines · On Sat, Oct 12, 2024 at 12:47 AM <[email protected]> wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

crush_bucket_alg_name(), crush_get_bucket_item_weight(), crush_hash32(), and crush_hash32_5() were added by commit
5ecc0a0f8128 ("ceph: CRUSH mapping algorithm")
in 2009 but never used.

crush_hash_name() was added a little later by commit fb690390e305 ("ceph: make CRUSH hash function a bucket property") and also not used.

Remove them.

Quoted 8 lines
Quoted 5 lines

Hi David,

The implementation of the CRUSH algorithm is shared with userspace and these functions are used there (except for crush_hash32_5() perhaps). They are all trivial code, so I'd prefer to keep them for convenience.

OK, no problem.
(Although perhaps an ifndef __KERNEL__ might save a few bytes?)

I'm not sure that is worth the churn. If shaving off a teeny tiny bit from the text section in generic distro kernels (where Ceph modules are enabled) is really desired, I'd probably just drop these functions (i.e. apply the patch as is).

Thanks,

Ilya