Skip to content

Commit 3d8a9a1

Browse files
visitorckwakpm00
authored andcommitted
bcache: update min_heap_callbacks to use default builtin swap
Replace the swp function pointer in the min_heap_callbacks of bcache with NULL, allowing direct usage of the default builtin swap implementation. This modification simplifies the code and improves performance by removing unnecessary function indirection. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kuan-Wei Chiu <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Ching-Chun (Jim) Huang <[email protected]> Cc: Coly Li <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: "Liang, Kan" <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Matthew Sakai <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d684430 commit 3d8a9a1

File tree

4 files changed

+7
-38
lines changed

4 files changed

+7
-38
lines changed

drivers/md/bcache/alloc.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,16 @@ static inline bool new_bucket_min_cmp(const void *l, const void *r, void *args)
189189
return new_bucket_prio(ca, *lhs) < new_bucket_prio(ca, *rhs);
190190
}
191191

192-
static inline void new_bucket_swap(void *l, void *r, void __always_unused *args)
193-
{
194-
struct bucket **lhs = l, **rhs = r;
195-
196-
swap(*lhs, *rhs);
197-
}
198-
199192
static void invalidate_buckets_lru(struct cache *ca)
200193
{
201194
struct bucket *b;
202195
const struct min_heap_callbacks bucket_max_cmp_callback = {
203196
.less = new_bucket_max_cmp,
204-
.swp = new_bucket_swap,
197+
.swp = NULL,
205198
};
206199
const struct min_heap_callbacks bucket_min_cmp_callback = {
207200
.less = new_bucket_min_cmp,
208-
.swp = new_bucket_swap,
201+
.swp = NULL,
209202
};
210203

211204
ca->heap.nr = 0;

drivers/md/bcache/bset.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,14 +1093,6 @@ static inline bool new_btree_iter_cmp(const void *l, const void *r, void __alway
10931093
return bkey_cmp(_l->k, _r->k) <= 0;
10941094
}
10951095

1096-
static inline void new_btree_iter_swap(void *iter1, void *iter2, void __always_unused *args)
1097-
{
1098-
struct btree_iter_set *_iter1 = iter1;
1099-
struct btree_iter_set *_iter2 = iter2;
1100-
1101-
swap(*_iter1, *_iter2);
1102-
}
1103-
11041096
static inline bool btree_iter_end(struct btree_iter *iter)
11051097
{
11061098
return !iter->heap.nr;
@@ -1111,7 +1103,7 @@ void bch_btree_iter_push(struct btree_iter *iter, struct bkey *k,
11111103
{
11121104
const struct min_heap_callbacks callbacks = {
11131105
.less = new_btree_iter_cmp,
1114-
.swp = new_btree_iter_swap,
1106+
.swp = NULL,
11151107
};
11161108

11171109
if (k != end)
@@ -1157,7 +1149,7 @@ static inline struct bkey *__bch_btree_iter_next(struct btree_iter *iter,
11571149
struct bkey *ret = NULL;
11581150
const struct min_heap_callbacks callbacks = {
11591151
.less = cmp,
1160-
.swp = new_btree_iter_swap,
1152+
.swp = NULL,
11611153
};
11621154

11631155
if (!btree_iter_end(iter)) {
@@ -1231,7 +1223,7 @@ static void btree_mergesort(struct btree_keys *b, struct bset *out,
12311223
: bch_ptr_invalid;
12321224
const struct min_heap_callbacks callbacks = {
12331225
.less = b->ops->sort_cmp,
1234-
.swp = new_btree_iter_swap,
1226+
.swp = NULL,
12351227
};
12361228

12371229
/* Heapify the iterator, using our comparison function */

drivers/md/bcache/extents.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,12 @@ static bool new_bch_extent_sort_cmp(const void *l, const void *r, void __always_
266266
return !(c ? c > 0 : _l->k < _r->k);
267267
}
268268

269-
static inline void new_btree_iter_swap(void *iter1, void *iter2, void __always_unused *args)
270-
{
271-
struct btree_iter_set *_iter1 = iter1;
272-
struct btree_iter_set *_iter2 = iter2;
273-
274-
swap(*_iter1, *_iter2);
275-
}
276-
277269
static struct bkey *bch_extent_sort_fixup(struct btree_iter *iter,
278270
struct bkey *tmp)
279271
{
280272
const struct min_heap_callbacks callbacks = {
281273
.less = new_bch_extent_sort_cmp,
282-
.swp = new_btree_iter_swap,
274+
.swp = NULL,
283275
};
284276
while (iter->heap.nr > 1) {
285277
struct btree_iter_set *top = iter->heap.data, *i = top + 1;

drivers/md/bcache/movinggc.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,6 @@ static bool new_bucket_cmp(const void *l, const void *r, void __always_unused *a
190190
return GC_SECTORS_USED(*_l) >= GC_SECTORS_USED(*_r);
191191
}
192192

193-
static void new_bucket_swap(void *l, void *r, void __always_unused *args)
194-
{
195-
struct bucket **_l = l;
196-
struct bucket **_r = r;
197-
198-
swap(*_l, *_r);
199-
}
200-
201193
static unsigned int bucket_heap_top(struct cache *ca)
202194
{
203195
struct bucket *b;
@@ -212,7 +204,7 @@ void bch_moving_gc(struct cache_set *c)
212204
unsigned long sectors_to_move, reserve_sectors;
213205
const struct min_heap_callbacks callbacks = {
214206
.less = new_bucket_cmp,
215-
.swp = new_bucket_swap,
207+
.swp = NULL,
216208
};
217209

218210
if (!c->copy_gc_enabled)

0 commit comments

Comments
 (0)