Skip to content

Commit

Permalink
DAOS-13701: Memory bucket allocator API definition (#13152)
Browse files Browse the repository at this point in the history
- New umem macros are exported to do the allocation within
  memory bucket. umem internally now calls the modified backend
  allocator routines with memory bucket id passed as argument.
- umem_get_mb_evictable() and dav_get_zone_evictable() are
  added to support allocator returning preferred zone to be
  used as evictable memory bucket for current allocations. Right
  now these routines always return zero.
- The dav heap runtime is cleaned up to make provision for
  memory bucket implementation.

Signed-off-by: Sherin T George <sherin-t.george@hpe.com>
  • Loading branch information
sherintg authored Oct 11, 2023
1 parent f685497 commit 4951549
Show file tree
Hide file tree
Showing 17 changed files with 1,100 additions and 1,309 deletions.
12 changes: 7 additions & 5 deletions src/common/ad_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,8 @@ umo_tx_free(struct umem_instance *umm, umem_off_t umoff)
}

static umem_off_t
umo_tx_alloc(struct umem_instance *umm, size_t size, uint64_t flags,
unsigned int type_num)
umo_tx_alloc(struct umem_instance *umm, size_t size, uint64_t flags, unsigned int type_num,
unsigned int mbkt_id)
{
struct ad_tx *tx = tx_get();
struct ad_blob_handle bh = umm2ad_blob_hdl(umm);
Expand Down Expand Up @@ -1242,7 +1242,8 @@ umo_tx_add_ptr(struct umem_instance *umm, void *ptr, size_t size)
}

static umem_off_t
umo_reserve(struct umem_instance *umm, void *act, size_t size, unsigned int type_num)
umo_reserve(struct umem_instance *umm, void *act, size_t size, unsigned int type_num,
unsigned int mbkt_id)
{
struct ad_blob_handle bh = umm2ad_blob_hdl(umm);
struct ad_reserv_act *ract = act;
Expand Down Expand Up @@ -1330,9 +1331,10 @@ umo_atomic_copy(struct umem_instance *umm, void *dest, const void *src, size_t l
}

static umem_off_t
umo_atomic_alloc(struct umem_instance *umm, size_t size, unsigned int type_num)
umo_atomic_alloc(struct umem_instance *umm, size_t size, unsigned int type_num,
unsigned int mbkt_id)
{
return umo_tx_alloc(umm, size, 0, type_num);
return umo_tx_alloc(umm, size, 0, type_num, mbkt_id);
}

static int
Expand Down
25 changes: 15 additions & 10 deletions src/common/dav/bucket.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2015-2022, Intel Corporation */
/* Copyright 2015-2023, Intel Corporation */

/*
* bucket.c -- bucket implementation
Expand All @@ -23,15 +23,13 @@

struct bucket {
/* this struct is both the lock guard and the locked state */
struct bucket_locked *locked;

struct alloc_class *aclass;

struct block_container *container;
struct bucket_locked *locked;
struct alloc_class *aclass;
struct block_container *container;
const struct block_container_ops *c_ops;

struct memory_block_reserved *active_memory_block;
int is_active;
struct memory_block_reserved *active_memory_block;
struct zoneset *zset;
int is_active;
};

struct bucket_locked {
Expand Down Expand Up @@ -77,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)
bucket_locked_new(struct block_container *c, struct alloc_class *aclass, struct zoneset *zset)
{
ASSERTne(c, NULL);

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

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

return b;

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

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

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

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

struct bucket *bucket_acquire(struct bucket_locked *b);
void bucket_release(struct bucket *b);
Expand All @@ -41,5 +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);

#endif /* __DAOS_COMMON_BUCKET_H */
Loading

0 comments on commit 4951549

Please sign in to comment.