summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f880b1f)
We don't want to favor any end of the block spectrum.
Mix with a hash.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
#error Define GOLDEN_RATIO_PRIME for your wordsize.
#endif
#error Define GOLDEN_RATIO_PRIME for your wordsize.
#endif
-static inline unsigned long hash_long(unsigned long val, unsigned int bits)
+static inline unsigned long __hash_long(unsigned long val)
{
unsigned long hash = val;
{
unsigned long hash = val;
hash *= GOLDEN_RATIO_PRIME;
#endif
hash *= GOLDEN_RATIO_PRIME;
#endif
+ return hash;
+}
+
+static inline unsigned long hash_long(unsigned long val, unsigned int bits)
+{
/* High bits are more random, so use them. */
/* High bits are more random, so use them. */
- return hash >> (BITS_PER_LONG - bits);
+ return __hash_long(val) >> (BITS_PER_LONG - bits);
}
static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
}
static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
#include "../log.h"
#include "zipf.h"
#include "../minmax.h"
#include "../log.h"
#include "zipf.h"
#include "../minmax.h"
#include "../os/os.h"
struct fio_zipf_disk {
#include "../os/os.h"
struct fio_zipf_disk {
else
val = 1 + (unsigned long long)(n * pow(eta*rand_uni - eta + 1.0, alpha));
else
val = 1 + (unsigned long long)(n * pow(eta*rand_uni - eta + 1.0, alpha));
+ return __hash_long(val - 1) % zs->nranges;
}
void pareto_init(struct zipf_state *zs, unsigned long nranges, double h)
}
void pareto_init(struct zipf_state *zs, unsigned long nranges, double h)
double rand = (double) __rand(&zs->rand) / (double) FRAND_MAX;
unsigned long long n = zs->nranges - 1;
double rand = (double) __rand(&zs->rand) / (double) FRAND_MAX;
unsigned long long n = zs->nranges - 1;
- return n * pow(rand, zs->pareto_pow);
+ return __hash_long(n * pow(rand, zs->pareto_pow)) % zs->nranges;