Skip to content

Commit 63a26e0

Browse files
committed
filehash: move to separate allocation
We currently make it part of the thread structure allocation, but there's no need to do that since we have smalloc available. Signed-off-by: Jens Axboe <[email protected]>
1 parent cab2472 commit 63a26e0

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

filehash.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
#include "flist.h"
66
#include "hash.h"
77
#include "filehash.h"
8+
#include "smalloc.h"
89
#include "lib/bloom.h"
910

1011
#define HASH_BUCKETS 512
1112
#define HASH_MASK (HASH_BUCKETS - 1)
1213

1314
#define BLOOM_SIZE 16*1024*1024
1415

15-
unsigned int file_hash_size = HASH_BUCKETS * sizeof(struct flist_head);
16+
static unsigned int file_hash_size = HASH_BUCKETS * sizeof(struct flist_head);
1617

1718
static struct flist_head *file_hash;
1819
static struct fio_mutex *hash_lock;
@@ -116,18 +117,20 @@ void file_hash_exit(void)
116117
if (has_entries)
117118
log_err("fio: file hash not empty on exit\n");
118119

120+
sfree(file_hash);
119121
file_hash = NULL;
120122
fio_mutex_remove(hash_lock);
121123
hash_lock = NULL;
122124
bloom_free(file_bloom);
123125
file_bloom = NULL;
124126
}
125127

126-
void file_hash_init(void *ptr)
128+
void file_hash_init(void)
127129
{
128130
unsigned int i;
129131

130-
file_hash = ptr;
132+
file_hash = smalloc(file_hash_size);
133+
131134
for (i = 0; i < HASH_BUCKETS; i++)
132135
INIT_FLIST_HEAD(&file_hash[i]);
133136

filehash.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
#include "lib/types.h"
55

6-
extern unsigned int file_hash_size;
7-
8-
extern void file_hash_init(void *);
6+
extern void file_hash_init(void);
97
extern void file_hash_exit(void);
108
extern struct fio_file *lookup_file_hash(const char *);
119
extern struct fio_file *add_file_hash(struct fio_file *);

init.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ static int setup_thread_area(void)
334334
do {
335335
size_t size = max_jobs * sizeof(struct thread_data);
336336

337-
size += file_hash_size;
338337
size += sizeof(unsigned int);
339338

340339
#ifndef CONFIG_NO_SHM
@@ -366,11 +365,10 @@ static int setup_thread_area(void)
366365
#endif
367366

368367
memset(threads, 0, max_jobs * sizeof(struct thread_data));
369-
hash = (void *) threads + max_jobs * sizeof(struct thread_data);
370-
fio_debug_jobp = (void *) hash + file_hash_size;
368+
fio_debug_jobp = (void *) threads + max_jobs * sizeof(struct thread_data);
371369
*fio_debug_jobp = -1;
372-
file_hash_init(hash);
373370

371+
file_hash_init();
374372
flow_init();
375373

376374
return 0;

0 commit comments

Comments
 (0)