]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/memory/memkind_kmem_allocator.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // Copyright (c) 2019 Intel Corporation
3 // This source code is licensed under both the GPLv2 (found in the
4 // COPYING file in the root directory) and Apache 2.0 License
5 // (found in the LICENSE.Apache file in the root directory).
11 #include "memory/memkind_kmem_allocator.h"
13 namespace ROCKSDB_NAMESPACE
{
14 Status
MemkindKmemAllocator::PrepareOptions(const ConfigOptions
& options
) {
16 if (!IsSupported(&message
)) {
17 return Status::NotSupported(message
);
19 return MemoryAllocator::PrepareOptions(options
);
24 void* MemkindKmemAllocator::Allocate(size_t size
) {
25 void* p
= memkind_malloc(MEMKIND_DAX_KMEM
, size
);
27 throw std::bad_alloc();
32 void MemkindKmemAllocator::Deallocate(void* p
) {
33 memkind_free(MEMKIND_DAX_KMEM
, p
);
36 #ifdef ROCKSDB_MALLOC_USABLE_SIZE
37 size_t MemkindKmemAllocator::UsableSize(void* p
,
38 size_t /*allocation_size*/) const {
39 return memkind_malloc_usable_size(MEMKIND_DAX_KMEM
, p
);
41 #endif // ROCKSDB_MALLOC_USABLE_SIZE
44 } // namespace ROCKSDB_NAMESPACE