Skip to content

Commit

Permalink
DAOS-14491: Retain support for phase-1 DAV heap
Browse files Browse the repository at this point in the history
A copy of the phase-1 DAV allocator with some cleanup is moved to
the subdirectory src/common/dav_v1. This allocator is built as a
standalone shared library and linked to the libdaos_common_pmem
library.  The umem will now support one more mode DAOS_MD_BMEM_V1
which results in umem instance using phase-1 DAV allocator
interface and layout.

Signed-off-by: Sherin T George <sherin-t.george@hpe.com>
  • Loading branch information
sherintg committed Oct 11, 2023
1 parent 4951549 commit 04279b1
Show file tree
Hide file tree
Showing 68 changed files with 15,211 additions and 891 deletions.
1 change: 1 addition & 0 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def scons():
# Generate common libraries used by multiple components
SConscript('gurt/SConscript')
SConscript('cart/SConscript')
SConscript('common/dav_v1/SConscript')
SConscript('common/SConscript')
SConscript('bio/SConscript')
SConscript('vea/SConscript')
Expand Down
9 changes: 4 additions & 5 deletions src/common/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ def build_daos_common(denv, client):
else:
dav_src = ['dav/alloc_class.c', 'dav/bucket.c', 'dav/container_ravl.c',
'dav/container_seglists.c', 'dav/critnib.c', 'dav/dav_clogs.c',
'dav/dav_iface.c', 'dav/heap.c', 'dav/memblock.c',
'dav/memops.c', 'dav/os_thread_posix.c', 'dav/palloc.c', 'dav/ravl.c',
'dav/ravl_interval.c', 'dav/recycler.c', 'dav/stats.c', 'dav/tx.c', 'dav/ulog.c',
'dav/util.c', 'dav/wal_tx.c']
'dav/dav_iface.c', 'dav/heap.c', 'dav/memblock.c', 'dav/memops.c',
'dav/palloc.c', 'dav/ravl.c', 'dav/ravl_interval.c', 'dav/recycler.c',
'dav/stats.c', 'dav/tx.c', 'dav/ulog.c', 'dav/util.c', 'dav/wal_tx.c']
ad_mem_files = ['ad_mem.c', 'ad_tx.c']
common_libs.extend(['pmemobj', 'abt'])
common_libs.extend(['pmemobj', 'abt', 'dav_v1'])
benv.AppendUnique(RPATH_FULL=['$PREFIX/lib64/daos_srv'])
benv.Append(CPPDEFINES=['-DDAOS_PMEM_BUILD'])
benv.Append(OBJPREFIX="v_")
Expand Down
4 changes: 2 additions & 2 deletions src/common/dav/bucket.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct bucket {

struct bucket_locked {
struct bucket bucket;
os_mutex_t lock;
pthread_mutex_t lock;
};

/*
Expand Down Expand Up @@ -206,7 +206,7 @@ bucket_memblock_insert_block(const struct memory_block *m, void *b)
int
bucket_attach_run(struct bucket *b, const struct memory_block *m)
{
os_mutex_t *lock = m->m_ops->get_lock(m);
pthread_mutex_t *lock = m->m_ops->get_lock(m);

util_mutex_lock(lock);

Expand Down
2 changes: 1 addition & 1 deletion src/common/dav/critnib.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct critnib {

uint64_t remove_count;

os_mutex_t mutex; /* writes/removes */
pthread_mutex_t mutex; /* writes/removes */
};

/*
Expand Down
7 changes: 3 additions & 4 deletions src/common/dav/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "recycler.h"
#include "container.h"
#include "alloc_class.h"
#include "os_thread.h"

#define MAX_RUN_LOCKS MAX_CHUNK
#define MAX_RUN_LOCKS_VG 1024 /* avoid perf issues /w drd */
Expand All @@ -48,7 +47,7 @@ struct heap_rt {
struct alloc_class_collection *alloc_classes;
struct zoneset *default_zset;
struct zoneset **evictable_zsets;
os_mutex_t run_locks[MAX_RUN_LOCKS];
pthread_mutex_t run_locks[MAX_RUN_LOCKS];
unsigned nlocks;
unsigned nzones;
unsigned zones_exhausted;
Expand Down Expand Up @@ -145,7 +144,7 @@ zoneset_bucket_release(struct bucket *b)
/*
* heap_get_run_lock -- returns the lock associated with memory block
*/
os_mutex_t *
pthread_mutex_t *
heap_get_run_lock(struct palloc_heap *heap, uint32_t chunk_id)
{
return &heap->rt->run_locks[chunk_id % heap->rt->nlocks];
Expand Down Expand Up @@ -363,7 +362,7 @@ heap_run_into_free_chunk(struct palloc_heap *heap,
* We could forgo this lock if it weren't for helgrind which needs it
* to establish happens-before relation for the chunk metadata.
*/
os_mutex_t *lock = m->m_ops->get_lock(m);
pthread_mutex_t *lock = m->m_ops->get_lock(m);

util_mutex_lock(lock);

Expand Down
3 changes: 1 addition & 2 deletions src/common/dav/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "bucket.h"
#include "memops.h"
#include "palloc.h"
#include "os_thread.h"
#include "dav_internal.h"

#define HEAP_OFF_TO_PTR(heap, off) ((void *)((char *)((heap)->base) + (off)))
Expand Down Expand Up @@ -50,7 +49,7 @@ zoneset_bucket_release(struct bucket *b);

int
heap_get_bestfit_block(struct palloc_heap *heap, struct bucket *b, struct memory_block *m);
os_mutex_t *
pthread_mutex_t *
heap_get_run_lock(struct palloc_heap *heap, uint32_t chunk_id);

void
Expand Down
4 changes: 2 additions & 2 deletions src/common/dav/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ run_prep_operation_hdr(const struct memory_block *m, enum memblock_state op,
* single bucket there's no reason to lock them - the bucket itself is
* protected.
*/
static os_mutex_t *
static pthread_mutex_t *
huge_get_lock(const struct memory_block *m)
{
/* suppress unused-parameter errors */
Expand All @@ -780,7 +780,7 @@ huge_get_lock(const struct memory_block *m)
/*
* run_get_lock -- gets the runtime mutex from the heap.
*/
static os_mutex_t *
static pthread_mutex_t *
run_get_lock(const struct memory_block *m)
{
return heap_get_run_lock(m->heap, m->chunk_id);
Expand Down
3 changes: 1 addition & 2 deletions src/common/dav/memblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <stddef.h>
#include <stdint.h>

#include "os_thread.h"
#include "heap_layout.h"
#include "memops.h"
#include "palloc.h"
Expand Down Expand Up @@ -155,7 +154,7 @@ struct memory_block_ops {
enum memblock_state dest_state, struct operation_context *ctx);

/* returns lock associated with memory block */
os_mutex_t *(*get_lock)(const struct memory_block *m);
pthread_mutex_t *(*get_lock)(const struct memory_block *m);

/* returns whether a block is allocated or not */
enum memblock_state (*get_state)(const struct memory_block *m);
Expand Down
167 changes: 0 additions & 167 deletions src/common/dav/os_thread.h

This file was deleted.

Loading

0 comments on commit 04279b1

Please sign in to comment.