Skip to content

Commit

Permalink
DAOS-14363 umem: Phase-2 allocator with MB support (#14151)
Browse files Browse the repository at this point in the history
- The phase-2 allocator will now support evictable and non-evictable
  memory buckets. The new allocator can be enabled using
  DAOS_MD_ON_SSD_MODE=3.
- Unit tests added to test the functionality.

Signed-off-by: Sherin T George <sherin-t.george@hpe.com>
  • Loading branch information
sherintg authored May 28, 2024
1 parent 4753dde commit 29826e2
Show file tree
Hide file tree
Showing 41 changed files with 3,892 additions and 1,349 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ pipeline {
}
steps {
job_step_update(
unitTest(timeout_time: 120,
unitTest(timeout_time: 180,
unstash_opt: true,
ignore_failure: true,
inst_repos: prRepos(),
Expand Down
4 changes: 2 additions & 2 deletions src/common/dav/dav.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2015-2023, Intel Corporation */
/* Copyright 2015-2024, Intel Corporation */

/*
* dav_flags.h -- Interfaces exported by DAOS internal Allocator for VOS (DAV)
Expand Down Expand Up @@ -29,7 +29,7 @@

#define DAV_XALLOC_CLASS_MASK ((((uint64_t)1 << 16) - 1) << 48)
#ifdef DAV_V2_BUILD
#define DAV_XALLOC_EZONE_MASK ((((uint64_t)1 << 16) - 1) << 32)
#define DAV_XALLOC_EZONE_MASK ((((uint64_t)1 << 32) - 1) << 16)
#else /* DAV_V2_BUILD */
#define DAV_XALLOC_EZONE_MASK 0
#endif /* DAV_V2_BUILD */
Expand Down
2 changes: 1 addition & 1 deletion src/common/dav/dav_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ dav_obj_open_internal(int fd, int flags, size_t sz, const char *path, struct ume
D_ERROR("meta context not defined. WAL commit disabled for %s\n", path);
} else {
num_pages = (sz + UMEM_CACHE_PAGE_SZ - 1) >> UMEM_CACHE_PAGE_SZ_SHIFT;
rc = umem_cache_alloc(store, UMEM_CACHE_PAGE_SZ, num_pages, 0, 0, 0, base,
rc = umem_cache_alloc(store, UMEM_CACHE_PAGE_SZ, num_pages, 0, 0, 0, base, NULL,
NULL, NULL);
if (rc != 0) {
D_ERROR("Could not allocate page cache: rc=" DF_RC "\n", DP_RC(rc));
Expand Down
5 changes: 3 additions & 2 deletions src/common/dav_v2/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@


SRC = ['alloc_class.c', 'bucket.c', 'container_ravl.c', 'container_seglists.c', 'critnib.c',
'dav_clogs.c', 'dav_iface.c', 'heap.c', 'memblock.c', 'memops.c', 'palloc.c', 'ravl.c',
'ravl_interval.c', 'recycler.c', 'stats.c', 'tx.c', 'ulog.c', 'util.c', 'wal_tx.c']
'dav_clogs.c', 'dav_iface.c', 'heap.c', 'memblock.c', 'memops.c', 'meta_io.c',
'palloc.c', 'ravl.c', 'ravl_interval.c', 'recycler.c', 'stats.c', 'tx.c', 'ulog.c',
'util.c', 'wal_tx.c']


def scons():
Expand Down
4 changes: 2 additions & 2 deletions src/common/dav_v2/alloc_class.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2016-2023, Intel Corporation */
/* Copyright 2016-2024, Intel Corporation */

/*
* alloc_class.c -- implementation of allocation classes
Expand Down Expand Up @@ -607,7 +607,7 @@ alloc_class_by_run(struct alloc_class_collection *ac,

uint32_t map_idx_s = (uint32_t)map_idx;

ASSERT(size_idx <= UINT16_MAX);
ASSERT(size_idx <= MAX_CHUNK);

uint16_t size_idx_s = (uint16_t)size_idx;
uint16_t flags_s = (uint16_t)flags;
Expand Down
14 changes: 7 additions & 7 deletions src/common/dav_v2/bucket.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2015-2023, Intel Corporation */
/* Copyright 2015-2024, Intel Corporation */

/*
* bucket.c -- bucket implementation
Expand Down Expand Up @@ -28,7 +28,7 @@ struct bucket {
struct block_container *container;
const struct block_container_ops *c_ops;
struct memory_block_reserved *active_memory_block;
struct zoneset *zset;
struct mbrt *mb;
int is_active;
};

Expand Down Expand Up @@ -75,7 +75,7 @@ bucket_fini(struct bucket *b)
* bucket_locked_new -- creates a new locked bucket instance
*/
struct bucket_locked *
bucket_locked_new(struct block_container *c, struct alloc_class *aclass, struct zoneset *zset)
bucket_locked_new(struct block_container *c, struct alloc_class *aclass, struct mbrt *mb)
{
ASSERTne(c, NULL);

Expand All @@ -90,7 +90,7 @@ bucket_locked_new(struct block_container *c, struct alloc_class *aclass, struct

util_mutex_init(&b->lock);
b->bucket.locked = b;
b->bucket.zset = zset;
b->bucket.mb = mb;

return b;

Expand Down Expand Up @@ -268,8 +268,8 @@ bucket_active_block(struct bucket *b)
return b->is_active ? b->active_memory_block : NULL;
}

struct zoneset *
bucket_get_zoneset(struct bucket *b)
struct mbrt *
bucket_get_mbrt(struct bucket *b)
{
return b->zset;
return b->mb;
}
8 changes: 4 additions & 4 deletions src/common/dav_v2/bucket.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2015-2023, Intel Corporation */
/* Copyright 2015-2024, Intel Corporation */

/*
* bucket.h -- internal definitions for bucket
Expand All @@ -22,7 +22,7 @@ struct bucket_locked;
struct bucket;

struct bucket_locked *
bucket_locked_new(struct block_container *c, struct alloc_class *aclass, struct zoneset *zset);
bucket_locked_new(struct block_container *c, struct alloc_class *aclass, struct mbrt *mb);

struct bucket *bucket_acquire(struct bucket_locked *b);
void bucket_release(struct bucket *b);
Expand All @@ -41,7 +41,7 @@ int bucket_detach_run(struct bucket *b,
struct memory_block_reserved *bucket_active_block(struct bucket *b);

void bucket_locked_delete(struct bucket_locked *b);
struct zoneset *
bucket_get_zoneset(struct bucket *b);
struct mbrt *
bucket_get_mbrt(struct bucket *b);

#endif /* __DAOS_COMMON_BUCKET_H */
24 changes: 13 additions & 11 deletions src/common/dav_v2/container_ravl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

struct block_container_ravl {
struct block_container super;
struct ravl *tree;
struct memory_block m;
struct ravl *tree;
};

/*
Expand Down Expand Up @@ -55,15 +56,9 @@ container_ravl_insert_block(struct block_container *bc,
struct block_container_ravl *c =
(struct block_container_ravl *)bc;

struct memory_block *e = m->m_ops->get_user_data(m);
c->m = *m;

VALGRIND_DO_MAKE_MEM_DEFINED(e, sizeof(*e));
VALGRIND_ADD_TO_TX(e, sizeof(*e));
*e = *m;
VALGRIND_SET_CLEAN(e, sizeof(*e));
VALGRIND_REMOVE_FROM_TX(e, sizeof(*e));

return ravl_insert(c->tree, e);
return ravl_emplace_copy(c->tree, m);
}

/*
Expand All @@ -84,7 +79,13 @@ container_ravl_get_rm_block_bestfit(struct block_container *bc,
return ENOMEM;

struct memory_block *e = ravl_data(n);
*m = *e;
*m = c->m;
m->zone_id = e->zone_id;
m->chunk_id = e->chunk_id;
m->size_idx = e->size_idx;
m->block_off = e->block_off;
/* Rest of the fields in e should not be accessed. */

ravl_remove(c->tree, n);

return 0;
Expand Down Expand Up @@ -180,7 +181,8 @@ container_new_ravl(struct palloc_heap *heap)

bc->super.heap = heap;
bc->super.c_ops = &container_ravl_ops;
bc->tree = ravl_new(container_compare_memblocks);
bc->tree =
ravl_new_sized(container_compare_memblocks, offsetof(struct memory_block, m_ops));
if (bc->tree == NULL)
goto error_ravl_new;

Expand Down
4 changes: 2 additions & 2 deletions src/common/dav_v2/container_seglists.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2015-2023, Intel Corporation */
/* Copyright 2015-2024, Intel Corporation */

/*
* container_seglists.c -- implementation of segregated lists block container
Expand Down Expand Up @@ -35,7 +35,7 @@ container_seglists_insert_block(struct block_container *bc,
const struct memory_block *m)
{
ASSERT(m->chunk_id < MAX_CHUNK);
ASSERT(m->zone_id < UINT16_MAX);
ASSERT(m->zone_id < UINT32_MAX);
ASSERTne(m->size_idx, 0);

struct block_container_seglists *c =
Expand Down
Loading

0 comments on commit 29826e2

Please sign in to comment.