Remove all use of the LOG2() macro/inline, undoing some non-optimal cruft
that crept in recently. GCC will optimize the divides and multiplies for us. Submitted by: David Schultz <dschultz@uclink.Berkeley.EDU> MFC after: 1 day
This commit is contained in:
parent
c54f72859c
commit
57e6d29b1e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109086
@ -371,8 +371,8 @@ scanradix(
|
||||
);
|
||||
}
|
||||
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
next_skip = skip >> BLIST_META_RADIX_SHIFT;
|
||||
radix /= BLIST_META_RADIX;
|
||||
next_skip = skip / BLIST_META_RADIX;
|
||||
|
||||
for (i = 1; i <= skip; i += next_skip) {
|
||||
int r;
|
||||
|
@ -153,8 +153,8 @@ blist_create(daddr_t blocks)
|
||||
radix = BLIST_BMAP_RADIX;
|
||||
|
||||
while (radix < blocks) {
|
||||
radix <<= BLIST_META_RADIX_SHIFT;
|
||||
skip = (skip + 1) << BLIST_META_RADIX_SHIFT;
|
||||
radix *= BLIST_META_RADIX;
|
||||
skip = (skip + 1) * BLIST_META_RADIX;
|
||||
}
|
||||
|
||||
bl = malloc(sizeof(struct blist), M_SWAP, M_WAITOK | M_ZERO);
|
||||
@ -401,7 +401,7 @@ blst_meta_alloc(
|
||||
int skip
|
||||
) {
|
||||
int i;
|
||||
int next_skip = (skip >> BLIST_META_RADIX_SHIFT);
|
||||
int next_skip = ((u_int)skip / BLIST_META_RADIX);
|
||||
|
||||
if (scan->u.bmu_avail == 0) {
|
||||
/*
|
||||
@ -412,7 +412,7 @@ blst_meta_alloc(
|
||||
}
|
||||
|
||||
if (scan->u.bmu_avail == radix) {
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
radix /= BLIST_META_RADIX;
|
||||
|
||||
/*
|
||||
* ALL-FREE special case, initialize uninitialize
|
||||
@ -430,7 +430,7 @@ blst_meta_alloc(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
radix /= BLIST_META_RADIX;
|
||||
}
|
||||
|
||||
for (i = 1; i <= skip; i += next_skip) {
|
||||
@ -532,7 +532,7 @@ blst_meta_free(
|
||||
daddr_t blk
|
||||
) {
|
||||
int i;
|
||||
int next_skip = (skip >> BLIST_META_RADIX_SHIFT);
|
||||
int next_skip = ((u_int)skip / BLIST_META_RADIX);
|
||||
|
||||
#if 0
|
||||
printf("FREE (%llx,%lld) FROM (%llx,%lld)\n",
|
||||
@ -582,7 +582,7 @@ blst_meta_free(
|
||||
* Break the free down into its components
|
||||
*/
|
||||
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
radix /= BLIST_META_RADIX;
|
||||
|
||||
i = (freeBlk - blk) / radix;
|
||||
blk += i * radix;
|
||||
@ -672,8 +672,8 @@ static void blst_copy(
|
||||
}
|
||||
|
||||
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
next_skip = (skip >> BLIST_META_RADIX_SHIFT);
|
||||
radix /= BLIST_META_RADIX;
|
||||
next_skip = ((u_int)skip / BLIST_META_RADIX);
|
||||
|
||||
for (i = 1; count && i <= skip; i += next_skip) {
|
||||
if (scan[i].bm_bighint == (daddr_t)-1)
|
||||
@ -751,7 +751,7 @@ blst_meta_fill(
|
||||
daddr_t blk
|
||||
) {
|
||||
int i;
|
||||
int next_skip = (skip >> BLIST_META_RADIX_SHIFT);
|
||||
int next_skip = ((u_int)skip / BLIST_META_RADIX);
|
||||
int nblks = 0;
|
||||
|
||||
if (count == radix || scan->u.bmu_avail == 0) {
|
||||
@ -765,7 +765,7 @@ blst_meta_fill(
|
||||
}
|
||||
|
||||
if (scan->u.bmu_avail == radix) {
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
radix /= BLIST_META_RADIX;
|
||||
|
||||
/*
|
||||
* ALL-FREE special case, initialize sublevel
|
||||
@ -782,7 +782,7 @@ blst_meta_fill(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
radix /= BLIST_META_RADIX;
|
||||
}
|
||||
|
||||
if (count > radix)
|
||||
@ -856,8 +856,8 @@ blst_radix_init(blmeta_t *scan, daddr_t radix, int skip, daddr_t count)
|
||||
scan->u.bmu_avail = 0;
|
||||
}
|
||||
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
next_skip = (skip >> BLIST_META_RADIX_SHIFT);
|
||||
radix /= BLIST_META_RADIX;
|
||||
next_skip = ((u_int)skip / BLIST_META_RADIX);
|
||||
|
||||
for (i = 1; i <= skip; i += next_skip) {
|
||||
if (count >= radix) {
|
||||
@ -944,8 +944,8 @@ blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t radix, int skip, int tab)
|
||||
(long long)scan->bm_bighint
|
||||
);
|
||||
|
||||
radix >>= BLIST_META_RADIX_SHIFT;
|
||||
next_skip = (skip >> BLIST_META_RADIX_SHIFT);
|
||||
radix /= BLIST_META_RADIX;
|
||||
next_skip = ((u_int)skip / BLIST_META_RADIX);
|
||||
tab += 4;
|
||||
|
||||
for (i = 1; i <= skip; i += next_skip) {
|
||||
|
@ -33,20 +33,6 @@
|
||||
|
||||
typedef u_int32_t u_daddr_t; /* unsigned disk address */
|
||||
|
||||
static __inline int
|
||||
LOG2(u_daddr_t v)
|
||||
{
|
||||
int i = -1;
|
||||
|
||||
if (!v)
|
||||
return(0);
|
||||
while (v) {
|
||||
i++;
|
||||
v >>= 1;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
/*
|
||||
* blmeta and bl_bitmap_t MUST be a power of 2 in size.
|
||||
*/
|
||||
@ -69,9 +55,7 @@ typedef struct blist {
|
||||
} *blist_t;
|
||||
|
||||
#define BLIST_META_RADIX 16
|
||||
#define BLIST_META_RADIX_SHIFT LOG2(BLIST_META_RADIX)
|
||||
#define BLIST_BMAP_RADIX (sizeof(u_daddr_t)*8)
|
||||
#define BLIST_BMAP_RADIX_SHIFT LOG2(BLIST_BMAP_RADIX)
|
||||
|
||||
#define BLIST_MAX_ALLOC BLIST_BMAP_RADIX
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user