repo
stringlengths
1
152
file
stringlengths
15
205
code
stringlengths
0
41.6M
file_length
int64
0
41.6M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
90 values
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/pmalloc.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * pmalloc.h -- internal definitions for persistent malloc */ #ifndef LIBPMEMOBJ_PMALLOC_H #define LIBPMEMOBJ_PMALLOC_H 1 #include <stddef.h> #include <stdint.h> #include "libpmemobj.h" #include "memops.h" #include "palloc.h" #ifdef __cplusplus extern "C" { #endif /* single operations done in the internal context of the lane */ int pmalloc(PMEMobjpool *pop, uint64_t *off, size_t size, uint64_t extra_field, uint16_t object_flags); int pmalloc_construct(PMEMobjpool *pop, uint64_t *off, size_t size, palloc_constr constructor, void *arg, uint64_t extra_field, uint16_t object_flags, uint16_t class_id); int prealloc(PMEMobjpool *pop, uint64_t *off, size_t size, uint64_t extra_field, uint16_t object_flags); void pfree(PMEMobjpool *pop, uint64_t *off); /* external operation to be used together with context-aware palloc funcs */ struct operation_context *pmalloc_operation_hold(PMEMobjpool *pop); struct operation_context *pmalloc_operation_hold_no_start(PMEMobjpool *pop); void pmalloc_operation_release(PMEMobjpool *pop); void pmalloc_ctl_register(PMEMobjpool *pop); int pmalloc_cleanup(PMEMobjpool *pop); int pmalloc_boot(PMEMobjpool *pop); #ifdef __cplusplus } #endif #endif
2,806
34.0875
76
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/recycler.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * recycler.h -- internal definitions of run recycler * * This is a container that stores runs that are currently not used by any of * the buckets. */ #ifndef LIBPMEMOBJ_RECYCLER_H #define LIBPMEMOBJ_RECYCLER_H 1 #include "memblock.h" #include "vec.h" #ifdef __cplusplus extern "C" { #endif struct recycler; VEC(empty_runs, struct memory_block); struct recycler_element { uint32_t max_free_block; uint32_t free_space; uint32_t chunk_id; uint32_t zone_id; }; struct recycler *recycler_new(struct palloc_heap *layout, size_t nallocs); void recycler_delete(struct recycler *r); struct recycler_element recycler_element_new(struct palloc_heap *heap, const struct memory_block *m); int recycler_put(struct recycler *r, const struct memory_block *m, struct recycler_element element); int recycler_get(struct recycler *r, struct memory_block *m); void recycler_pending_put(struct recycler *r, struct memory_block_reserved *m); struct empty_runs recycler_recalc(struct recycler *r, int force); void recycler_inc_unaccounted(struct recycler *r, const struct memory_block *m); #ifdef __cplusplus } #endif #endif
2,734
30.802326
77
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/palloc.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * palloc.h -- internal definitions for persistent allocator */ #ifndef LIBPMEMOBJ_PALLOC_H #define LIBPMEMOBJ_PALLOC_H 1 #include <stddef.h> #include <stdint.h> #include "libpmemobj.h" #include "memops.h" #include "ulog.h" #include "valgrind_internal.h" #include "stats.h" #ifdef __cplusplus extern "C" { #endif #define PALLOC_CTL_DEBUG_NO_PATTERN (-1) struct palloc_heap { struct pmem_ops p_ops; struct heap_layout *layout; struct heap_rt *rt; uint64_t *sizep; uint64_t growsize; struct stats *stats; struct pool_set *set; void *base; int alloc_pattern; }; struct memory_block; typedef int (*palloc_constr)(void *base, void *ptr, size_t usable_size, void *arg); int palloc_operation(struct palloc_heap *heap, uint64_t off, uint64_t *dest_off, size_t size, palloc_constr constructor, void *arg, uint64_t extra_field, uint16_t object_flags, uint16_t class_id, struct operation_context *ctx); int palloc_reserve(struct palloc_heap *heap, size_t size, palloc_constr constructor, void *arg, uint64_t extra_field, uint16_t object_flags, uint16_t class_id, struct pobj_action *act); void palloc_defer_free(struct palloc_heap *heap, uint64_t off, struct pobj_action *act); void palloc_cancel(struct palloc_heap *heap, struct pobj_action *actv, size_t actvcnt); void palloc_publish(struct palloc_heap *heap, struct pobj_action *actv, size_t actvcnt, struct operation_context *ctx); void palloc_set_value(struct palloc_heap *heap, struct pobj_action *act, uint64_t *ptr, uint64_t value); uint64_t palloc_first(struct palloc_heap *heap); uint64_t palloc_next(struct palloc_heap *heap, uint64_t off); size_t palloc_usable_size(struct palloc_heap *heap, uint64_t off); uint64_t palloc_extra(struct palloc_heap *heap, uint64_t off); uint16_t palloc_flags(struct palloc_heap *heap, uint64_t off); int palloc_boot(struct palloc_heap *heap, void *heap_start, uint64_t heap_size, uint64_t *sizep, void *base, struct pmem_ops *p_ops, struct stats *stats, struct pool_set *set); int palloc_buckets_init(struct palloc_heap *heap); int palloc_init(void *heap_start, uint64_t heap_size, uint64_t *sizep, struct pmem_ops *p_ops); void *palloc_heap_end(struct palloc_heap *h); int palloc_heap_check(void *heap_start, uint64_t heap_size); int palloc_heap_check_remote(void *heap_start, uint64_t heap_size, struct remote_ops *ops); void palloc_heap_cleanup(struct palloc_heap *heap); size_t palloc_heap(void *heap_start); /* foreach callback, terminates iteration if return value is non-zero */ typedef int (*object_callback)(const struct memory_block *m, void *arg); #if VG_MEMCHECK_ENABLED void palloc_heap_vg_open(struct palloc_heap *heap, int objects); #endif #ifdef __cplusplus } #endif #endif
4,336
30.427536
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/container.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * container.h -- internal definitions for block containers */ #ifndef LIBPMEMOBJ_CONTAINER_H #define LIBPMEMOBJ_CONTAINER_H 1 #include "memblock.h" #ifdef __cplusplus extern "C" { #endif struct block_container { struct block_container_ops *c_ops; struct palloc_heap *heap; }; struct block_container_ops { /* inserts a new memory block into the container */ int (*insert)(struct block_container *c, const struct memory_block *m); /* removes exact match memory block */ int (*get_rm_exact)(struct block_container *c, const struct memory_block *m); /* removes and returns the best-fit memory block for size */ int (*get_rm_bestfit)(struct block_container *c, struct memory_block *m); /* finds exact match memory block */ int (*get_exact)(struct block_container *c, const struct memory_block *m); /* checks whether the container is empty */ int (*is_empty)(struct block_container *c); /* removes all elements from the container */ void (*rm_all)(struct block_container *c); /* deletes the container */ void (*destroy)(struct block_container *c); }; #ifdef __cplusplus } #endif #endif /* LIBPMEMOBJ_CONTAINER_H */
2,751
32.560976
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/stats.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * stats.h -- definitions of statistics */ #ifndef LIBPMEMOBJ_STATS_H #define LIBPMEMOBJ_STATS_H 1 #include "ctl.h" #ifdef __cplusplus extern "C" { #endif struct stats_transient { int unused; }; struct stats_persistent { uint64_t heap_curr_allocated; }; struct stats { int enabled; struct stats_transient *transient; struct stats_persistent *persistent; }; #define STATS_INC(stats, type, name, value) do {\ if ((stats)->enabled)\ util_fetch_and_add64((&(stats)->type->name), (value));\ } while (0) #define STATS_SUB(stats, type, name, value) do {\ if ((stats)->enabled)\ util_fetch_and_sub64((&(stats)->type->name), (value));\ } while (0) #define STATS_SET(stats, type, name, value) do {\ if ((stats)->enabled)\ util_atomic_store_explicit64((&(stats)->type->name), (value),\ memory_order_release);\ } while (0) #define STATS_CTL_LEAF(type, name)\ {CTL_STR(name), CTL_NODE_LEAF,\ {CTL_READ_HANDLER(type##_##name), NULL, NULL},\ NULL, NULL} #define STATS_CTL_HANDLER(type, name, varname)\ static int CTL_READ_HANDLER(type##_##name)(void *ctx,\ enum ctl_query_source source, void *arg, struct ctl_indexes *indexes)\ {\ PMEMobjpool *pop = ctx;\ uint64_t *argv = arg;\ util_atomic_load_explicit64(&pop->stats->type->varname,\ argv, memory_order_acquire);\ return 0;\ } void stats_ctl_register(PMEMobjpool *pop); struct stats *stats_new(PMEMobjpool *pop); void stats_delete(PMEMobjpool *pop, struct stats *stats); #ifdef __cplusplus } #endif #endif
3,087
29.27451
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/container_ravl.h
/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * container_ravl.h -- internal definitions for ravl-based block container */ #ifndef LIBPMEMOBJ_CONTAINER_RAVL_H #define LIBPMEMOBJ_CONTAINER_RAVL_H 1 #include "container.h" #ifdef __cplusplus extern "C" { #endif struct block_container *container_new_ravl(struct palloc_heap *heap); #ifdef __cplusplus } #endif #endif /* LIBPMEMOBJ_CONTAINER_RAVL_H */
1,960
36
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/tx.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * tx.h -- internal definitions for transactions */ #ifndef LIBPMEMOBJ_INTERNAL_TX_H #define LIBPMEMOBJ_INTERNAL_TX_H 1 #include <stdint.h> #include "obj.h" #include "ulog.h" #ifdef __cplusplus extern "C" { #endif #define TX_DEFAULT_RANGE_CACHE_SIZE (1 << 15) #define TX_DEFAULT_RANGE_CACHE_THRESHOLD (1 << 12) #define TX_RANGE_MASK (8ULL - 1) #define TX_RANGE_MASK_LEGACY (32ULL - 1) #define TX_ALIGN_SIZE(s, amask) (((s) + (amask)) & ~(amask)) struct tx_parameters { size_t cache_size; }; /* * Returns the current transaction's pool handle, NULL if not within * a transaction. */ PMEMobjpool *tx_get_pop(void); void tx_ctl_register(PMEMobjpool *pop); struct tx_parameters *tx_params_new(void); void tx_params_delete(struct tx_parameters *tx_params); #ifdef __cplusplus } #endif #endif
2,409
30.710526
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/memblock.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * memblock.h -- internal definitions for memory block */ #ifndef LIBPMEMOBJ_MEMBLOCK_H #define LIBPMEMOBJ_MEMBLOCK_H 1 #include <stddef.h> #include <stdint.h> #include "os_thread.h" #include "heap_layout.h" #include "memops.h" #include "palloc.h" #ifdef __cplusplus extern "C" { #endif #define MEMORY_BLOCK_NONE \ (struct memory_block)\ {0, 0, 0, 0, NULL, NULL, MAX_HEADER_TYPES, MAX_MEMORY_BLOCK} #define MEMORY_BLOCK_IS_NONE(_m)\ ((_m).heap == NULL) #define MEMORY_BLOCK_EQUALS(lhs, rhs)\ ((lhs).zone_id == (rhs).zone_id && (lhs).chunk_id == (rhs).chunk_id &&\ (lhs).block_off == (rhs).block_off && (lhs).heap == (rhs).heap) enum memory_block_type { /* * Huge memory blocks are directly backed by memory chunks. A single * huge block can consist of several chunks. * The persistent representation of huge memory blocks can be thought * of as a doubly linked list with variable length elements. * That list is stored in the chunk headers array where one element * directly corresponds to one chunk. * * U - used, F - free, R - footer, . - empty * |U| represents a used chunk with a size index of 1, with type * information (CHUNK_TYPE_USED) stored in the corresponding header * array element - chunk_headers[chunk_id]. * * |F...R| represents a free chunk with size index of 5. The empty * chunk headers have undefined values and shouldn't be used. All * chunks with size larger than 1 must have a footer in the last * corresponding header array - chunk_headers[chunk_id - size_idx - 1]. * * The above representation of chunks will be used to describe the * way fail-safety is achieved during heap operations. * * Allocation of huge memory block with size index 5: * Initial heap state: |U| <> |F..R| <> |U| <> |F......R| * * The only block that matches that size is at very end of the chunks * list: |F......R| * * As the request was for memory block of size 5, and this ones size is * 7 there's a need to first split the chunk in two. * 1) The last chunk header of the new allocation is marked as footer * and the block after that one is marked as free: |F...RF.R| * This is allowed and has no impact on the heap because this * modification is into chunk header that is otherwise unused, in * other words the linked list didn't change. * * 2) The size index of the first header is changed from previous value * of 7 to 5: |F...R||F.R| * This is a single fail-safe atomic operation and this is the * first change that is noticeable by the heap operations. * A single linked list element is split into two new ones. * * 3) The allocation process either uses redo log or changes directly * the chunk header type from free to used: |U...R| <> |F.R| * * In a similar fashion the reverse operation, free, is performed: * Initial heap state: |U| <> |F..R| <> |F| <> |U...R| <> |F.R| * * This is the heap after the previous example with the single chunk * in between changed from used to free. * * 1) Determine the neighbors of the memory block which is being * freed. * * 2) Update the footer (if needed) information of the last chunk which * is the memory block being freed or it's neighbor to the right. * |F| <> |U...R| <> |F.R << this one| * * 3) Update the size index and type of the left-most chunk header. * And so this: |F << this one| <> |U...R| <> |F.R| * becomes this: |F.......R| * The entire chunk header can be updated in a single fail-safe * atomic operation because it's size is only 64 bytes. */ MEMORY_BLOCK_HUGE, /* * Run memory blocks are chunks with CHUNK_TYPE_RUN and size index of 1. * The entire chunk is subdivided into smaller blocks and has an * additional metadata attached in the form of a bitmap - each bit * corresponds to a single block. * In this case there's no need to perform any coalescing or splitting * on the persistent metadata. * The bitmap is stored on a variable number of 64 bit values and * because of the requirement of allocation fail-safe atomicity the * maximum size index of a memory block from a run is 64 - since that's * the limit of atomic write guarantee. * * The allocation/deallocation process is a single 8 byte write that * sets/clears the corresponding bits. Depending on the user choice * it can either be made atomically or using redo-log when grouped with * other operations. * It's also important to note that in a case of realloc it might so * happen that a single 8 byte bitmap value has its bits both set and * cleared - that's why the run memory block metadata changes operate * on AND'ing or OR'ing a bitmask instead of directly setting the value. */ MEMORY_BLOCK_RUN, MAX_MEMORY_BLOCK }; enum memblock_state { MEMBLOCK_STATE_UNKNOWN, MEMBLOCK_ALLOCATED, MEMBLOCK_FREE, MAX_MEMBLOCK_STATE, }; /* runtime bitmap information for a run */ struct run_bitmap { unsigned nvalues; /* number of 8 byte values - size of values array */ unsigned nbits; /* number of valid bits */ size_t size; /* total size of the bitmap in bytes */ uint64_t *values; /* pointer to the bitmap's values array */ }; struct memory_block_ops { /* returns memory block size */ size_t (*block_size)(const struct memory_block *m); /* prepares header modification operation */ void (*prep_hdr)(const struct memory_block *m, 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); /* returns whether a block is allocated or not */ enum memblock_state (*get_state)(const struct memory_block *m); /* returns pointer to the data of a block */ void *(*get_user_data)(const struct memory_block *m); /* * Returns the size of a memory block without overhead. * This is the size of a data block that can be used. */ size_t (*get_user_size)(const struct memory_block *m); /* returns pointer to the beginning of data of a run block */ void *(*get_real_data)(const struct memory_block *m); /* returns the size of a memory block, including headers */ size_t (*get_real_size)(const struct memory_block *m); /* writes a header of an allocation */ void (*write_header)(const struct memory_block *m, uint64_t extra_field, uint16_t flags); void (*invalidate)(const struct memory_block *m); /* * Checks the header type of a chunk matches the expected type and * modifies it if necessary. This is fail-safe atomic. */ void (*ensure_header_type)(const struct memory_block *m, enum header_type t); /* * Reinitializes a block after a heap restart. * This is called for EVERY allocation, but *only* under Valgrind. */ void (*reinit_header)(const struct memory_block *m); /* returns the extra field of an allocation */ uint64_t (*get_extra)(const struct memory_block *m); /* returns the flags of an allocation */ uint16_t (*get_flags)(const struct memory_block *m); /* initializes memblock in valgrind */ void (*vg_init)(const struct memory_block *m, int objects, object_callback cb, void *arg); /* iterates over every free block */ int (*iterate_free)(const struct memory_block *m, object_callback cb, void *arg); /* iterates over every used block */ int (*iterate_used)(const struct memory_block *m, object_callback cb, void *arg); /* calculates number of free units, valid only for runs */ void (*calc_free)(const struct memory_block *m, uint32_t *free_space, uint32_t *max_free_block); /* this is called exactly once for every existing chunk */ void (*reinit_chunk)(const struct memory_block *m); /* * Initializes bitmap data for a run. * Do *not* use this function unless absolutely necessery, it breaks * the abstraction layer by exposing implementation details. */ void (*get_bitmap)(const struct memory_block *m, struct run_bitmap *b); }; struct memory_block { uint32_t chunk_id; /* index of the memory block in its zone */ uint32_t zone_id; /* index of this block zone in the heap */ /* * Size index of the memory block represented in either multiple of * CHUNKSIZE in the case of a huge chunk or in multiple of a run * block size. */ uint32_t size_idx; /* * Used only for run chunks, must be zeroed for huge. * Number of preceding blocks in the chunk. In other words, the * position of this memory block in run bitmap. */ uint32_t block_off; /* * The variables below are associated with the memory block and are * stored here for convenience. Those fields are filled by either the * memblock_from_offset or memblock_rebuild_state, and they should not * be modified manually. */ const struct memory_block_ops *m_ops; struct palloc_heap *heap; enum header_type header_type; enum memory_block_type type; }; /* * This is a representation of a run memory block that is active in a bucket or * is on a pending list in the recycler. * This structure should never be passed around by value because the address of * the nresv variable can be in reservations made through palloc_reserve(). Only * if the number of reservations equals 0 the structure can be moved/freed. */ struct memory_block_reserved { struct memory_block m; /* * Number of reservations made from this run, the pointer to this value * is stored in a user facing pobj_action structure. Decremented once * the reservation is published or canceled. */ int nresv; }; struct memory_block memblock_from_offset(struct palloc_heap *heap, uint64_t off); struct memory_block memblock_from_offset_opt(struct palloc_heap *heap, uint64_t off, int size); void memblock_rebuild_state(struct palloc_heap *heap, struct memory_block *m); struct memory_block memblock_huge_init(struct palloc_heap *heap, uint32_t chunk_id, uint32_t zone_id, uint32_t size_idx); struct memory_block memblock_run_init(struct palloc_heap *heap, uint32_t chunk_id, uint32_t zone_id, uint32_t size_idx, uint16_t flags, uint64_t unit_size, uint64_t alignment); void memblock_run_bitmap(uint32_t *size_idx, uint16_t flags, uint64_t unit_size, uint64_t alignment, void *content, struct run_bitmap *b); #ifdef __cplusplus } #endif #endif
11,746
35.481366
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/pmemops.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef LIBPMEMOBJ_PMEMOPS_H #define LIBPMEMOBJ_PMEMOPS_H 1 #include <stddef.h> #include <stdint.h> #include "util.h" #ifdef __cplusplus extern "C" { #endif typedef int (*persist_fn)(void *base, const void *, size_t, unsigned); typedef int (*flush_fn)(void *base, const void *, size_t, unsigned); typedef void (*drain_fn)(void *base); typedef void *(*memcpy_fn)(void *base, void *dest, const void *src, size_t len, unsigned flags); typedef void *(*memmove_fn)(void *base, void *dest, const void *src, size_t len, unsigned flags); typedef void *(*memset_fn)(void *base, void *dest, int c, size_t len, unsigned flags); typedef int (*remote_read_fn)(void *ctx, uintptr_t base, void *dest, void *addr, size_t length); struct pmem_ops { /* for 'master' replica: with or without data replication */ persist_fn persist; /* persist function */ flush_fn flush; /* flush function */ drain_fn drain; /* drain function */ memcpy_fn memcpy; /* persistent memcpy function */ memmove_fn memmove; /* persistent memmove function */ memset_fn memset; /* persistent memset function */ void *base; struct remote_ops { remote_read_fn read; void *ctx; uintptr_t base; } remote; }; static force_inline int pmemops_xpersist(const struct pmem_ops *p_ops, const void *d, size_t s, unsigned flags) { return p_ops->persist(p_ops->base, d, s, flags); } static force_inline void pmemops_persist(const struct pmem_ops *p_ops, const void *d, size_t s) { (void) pmemops_xpersist(p_ops, d, s, 0); } static force_inline int pmemops_xflush(const struct pmem_ops *p_ops, const void *d, size_t s, unsigned flags) { return p_ops->flush(p_ops->base, d, s, flags); } static force_inline void pmemops_flush(const struct pmem_ops *p_ops, const void *d, size_t s) { (void) pmemops_xflush(p_ops, d, s, 0); } static force_inline void pmemops_drain(const struct pmem_ops *p_ops) { p_ops->drain(p_ops->base); } static force_inline void * pmemops_memcpy(const struct pmem_ops *p_ops, void *dest, const void *src, size_t len, unsigned flags) { return p_ops->memcpy(p_ops->base, dest, src, len, flags); } static force_inline void * pmemops_memmove(const struct pmem_ops *p_ops, void *dest, const void *src, size_t len, unsigned flags) { return p_ops->memmove(p_ops->base, dest, src, len, flags); } static force_inline void * pmemops_memset(const struct pmem_ops *p_ops, void *dest, int c, size_t len, unsigned flags) { return p_ops->memset(p_ops->base, dest, c, len, flags); } #ifdef __cplusplus } #endif #endif
4,125
29.791045
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/sync.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * sync.h -- internal to obj synchronization API */ #ifndef LIBPMEMOBJ_SYNC_H #define LIBPMEMOBJ_SYNC_H 1 #include <errno.h> #include <stdint.h> #include "libpmemobj.h" #include "out.h" #include "os_thread.h" #ifdef __cplusplus extern "C" { #endif /* * internal definitions of PMEM-locks */ typedef union padded_pmemmutex { char padding[_POBJ_CL_SIZE]; struct { uint64_t runid; union { os_mutex_t mutex; struct { void *bsd_mutex_p; union padded_pmemmutex *next; } bsd_u; } mutex_u; } pmemmutex; } PMEMmutex_internal; #define PMEMmutex_lock pmemmutex.mutex_u.mutex #define PMEMmutex_bsd_mutex_p pmemmutex.mutex_u.bsd_u.bsd_mutex_p #define PMEMmutex_next pmemmutex.mutex_u.bsd_u.next typedef union padded_pmemrwlock { char padding[_POBJ_CL_SIZE]; struct { uint64_t runid; union { os_rwlock_t rwlock; struct { void *bsd_rwlock_p; union padded_pmemrwlock *next; } bsd_u; } rwlock_u; } pmemrwlock; } PMEMrwlock_internal; #define PMEMrwlock_lock pmemrwlock.rwlock_u.rwlock #define PMEMrwlock_bsd_rwlock_p pmemrwlock.rwlock_u.bsd_u.bsd_rwlock_p #define PMEMrwlock_next pmemrwlock.rwlock_u.bsd_u.next typedef union padded_pmemcond { char padding[_POBJ_CL_SIZE]; struct { uint64_t runid; union { os_cond_t cond; struct { void *bsd_cond_p; union padded_pmemcond *next; } bsd_u; } cond_u; } pmemcond; } PMEMcond_internal; #define PMEMcond_cond pmemcond.cond_u.cond #define PMEMcond_bsd_cond_p pmemcond.cond_u.bsd_u.bsd_cond_p #define PMEMcond_next pmemcond.cond_u.bsd_u.next /* * pmemobj_mutex_lock_nofail -- pmemobj_mutex_lock variant that never * fails from caller perspective. If pmemobj_mutex_lock failed, this function * aborts the program. */ static inline void pmemobj_mutex_lock_nofail(PMEMobjpool *pop, PMEMmutex *mutexp) { int ret = pmemobj_mutex_lock(pop, mutexp); if (ret) { errno = ret; FATAL("!pmemobj_mutex_lock"); } } /* * pmemobj_mutex_unlock_nofail -- pmemobj_mutex_unlock variant that never * fails from caller perspective. If pmemobj_mutex_unlock failed, this function * aborts the program. */ static inline void pmemobj_mutex_unlock_nofail(PMEMobjpool *pop, PMEMmutex *mutexp) { int ret = pmemobj_mutex_unlock(pop, mutexp); if (ret) { errno = ret; FATAL("!pmemobj_mutex_unlock"); } } int pmemobj_mutex_assert_locked(PMEMobjpool *pop, PMEMmutex *mutexp); #ifdef __cplusplus } #endif #endif
4,019
27.309859
79
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/lane.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * lane.h -- internal definitions for lanes */ #ifndef LIBPMEMOBJ_LANE_H #define LIBPMEMOBJ_LANE_H 1 #include <stdint.h> #include "ulog.h" #include "libpmemobj.h" #ifdef __cplusplus extern "C" { #endif /* * Distance between lanes used by threads required to prevent threads from * false sharing part of lanes array. Used if properly spread lanes are * available. Otherwise less spread out lanes would be used. */ #define LANE_JUMP (64 / sizeof(uint64_t)) /* * Number of times the algorithm will try to reacquire the primary lane for the * thread. If this threshold is exceeded, a new primary lane is selected for the * thread. */ #define LANE_PRIMARY_ATTEMPTS 128 #define RLANE_DEFAULT 0 #define LANE_TOTAL_SIZE 3072 /* 3 * 1024 (sum of 3 old lane sections) */ /* * We have 3 kilobytes to distribute. * The smallest capacity is needed for the internal redo log for which we can * accurately calculate the maximum number of occupied space: 48 bytes, * 3 times sizeof(struct ulog_entry_val). One for bitmap OR, second for bitmap * AND, third for modification of the destination pointer. For future needs, * this has been bumped up to 12 ulog entries. * * The remaining part has to be split between transactional redo and undo logs, * and since by far the most space consuming operations are transactional * snapshots, most of the space, 2 kilobytes, is assigned to the undo log. * After that, the remainder, 640 bytes, or 40 ulog entries, is left for the * transactional redo logs. * Thanks to this distribution, all small and medium transactions should be * entirely performed without allocating any additional metadata. */ #define LANE_UNDO_SIZE 2048 #define LANE_REDO_EXTERNAL_SIZE 640 #define LANE_REDO_INTERNAL_SIZE 192 struct lane_layout { /* * Redo log for self-contained and 'one-shot' allocator operations. * Cannot be extended. */ struct ULOG(LANE_REDO_INTERNAL_SIZE) internal; /* * Redo log for large operations/transactions. * Can be extended by the use of internal ulog. */ struct ULOG(LANE_REDO_EXTERNAL_SIZE) external; /* * Undo log for snapshots done in a transaction. * Can be extended/shrunk by the use of internal ulog. */ struct ULOG(LANE_UNDO_SIZE) undo; }; struct lane { struct lane_layout *layout; /* pointer to persistent layout */ struct operation_context *internal; /* context for internal ulog */ struct operation_context *external; /* context for external ulog */ struct operation_context *undo; /* context for undo ulog */ }; struct lane_descriptor { /* * Number of lanes available at runtime must be <= total number of lanes * available in the pool. Number of lanes can be limited by shortage of * other resources e.g. available RNIC's submission queue sizes. */ unsigned runtime_nlanes; unsigned next_lane_idx; uint64_t *lane_locks; struct lane *lane; }; typedef int (*section_layout_op)(PMEMobjpool *pop, void *data, unsigned length); typedef void *(*section_constr)(PMEMobjpool *pop, void *data); typedef void (*section_destr)(PMEMobjpool *pop, void *rt); typedef int (*section_global_op)(PMEMobjpool *pop); struct section_operations { section_constr construct_rt; section_destr destroy_rt; section_layout_op check; section_layout_op recover; section_global_op boot; section_global_op cleanup; }; struct lane_info { uint64_t pop_uuid_lo; uint64_t lane_idx; unsigned long nest_count; /* * The index of the primary lane for the thread. A thread will always * try to acquire the primary lane first, and only if that fails it will * look for a different available lane. */ uint64_t primary; int primary_attempts; struct lane_info *prev, *next; }; void lane_info_boot(void); void lane_info_destroy(void); void lane_init_data(PMEMobjpool *pop); int lane_boot(PMEMobjpool *pop); void lane_cleanup(PMEMobjpool *pop); int lane_recover_and_section_boot(PMEMobjpool *pop); int lane_section_cleanup(PMEMobjpool *pop); int lane_check(PMEMobjpool *pop); unsigned lane_hold(PMEMobjpool *pop, struct lane **lane); void lane_release(PMEMobjpool *pop); void lane_attach(PMEMobjpool *pop, unsigned lane); unsigned lane_detach(PMEMobjpool *pop); #ifdef __cplusplus } #endif #endif
5,804
32.554913
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/bucket.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * bucket.h -- internal definitions for bucket */ #ifndef LIBPMEMOBJ_BUCKET_H #define LIBPMEMOBJ_BUCKET_H 1 #include <stddef.h> #include <stdint.h> #include "container.h" #include "memblock.h" #include "os_thread.h" #ifdef __cplusplus extern "C" { #endif #define CALC_SIZE_IDX(_unit_size, _size)\ ((_size) == 0 ? 0 : (uint32_t)((((_size) - 1) / (_unit_size)) + 1)) struct bucket { os_mutex_t lock; struct alloc_class *aclass; struct block_container *container; struct block_container_ops *c_ops; struct memory_block_reserved *active_memory_block; int is_active; }; struct bucket *bucket_new(struct block_container *c, struct alloc_class *aclass); int *bucket_current_resvp(struct bucket *b); int bucket_insert_block(struct bucket *b, const struct memory_block *m); void bucket_delete(struct bucket *b); #ifdef __cplusplus } #endif #endif
2,466
29.8375
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/ulog.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * ulog.h -- unified log public interface */ #ifndef LIBPMEMOBJ_ULOG_H #define LIBPMEMOBJ_ULOG_H 1 #include <stddef.h> #include <stdint.h> #include "vec.h" #include "pmemops.h" struct ulog_entry_base { uint64_t offset; /* offset with operation type flag */ }; /* * ulog_entry_val -- log entry */ struct ulog_entry_val { struct ulog_entry_base base; uint64_t value; /* value to be applied */ }; /* * ulog_entry_buf - ulog buffer entry */ struct ulog_entry_buf { struct ulog_entry_base base; /* offset with operation type flag */ uint64_t checksum; /* checksum of the entire log entry */ uint64_t size; /* size of the buffer to be modified */ uint8_t data[]; /* content to fill in */ }; /* * This structure *must* be located at a cacheline boundry. To achieve this, * the next field is always allocated with extra padding, and then the offset * is additionally aligned. */ #define ULOG(capacity_bytes) {\ /* 64 bytes of metadata */\ uint64_t checksum; /* checksum of ulog header and its entries */\ uint64_t next; /* offset of ulog extension */\ uint64_t capacity; /* capacity of this ulog in bytes */\ uint64_t unused[5]; /* must be 0 */\ uint8_t data[capacity_bytes]; /* N bytes of data */\ }\ #define SIZEOF_ULOG(base_capacity)\ (sizeof(struct ulog) + base_capacity) /* use this for allocations of aligned ulog extensions */ #define SIZEOF_ALIGNED_ULOG(base_capacity)\ (SIZEOF_ULOG(base_capacity) + CACHELINE_SIZE) struct ulog ULOG(0); VEC(ulog_next, uint64_t); typedef uint64_t ulog_operation_type; #define ULOG_OPERATION_SET (0b000ULL << 61ULL) #define ULOG_OPERATION_AND (0b001ULL << 61ULL) #define ULOG_OPERATION_OR (0b010ULL << 61ULL) #define ULOG_OPERATION_BUF_SET (0b101ULL << 61ULL) #define ULOG_OPERATION_BUF_CPY (0b110ULL << 61ULL) #define ULOG_BIT_OPERATIONS (ULOG_OPERATION_AND | ULOG_OPERATION_OR) typedef int (*ulog_check_offset_fn)(void *ctx, uint64_t offset); typedef int (*ulog_extend_fn)(void *, uint64_t *); typedef int (*ulog_entry_cb)(struct ulog_entry_base *e, void *arg, const struct pmem_ops *p_ops); typedef void (*ulog_free_fn)(void *base, uint64_t *next); struct ulog *ulog_next(struct ulog *ulog, const struct pmem_ops *p_ops); void ulog_construct(uint64_t offset, size_t capacity, int flush, const struct pmem_ops *p_ops); size_t ulog_capacity(struct ulog *ulog, size_t ulog_base_bytes, const struct pmem_ops *p_ops); void ulog_rebuild_next_vec(struct ulog *ulog, struct ulog_next *next, const struct pmem_ops *p_ops); int ulog_foreach_entry(struct ulog *ulog, ulog_entry_cb cb, void *arg, const struct pmem_ops *ops); int ulog_reserve(struct ulog *ulog, size_t ulog_base_nbytes, size_t *new_capacity_bytes, ulog_extend_fn extend, struct ulog_next *next, const struct pmem_ops *p_ops); void ulog_store(struct ulog *dest, struct ulog *src, size_t nbytes, size_t ulog_base_nbytes, struct ulog_next *next, const struct pmem_ops *p_ops); void ulog_clobber(struct ulog *dest, struct ulog_next *next, const struct pmem_ops *p_ops); void ulog_clobber_data(struct ulog *dest, size_t nbytes, size_t ulog_base_nbytes, struct ulog_next *next, ulog_free_fn ulog_free, const struct pmem_ops *p_ops); void ulog_process(struct ulog *ulog, ulog_check_offset_fn check, const struct pmem_ops *p_ops); size_t ulog_base_nbytes(struct ulog *ulog); int ulog_recovery_needed(struct ulog *ulog, int verify_checksum); uint64_t ulog_entry_offset(const struct ulog_entry_base *entry); ulog_operation_type ulog_entry_type( const struct ulog_entry_base *entry); struct ulog_entry_val *ulog_entry_val_create(struct ulog *ulog, size_t offset, uint64_t *dest, uint64_t value, ulog_operation_type type, const struct pmem_ops *p_ops); struct ulog_entry_buf * ulog_entry_buf_create(struct ulog *ulog, size_t offset, uint64_t *dest, const void *src, uint64_t size, ulog_operation_type type, const struct pmem_ops *p_ops); void ulog_entry_apply(const struct ulog_entry_base *e, int persist, const struct pmem_ops *p_ops); size_t ulog_entry_size(const struct ulog_entry_base *entry); void ulog_recover(struct ulog *ulog, ulog_check_offset_fn check, const struct pmem_ops *p_ops); int ulog_check(struct ulog *ulog, ulog_check_offset_fn check, const struct pmem_ops *p_ops); #endif
5,859
33.674556
77
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmemobj/ravl.h
/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * ravl.h -- internal definitions for ravl tree */ #ifndef LIBPMEMOBJ_RAVL_H #define LIBPMEMOBJ_RAVL_H 1 #include <stddef.h> #ifdef __cplusplus extern "C" { #endif struct ravl; struct ravl_node; enum ravl_predicate { RAVL_PREDICATE_EQUAL = 1 << 0, RAVL_PREDICATE_GREATER = 1 << 1, RAVL_PREDICATE_LESS = 1 << 2, RAVL_PREDICATE_LESS_EQUAL = RAVL_PREDICATE_EQUAL | RAVL_PREDICATE_LESS, RAVL_PREDICATE_GREATER_EQUAL = RAVL_PREDICATE_EQUAL | RAVL_PREDICATE_GREATER, }; typedef int ravl_compare(const void *lhs, const void *rhs); typedef void ravl_cb(void *data, void *arg); typedef void ravl_constr(void *data, size_t data_size, const void *arg); struct ravl *ravl_new(ravl_compare *compare); struct ravl *ravl_new_sized(ravl_compare *compare, size_t data_size); void ravl_delete(struct ravl *ravl); void ravl_delete_cb(struct ravl *ravl, ravl_cb cb, void *arg); int ravl_empty(struct ravl *ravl); void ravl_clear(struct ravl *ravl); int ravl_insert(struct ravl *ravl, const void *data); int ravl_emplace(struct ravl *ravl, ravl_constr constr, const void *arg); int ravl_emplace_copy(struct ravl *ravl, const void *data); struct ravl_node *ravl_find(struct ravl *ravl, const void *data, enum ravl_predicate predicate_flags); void *ravl_data(struct ravl_node *node); void ravl_remove(struct ravl *ravl, struct ravl_node *node); #ifdef __cplusplus } #endif #endif /* LIBPMEMOBJ_RAVL_H */
3,005
35.216867
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/common_badblock.sh
#!/usr/bin/env bash # # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/common_badblock.sh -- commons for the following tests: # - util_badblock # - pmempool_create # - pmempool_info # LOG=out${UNITTEST_NUM}.log COMMAND_NDCTL_NFIT_TEST_INIT="\ sudo ndctl disable-region all &>>$PREP_LOG_FILE && \ sudo modprobe -r nfit_test &>>$PREP_LOG_FILE && \ sudo modprobe nfit_test &>>$PREP_LOG_FILE && \ sudo ndctl disable-region all &>>$PREP_LOG_FILE && \ sudo ndctl zero-labels all &>>$PREP_LOG_FILE && \ sudo ndctl enable-region all &>>$PREP_LOG_FILE" COMMAND_NDCTL_NFIT_TEST_FINI="\ sudo ndctl disable-region all &>>$PREP_LOG_FILE && \ sudo modprobe -r nfit_test &>>$PREP_LOG_FILE" # # ndctl_nfit_test_init -- reset all regions and reload the nfit_test module # function ndctl_nfit_test_init() { expect_normal_exit $COMMAND_NDCTL_NFIT_TEST_INIT } # # ndctl_nfit_test_init_node -- reset all regions and reload the nfit_test module on a remote node # function ndctl_nfit_test_init_node() { expect_normal_exit run_on_node $1 "$COMMAND_NDCTL_NFIT_TEST_INIT" } # # ndctl_nfit_test_fini -- disable all regions, remove the nfit_test module # and (optionally) umount the pmem block device # # Input argument: # 1) pmem mount directory to be umounted # function ndctl_nfit_test_fini() { MOUNT_DIR=$1 [ $MOUNT_DIR ] && sudo umount $MOUNT_DIR &>> $PREP_LOG_FILE expect_normal_exit $COMMAND_NDCTL_NFIT_TEST_FINI } # # ndctl_nfit_test_fini_node -- disable all regions, remove the nfit_test module # and (optionally) umount the pmem block device on a remote node # # Input arguments: # 1) node number # 2) pmem mount directory to be umounted # function ndctl_nfit_test_fini_node() { MOUNT_DIR=$2 [ $MOUNT_DIR ] && expect_normal_exit run_on_node $1 "sudo umount $MOUNT_DIR &>> $PREP_LOG_FILE" expect_normal_exit run_on_node $1 "$COMMAND_NDCTL_NFIT_TEST_FINI" } # # ndctl_nfit_test_mount_pmem -- mount a pmem block device # # Input arguments: # 1) path of a pmem block device # 2) mount directory # function ndctl_nfit_test_mount_pmem() { FULLDEV=$1 MOUNT_DIR=$2 expect_normal_exit "\ sudo mkfs.ext4 $FULLDEV &>>$PREP_LOG_FILE && \ sudo mkdir -p $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo mount $FULLDEV $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo chmod 0777 $MOUNT_DIR" } # # ndctl_nfit_test_mount_pmem_node -- mount a pmem block device on a remote node # # Input arguments: # 1) number of a node # 2) path of a pmem block device # 3) mount directory # function ndctl_nfit_test_mount_pmem_node() { FULLDEV=$2 MOUNT_DIR=$3 expect_normal_exit run_on_node $1 "\ sudo mkfs.ext4 $FULLDEV &>>$PREP_LOG_FILE && \ sudo mkdir -p $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo mount $FULLDEV $MOUNT_DIR &>>$PREP_LOG_FILE && \ sudo chmod 0777 $MOUNT_DIR" } # # ndctl_nfit_test_get_device -- create a namespace and get name of the pmem device # of the nfit_test module # # Input argument: # 1) mode of the namespace (devdax or fsdax) # function ndctl_nfit_test_get_device() { MODE=$1 DEVTYPE="" [ "$MODE" == "devdax" ] && DEVTYPE="chardev" [ "$MODE" == "fsdax" ] && DEVTYPE="blockdev" [ "$DEVTYPE" == "" ] && echo "ERROR: wrong namespace mode: $MODE" >&2 && exit 1 BUS="nfit_test.0" REGION=$(ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) DEVICE=$(sudo ndctl create-namespace -b $BUS -r $REGION -f -m $MODE -a 4096 | sed "/$DEVTYPE/!d;s/[\", ]//g;s/$DEVTYPE://g") echo $DEVICE } # # ndctl_nfit_test_get_device_node -- create a namespace and get name of the pmem device # of the nfit_test module on a remote node # # Input argument: # 1) mode of the namespace (devdax or fsdax) # function ndctl_nfit_test_get_device_node() { MODE=$2 DEVTYPE="" [ "$MODE" == "devdax" ] && DEVTYPE="chardev" [ "$MODE" == "fsdax" ] && DEVTYPE="blockdev" [ "$DEVTYPE" == "" ] && echo "ERROR: wrong namespace mode: $MODE" >&2 && exit 1 BUS="nfit_test.0" REGION=$(expect_normal_exit run_on_node $1 ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) DEVICE=$(expect_normal_exit run_on_node $1 sudo ndctl create-namespace -b $BUS -r $REGION -f -m $MODE -a 4096 | sed "/$DEVTYPE/!d;s/[\", ]//g;s/$DEVTYPE://g") echo $DEVICE } # # ndctl_nfit_test_get_dax_device -- create a namespace and get name of the dax device # of the nfit_test module # function ndctl_nfit_test_get_dax_device() { # XXX needed by libndctl (it should be removed when it is not needed) sudo chmod o+rw /dev/ndctl* DEVICE=$(ndctl_nfit_test_get_device devdax) sudo chmod o+rw /dev/$DEVICE echo $DEVICE } # # ndctl_nfit_test_get_block_device -- create a namespace and get name of the pmem block device # of the nfit_test module # function ndctl_nfit_test_get_block_device() { DEVICE=$(ndctl_nfit_test_get_device fsdax) echo $DEVICE } # # ndctl_nfit_test_get_block_device_node -- create a namespace and get name of the pmem block device # of the nfit_test module on a remote node # function ndctl_nfit_test_get_block_device_node() { DEVICE=$(ndctl_nfit_test_get_device_node $1 fsdax) echo $DEVICE } # # ndctl_nfit_test_grant_access -- grant accesses required by libndctl # # XXX needed by libndctl (it should be removed when these extra access rights are not needed) # # Input argument: # 1) a name of pmem device # function ndctl_nfit_test_grant_access() { DEVICE=$1 BUS="nfit_test.0" REGION=$(ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) expect_normal_exit "\ sudo chmod o+rw /dev/nmem* && \ sudo chmod o+r /sys/devices/platform/$BUS/ndbus?/$REGION/*/resource && \ sudo chmod o+r /sys/devices/platform/$BUS/ndbus?/$REGION/resource" } # # ndctl_nfit_test_grant_access_node -- grant accesses required by libndctl on a node # # XXX needed by libndctl (it should be removed when these extra access rights are not needed) # # Input arguments: # 1) node number # 2) name of pmem device # function ndctl_nfit_test_grant_access_node() { DEVICE=$1 BUS="nfit_test.0" REGION=$(expect_normal_exit run_on_node $1 ndctl list -b $BUS -t pmem -Ri | sed "/dev/!d;s/[\", ]//g;s/dev://g" | tail -1) expect_normal_exit run_on_node $1 "\ sudo chmod o+rw /dev/nmem* && \ sudo chmod o+r /sys/devices/platform/$BUS/ndbus?/$REGION/*/resource && \ sudo chmod o+r /sys/devices/platform/$BUS/ndbus?/$REGION/resource" } # # ndctl_nfit_test_get_namespace_of_device -- get namespace of the pmem device # # Input argument: # 1) a name of pmem device # function ndctl_nfit_test_get_namespace_of_device() { DEVICE=$1 NAMESPACE=$(ndctl list | grep -e "$DEVICE" -e namespace | grep -B1 -e "$DEVICE" | head -n1 | cut -d'"' -f4) # XXX needed by libndctl (it should be removed when it is not needed) ndctl_nfit_test_grant_access $DEVICE echo $NAMESPACE } # # ndctl_nfit_test_get_namespace_of_device_node -- get namespace of the pmem device on a remote node # # Input arguments: # 1) node number # 2) name of pmem device # function ndctl_nfit_test_get_namespace_of_device_node() { DEVICE=$2 NAMESPACE=$(expect_normal_exit run_on_node $1 ndctl list | grep -e "$DEVICE" -e namespace | grep -B1 -e "$DEVICE" | head -n1 | cut -d'"' -f4) # XXX needed by libndctl (it should be removed when it is not needed) ndctl_nfit_test_grant_access_node $1 $DEVICE echo $NAMESPACE } # # ndctl_inject_error -- inject error (bad blocks) to the namespace # # Input arguments: # 1) namespace # 2) the first bad block # 3) number of bad blocks # function ndctl_inject_error() { local NAMESPACE=$1 local BLOCK=$2 local COUNT=$3 echo "# sudo ndctl inject-error --block=$BLOCK --count=$COUNT $NAMESPACE" >> $PREP_LOG_FILE sudo ndctl inject-error --block=$BLOCK --count=$COUNT $NAMESPACE &>> $PREP_LOG_FILE echo "# sudo ndctl start-scrub" >> $PREP_LOG_FILE sudo ndctl start-scrub &>> $PREP_LOG_FILE echo "# sudo ndctl wait-scrub" >> $PREP_LOG_FILE sudo ndctl wait-scrub &>> $PREP_LOG_FILE echo "(done: ndctl wait-scrub)" >> $PREP_LOG_FILE } # # print_bad_blocks -- print all bad blocks (count, offset and length) # or "No bad blocks found" if there are no bad blocks # function print_bad_blocks { # XXX sudo should be removed when it is not needed sudo ndctl list -M | grep -e "badblock_count" -e "offset" -e "length" >> $LOG || echo "No bad blocks found" >> $LOG } # # expect_bad_blocks -- verify if there are required bad blocks # and fail if they are not there # function expect_bad_blocks { # XXX sudo should be removed when it is not needed sudo ndctl list -M | grep -e "badblock_count" -e "offset" -e "length" >> $LOG && true if [ $? -ne 0 ]; then # XXX sudo should be removed when it is not needed sudo ndctl list -M &>> $PREP_LOG_FILE && true msg "=====================================================================" msg "Error occurred, the preparation log ($PREP_LOG_FILE) is listed below:" msg "" cat $PREP_LOG_FILE msg "=====================================================================" msg "" fatal "Error: ndctl failed to inject or retain bad blocks" fi } # # expect_bad_blocks -- verify if there are required bad blocks # and fail if they are not there # function expect_bad_blocks_node { # XXX sudo should be removed when it is not needed expect_normal_exit run_on_node $1 sudo ndctl list -M | grep -e "badblock_count" -e "offset" -e "length" >> $LOG || fatal "Error: ndctl failed to inject or retain bad blocks" }
11,240
32.257396
174
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/libpmempool_rm_remote/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # libpmempool_rm_remote/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
1,771
41.190476
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_obc/rpmem_obc_test_common.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_obc_test_common.h -- common declarations for rpmem_obc test */ #include "unittest.h" #include "out.h" #include "librpmem.h" #include "rpmem.h" #include "rpmem_proto.h" #include "rpmem_common.h" #include "rpmem_util.h" #include "rpmem_obc.h" #define POOL_SIZE 1024 #define NLANES 32 #define NLANES_RESP 16 #define PROVIDER RPMEM_PROV_LIBFABRIC_SOCKETS #define POOL_DESC "pool_desc" #define RKEY 0xabababababababab #define RADDR 0x0101010101010101 #define PORT 1234 #define BUFF_SIZE 8192 #define POOL_ATTR_INIT {\ .signature = "<RPMEM>",\ .major = 1,\ .compat_features = 2,\ .incompat_features = 3,\ .ro_compat_features = 4,\ .poolset_uuid = "POOLSET_UUID0123",\ .uuid = "UUID0123456789AB",\ .next_uuid = "NEXT_UUID0123456",\ .prev_uuid = "PREV_UUID0123456",\ .user_flags = "USER_FLAGS012345",\ } #define POOL_ATTR_ALT {\ .signature = "<ALT>",\ .major = 5,\ .compat_features = 6,\ .incompat_features = 7,\ .ro_compat_features = 8,\ .poolset_uuid = "UUID_POOLSET_ALT",\ .uuid = "ALT_UUIDCDEFFEDC",\ .next_uuid = "456UUID_NEXT_ALT",\ .prev_uuid = "UUID012_ALT_PREV",\ .user_flags = "012345USER_FLAGS",\ } static const struct rpmem_pool_attr POOL_ATTR = POOL_ATTR_INIT; struct server { int fd_in; int fd_out; }; void set_rpmem_cmd(const char *fmt, ...); struct server *srv_init(void); void srv_fini(struct server *s); void srv_recv(struct server *s, void *buff, size_t len); void srv_send(struct server *s, const void *buff, size_t len); void srv_wait_disconnect(struct server *s); void client_connect_wait(struct rpmem_obc *rpc, char *target); /* * Since the server may disconnect the connection at any moment * from the client's perspective, execute the test in a loop so * the moment when the connection is closed will be possibly different. */ #define ECONNRESET_LOOP 10 void server_econnreset(struct server *s, const void *msg, size_t len); TEST_CASE_DECLARE(client_enotconn); TEST_CASE_DECLARE(client_connect); TEST_CASE_DECLARE(client_monitor); TEST_CASE_DECLARE(server_monitor); TEST_CASE_DECLARE(server_wait); TEST_CASE_DECLARE(client_create); TEST_CASE_DECLARE(server_create); TEST_CASE_DECLARE(server_create_econnreset); TEST_CASE_DECLARE(server_create_eproto); TEST_CASE_DECLARE(server_create_error); TEST_CASE_DECLARE(client_open); TEST_CASE_DECLARE(server_open); TEST_CASE_DECLARE(server_open_econnreset); TEST_CASE_DECLARE(server_open_eproto); TEST_CASE_DECLARE(server_open_error); TEST_CASE_DECLARE(client_close); TEST_CASE_DECLARE(server_close); TEST_CASE_DECLARE(server_close_econnreset); TEST_CASE_DECLARE(server_close_eproto); TEST_CASE_DECLARE(server_close_error); TEST_CASE_DECLARE(client_set_attr); TEST_CASE_DECLARE(server_set_attr); TEST_CASE_DECLARE(server_set_attr_econnreset); TEST_CASE_DECLARE(server_set_attr_eproto); TEST_CASE_DECLARE(server_set_attr_error);
4,466
31.369565
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_obc/setup.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/rpmem_obc/setup.sh -- common setup for rpmem_obc tests # set -e require_nodes 2 require_node_log_files 1 $RPMEM_LOG_FILE RPMEM_CMD="\"cd ${NODE_TEST_DIR[0]} && UNITTEST_FORCE_QUIET=1 \ LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[0]} \ ./rpmem_obc$EXESUFFIX\"" export_vars_node 1 RPMEM_CMD
1,934
40.170213
87
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_sync_remote/config.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_sync_remote/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
1,775
41.285714
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_sync_remote/common.sh
#!/usr/bin/env bash # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_sync_remote/common.sh -- pmempool sync with remote replication # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER setup init_rpmem_on_node 1 0 require_node_log_files 1 pmemobj$UNITTEST_NUM.log require_node_log_files 1 pmempool$UNITTEST_NUM.log PMEMOBJCLI_SCRIPT="pmemobjcli.script" copy_files_to_node 1 ${NODE_TEST_DIR[1]} $PMEMOBJCLI_SCRIPT POOLSET_LOCAL="local_pool.set" # # configure_poolsets -- configure pool set files for test # usage: configure_poolsets <local replicas> <remote replicas> # function configure_poolsets() { local n_local=$1 local n_remote=$2 local poolset_args="8M:${NODE_DIR[1]}/pool.part.1:x 8M:${NODE_DIR[1]}/pool.part.2:x" for i in $(seq 0 $((n_local - 1))); do poolset_args="$poolset_args R 8M:${NODE_DIR[1]}/pool.$i.part.1:x 8M:${NODE_DIR[1]}/pool.$i.part.2:x" done for i in $(seq 0 $((n_remote - 1))); do POOLSET_REMOTE[$i]="remote_pool.$i.set" create_poolset $DIR/${POOLSET_REMOTE[$i]}\ 8M:${NODE_DIR[0]}remote.$i.part.1:x\ 8M:${NODE_DIR[0]}remote.$i.part.2:x copy_files_to_node 0 ${NODE_DIR[0]} $DIR/${POOLSET_REMOTE[$i]} poolset_args="$poolset_args m ${NODE_ADDR[0]}:${POOLSET_REMOTE[$i]}" done create_poolset $DIR/$POOLSET_LOCAL $poolset_args copy_files_to_node 1 ${NODE_DIR[1]} $DIR/$POOLSET_LOCAL expect_normal_exit run_on_node 1 ../pmempool rm -sf ${NODE_DIR[1]}$POOLSET_LOCAL expect_normal_exit run_on_node 1 ../pmempool create obj ${NODE_DIR[1]}$POOLSET_LOCAL expect_normal_exit run_on_node 1 ../pmemobjcli -s $PMEMOBJCLI_SCRIPT ${NODE_DIR[1]}$POOLSET_LOCAL > /dev/null } DUMP_INFO_LOG="../pmempool info -lHZCOoAa" DUMP_INFO_LOG_REMOTE="$DUMP_INFO_LOG -f obj" DUMP_INFO_SED="sed -e '/^Checksum/d' -e '/^Creation/d'" DUMP_INFO_SED_REMOTE="$DUMP_INFO_SED -e '/^Previous part UUID/d' -e '/^Next part UUID/d'" function dump_info_log() { local node=$1 local rep=$2 local poolset=$3 local name=$4 local ignore=$5 local sed_cmd="$DUMP_INFO_SED" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG -p $rep $poolset | $sed_cmd > $name\"" } function dump_info_log_remote() { local node=$1 local poolset=$2 local name=$3 local ignore=$4 local sed_cmd="$DUMP_INFO_SED_REMOTE" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG_REMOTE $poolset | $sed_cmd > $name\"" } function diff_log() { local node=$1 local f1=$2 local f2=$3 expect_normal_exit run_on_node $node "\"[ -s $f1 ] && [ -s $f2 ] && diff $f1 $f2\"" } exec_pmemobjcli_script() { local node=$1 local script=$2 local poolset=$3 local out=$4 expect_normal_exit run_on_node $node "\"../pmemobjcli -s $script $poolset > $out \"" }
4,397
30.414286
110
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_fip/config.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/rpmem_fip/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=none CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
1,774
41.261905
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_fip/rpmem_fip_oob.h
/* * Copyright 2016, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_fip_sock.h -- simple oob connection implementation for exchanging * required RDMA related data */ #include <stdint.h> #include <netinet/in.h> typedef struct rpmem_ssh client_t; client_t *client_exchange(struct rpmem_target_info *info, unsigned nlanes, enum rpmem_provider provider, struct rpmem_resp_attr *resp); void client_close_begin(client_t *c); void client_close_end(client_t *c); void server_exchange_begin(unsigned *lanes, enum rpmem_provider *provider, char **addr); void server_exchange_end(struct rpmem_resp_attr resp); void server_close_begin(void); void server_close_end(void); void set_rpmem_cmd(const char *fmt, ...);
2,258
37.948276
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_fip/setup.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/rpmem_fip/setup.sh -- common setup for rpmem_fip tests # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER require_node_log_files 0 $RPMEM_LOG_FILE $RPMEMD_LOG_FILE require_node_log_files 1 $RPMEM_LOG_FILE $RPMEMD_LOG_FILE SRV=srv${UNITTEST_NUM}.pid clean_remote_node 0 $SRV RPMEM_CMD="\"cd ${NODE_TEST_DIR[0]} && RPMEMD_LOG_LEVEL=\$RPMEMD_LOG_LEVEL RPMEMD_LOG_FILE=\$RPMEMD_LOG_FILE UNITTEST_FORCE_QUIET=1 \ LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[0]} \ ./rpmem_fip$EXESUFFIX\"" export_vars_node 1 RPMEM_CMD if [ -n ${RPMEM_MAX_NLANES+x} ]; then export_vars_node 1 RPMEM_MAX_NLANES fi
2,292
39.946429
133
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/tools/ctrld/signals_linux.h
/* * Copyright 2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * signals_linux.h - Signal definitions for Linux */ #ifndef _SIGNALS_LINUX_H #define _SIGNALS_LINUX_H 1 #define SIGNAL_2_STR(sig) [sig] = #sig static const char *signal2str[] = { SIGNAL_2_STR(SIGHUP), /* 1 */ SIGNAL_2_STR(SIGINT), /* 2 */ SIGNAL_2_STR(SIGQUIT), /* 3 */ SIGNAL_2_STR(SIGILL), /* 4 */ SIGNAL_2_STR(SIGTRAP), /* 5 */ SIGNAL_2_STR(SIGABRT), /* 6 */ SIGNAL_2_STR(SIGBUS), /* 7 */ SIGNAL_2_STR(SIGFPE), /* 8 */ SIGNAL_2_STR(SIGKILL), /* 9 */ SIGNAL_2_STR(SIGUSR1), /* 10 */ SIGNAL_2_STR(SIGSEGV), /* 11 */ SIGNAL_2_STR(SIGUSR2), /* 12 */ SIGNAL_2_STR(SIGPIPE), /* 13 */ SIGNAL_2_STR(SIGALRM), /* 14 */ SIGNAL_2_STR(SIGTERM), /* 15 */ SIGNAL_2_STR(SIGSTKFLT), /* 16 */ SIGNAL_2_STR(SIGCHLD), /* 17 */ SIGNAL_2_STR(SIGCONT), /* 18 */ SIGNAL_2_STR(SIGSTOP), /* 19 */ SIGNAL_2_STR(SIGTSTP), /* 20 */ SIGNAL_2_STR(SIGTTIN), /* 21 */ SIGNAL_2_STR(SIGTTOU), /* 22 */ SIGNAL_2_STR(SIGURG), /* 23 */ SIGNAL_2_STR(SIGXCPU), /* 24 */ SIGNAL_2_STR(SIGXFSZ), /* 25 */ SIGNAL_2_STR(SIGVTALRM), /* 26 */ SIGNAL_2_STR(SIGPROF), /* 27 */ SIGNAL_2_STR(SIGWINCH), /* 28 */ SIGNAL_2_STR(SIGPOLL), /* 29 */ SIGNAL_2_STR(SIGPWR), /* 30 */ SIGNAL_2_STR(SIGSYS) /* 31 */ }; #define SIGNALMAX SIGSYS #endif
2,837
36.342105
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/tools/ctrld/signals_freebsd.h
/* * Copyright 2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * signals_fbsd.h - Signal definitions for FreeBSD */ #ifndef _SIGNALS_FBSD_H #define _SIGNALS_FBSD_H 1 #define SIGNAL_2_STR(sig) [sig] = #sig static const char *signal2str[] = { SIGNAL_2_STR(SIGHUP), /* 1 */ SIGNAL_2_STR(SIGINT), /* 2 */ SIGNAL_2_STR(SIGQUIT), /* 3 */ SIGNAL_2_STR(SIGILL), /* 4 */ SIGNAL_2_STR(SIGTRAP), /* 5 */ SIGNAL_2_STR(SIGABRT), /* 6 */ SIGNAL_2_STR(SIGEMT), /* 7 */ SIGNAL_2_STR(SIGFPE), /* 8 */ SIGNAL_2_STR(SIGKILL), /* 9 */ SIGNAL_2_STR(SIGBUS), /* 10 */ SIGNAL_2_STR(SIGSEGV), /* 11 */ SIGNAL_2_STR(SIGSYS), /* 12 */ SIGNAL_2_STR(SIGPIPE), /* 13 */ SIGNAL_2_STR(SIGALRM), /* 14 */ SIGNAL_2_STR(SIGTERM), /* 15 */ SIGNAL_2_STR(SIGURG), /* 16 */ SIGNAL_2_STR(SIGSTOP), /* 17 */ SIGNAL_2_STR(SIGTSTP), /* 18 */ SIGNAL_2_STR(SIGCONT), /* 19 */ SIGNAL_2_STR(SIGCHLD), /* 20 */ SIGNAL_2_STR(SIGTTIN), /* 21 */ SIGNAL_2_STR(SIGTTOU), /* 22 */ SIGNAL_2_STR(SIGIO), /* 23 */ SIGNAL_2_STR(SIGXCPU), /* 24 */ SIGNAL_2_STR(SIGXFSZ), /* 25 */ SIGNAL_2_STR(SIGVTALRM), /* 26 */ SIGNAL_2_STR(SIGPROF), /* 27 */ SIGNAL_2_STR(SIGWINCH), /* 28 */ SIGNAL_2_STR(SIGINFO), /* 29 */ SIGNAL_2_STR(SIGUSR1), /* 30 */ SIGNAL_2_STR(SIGUSR2), /* 31 */ SIGNAL_2_STR(SIGTHR), /* 32 */ SIGNAL_2_STR(SIGLIBRT) /* 33 */ }; #define SIGNALMAX SIGLIBRT #endif
2,901
35.734177
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/libpmempool_feature/common.sh
#!/usr/bin/env bash # # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/libpmempool_feature/common.sh -- common part of libpmempool_feature tests # OUT=out${UNITTEST_NUM}.log LOG=grep${UNITTEST_NUM}.log QUERY_PATTERN="query" ERROR_PATTERN="<1> \\[feature.c:.*\\]" exit_func=expect_normal_exit # libpmempool_feature_query -- query feature # # usage: libpmempool_feature_query <enum-pmempool_feature> function libpmempool_feature_query() { # query feature expect_normal_exit ./libpmempool_feature$EXESUFFIX $DIR/pool.obj q $1 cat $OUT | grep "$QUERY_PATTERN" >> $LOG # verify query with pmempool info set +e count=$(expect_normal_exit $PMEMPOOL$EXESUFFIX info $DIR/pool.obj | grep -c "$1") set -e if [ "$count" = "0" ]; then echo "pmempool info: $1 is NOT set" >> $LOG else echo "pmempool info: $1 is set" >> $LOG fi # check if pool is still valid expect_normal_exit $PMEMPOOL$EXESUFFIX check $DIR/pool.obj >> /dev/null } # libpmempool_feature_enable -- enable feature # # usage: libpmempool_feature_enable <enum-pmempool_feature> [no-query] function libpmempool_feature_enable() { $exit_func ./libpmempool_feature$EXESUFFIX $DIR/pool.obj e $1 &>> $LOG if [ "$exit_func" == "expect_abnormal_exit" ]; then if [ -f "$PMEMPOOL_LOG_FILE" ]; then cat $PMEMPOOL_LOG_FILE | grep "$ERROR_PATTERN" >> $LOG fi fi if [ "x$2" != "xno-query" ]; then libpmempool_feature_query $1 fi } # libpmempool_feature_disable -- disable feature # # usage: libpmempool_feature_disable <enum-pmempool_feature> [no-query] function libpmempool_feature_disable() { $exit_func ./libpmempool_feature$EXESUFFIX $DIR/pool.obj d $1 &>> $LOG if [ "$exit_func" == "expect_abnormal_exit" ]; then if [ -f "$PMEMPOOL_LOG_FILE" ]; then cat $PMEMPOOL_LOG_FILE | grep "$ERROR_PATTERN" >> $LOG fi fi if [ "x$2" != "xno-query" ]; then libpmempool_feature_query $1 fi }
3,400
34.061856
84
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/sync-remotes/copy-to-remote-nodes.sh
#!/usr/bin/env bash # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # copy-to-remote-nodes.sh -- helper script used to sync remote nodes # set -e if [ ! -f ../testconfig.sh ]; then echo "SKIP: testconfig.sh does not exist" exit 0 fi # defined only to be able to source unittest.sh UNITTEST_NAME=sync-remotes UNITTEST_NUM=0 # Override default FS (any). # This is not a real test, so it should not depend on whether # PMEM_FS_DIR/NON_PMEM_FS_DIR are set. FS=none . ../unittest/unittest.sh COPY_TYPE=$1 shift case "$COPY_TYPE" in common) copy_common_to_remote_nodes $* > /dev/null exit 0 ;; test) copy_test_to_remote_nodes $* > /dev/null exit 0 ;; esac echo "Error: unknown copy type: $COPY_TYPE" exit 1
2,276
31.070423
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_check/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_check/config.sh -- test configuration # # Extend timeout for TEST5, as it may take a few minutes # when run on a non-pmem file system. CONF_TIMEOUT[5]='10m'
1,757
40.857143
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_check/common.sh
#!/usr/bin/env bash # # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_check/common.sh -- checking pools helpers # LOG=out${UNITTEST_NUM}.log rm -f $LOG && touch $LOG LAYOUT=OBJ_LAYOUT$SUFFIX POOLSET=$DIR/poolset # pmemspoil_corrupt_replica_sds -- corrupt shutdown state # # usage: pmemspoil_corrupt_replica_sds <replica> function pmemspoil_corrupt_replica_sds() { local replica=$1 expect_normal_exit $PMEMSPOIL --replica $replica $POOLSET \ pool_hdr.shutdown_state.usc=999 \ pool_hdr.shutdown_state.dirty=1 \ "pool_hdr.shutdown_state.checksum_gen\(\)" } # pmempool_check_sds_init -- shutdown state unittest init # # usage: pmempool_check_sds [enable-sds] function pmempool_check_sds_init() { # initialize poolset create_poolset $POOLSET \ 8M:$DIR/part00:x \ r 8M:$DIR/part10:x expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=$LAYOUT obj $POOLSET # enable SHUTDOWN_STATE feature if [ "x$1" == "xenable-sds" ]; then expect_normal_exit $PMEMPOOL$EXESUFFIX feature \ --enable "SHUTDOWN_STATE" $POOLSET fi } # pmempool_check_sds -- perform shutdown state unittest # # usage: pmempool_check_sds <scenario> function pmempool_check_sds() { # corrupt poolset replicas pmemspoil_corrupt_replica_sds 0 pmemspoil_corrupt_replica_sds 1 # verify it is corrupted expect_abnormal_exit $PMEMPOOL$EXESUFFIX check $POOLSET >> $LOG exit_func=expect_normal_exit # perform fixes case "$1" in fix_second_replica_only) echo -e "n\ny\n" | expect_normal_exit $PMEMPOOL$EXESUFFIX check -vr $POOLSET >> $LOG ;; fix_first_replica) echo -e "y\n" | expect_normal_exit $PMEMPOOL$EXESUFFIX check -vr $POOLSET >> $LOG ;; fix_no_replicas) echo -e "n\nn\n" | expect_abnormal_exit $PMEMPOOL$EXESUFFIX check -vr $POOLSET >> $LOG exit_func=expect_abnormal_exit ;; *) fatal "unittest_sds: undefined scenario '$1'" ;; esac #verify result $exit_func $PMEMPOOL$EXESUFFIX check $POOLSET >> $LOG }
3,452
32.524272
88
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/unittest/unittest.h
/* * Copyright 2014-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * unittest.h -- the mundane stuff shared by all unit tests * * we want unit tests to be very thorough and check absolutely everything * in order to nail down the test case as precisely as possible and flag * anything at all unexpected. as a result, most unit tests are 90% code * checking stuff that isn't really interesting to what is being tested. * to help address this, the macros defined here include all the boilerplate * error checking which prints information and exits on unexpected errors. * * the result changes this code: * * if ((buf = malloc(size)) == NULL) { * fprintf(stderr, "cannot allocate %d bytes for buf\n", size); * exit(1); * } * * into this code: * * buf = MALLOC(size); * * and the error message includes the calling context information (file:line). * in general, using the all-caps version of a call means you're using the * unittest.h version which does the most common checking for you. so * calling VMEM_CREATE() instead of vmem_create() returns the same * thing, but can never return an error since the unit test library checks for * it. * for routines like vmem_delete() there is no corresponding * VMEM_DELETE() because there's no error to check for. * * all unit tests should use the same initialization: * * START(argc, argv, "brief test description", ...); * * all unit tests should use these exit calls: * * DONE("message", ...); * UT_FATAL("message", ...); * * uniform stderr and stdout messages: * * UT_OUT("message", ...); * UT_ERR("message", ...); * * in all cases above, the message is printf-like, taking variable args. * the message can be NULL. it can start with "!" in which case the "!" is * skipped and the message gets the errno string appended to it, like this: * * if (somesyscall(..) < 0) * UT_FATAL("!my message"); */ #ifndef _UNITTEST_H #define _UNITTEST_H 1 #include <libpmem.h> #include <libpmemblk.h> #include <libpmemlog.h> #include <libpmemobj.h> #include <libpmemcto.h> #include <libpmempool.h> #include <libvmem.h> #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <stdarg.h> #include <stdint.h> #include <string.h> #include <strings.h> #include <setjmp.h> #include <time.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/file.h> #ifndef __FreeBSD__ #include <sys/mount.h> #endif #include <fcntl.h> #include <signal.h> #include <errno.h> #include <dirent.h> /* XXX: move OS abstraction layer out of common */ #include "os.h" #include "os_thread.h" #include "util.h" int ut_get_uuid_str(char *); #define UT_MAX_ERR_MSG 128 #define UT_POOL_HDR_UUID_STR_LEN 37 /* uuid string length */ #define UT_POOL_HDR_UUID_GEN_FILE "/proc/sys/kernel/random/uuid" /* XXX - fix this temp hack dup'ing util_strerror when we get mock for win */ void ut_strerror(int errnum, char *buff, size_t bufflen); /* XXX - eliminate duplicated definitions in unittest.h and util.h */ #ifdef _WIN32 static inline int ut_util_statW(const wchar_t *path, os_stat_t *st_bufp) { int retVal = _wstat64(path, st_bufp); /* clear unused bits to avoid confusion */ st_bufp->st_mode &= 0600; return retVal; } #endif /* * unit test support... */ void ut_start(const char *file, int line, const char *func, int argc, char * const argv[], const char *fmt, ...) __attribute__((format(printf, 6, 7))); void ut_startW(const char *file, int line, const char *func, int argc, wchar_t * const argv[], const char *fmt, ...) __attribute__((format(printf, 6, 7))); void NORETURN ut_done(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); void NORETURN ut_fatal(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); void NORETURN ut_end(const char *file, int line, const char *func, int ret); void ut_out(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); void ut_err(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf, 4, 5))); /* indicate the start of the test */ #ifndef _WIN32 #define START(argc, argv, ...)\ ut_start(__FILE__, __LINE__, __func__, argc, argv, __VA_ARGS__) #else #define START(argc, argv, ...)\ wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &argc);\ for (int i = 0; i < argc; i++) {\ argv[i] = ut_toUTF8(wargv[i]);\ if (argv[i] == NULL) {\ for (i--; i >= 0; i--)\ free(argv[i]);\ UT_FATAL("Error during arguments conversion\n");\ }\ }\ ut_start(__FILE__, __LINE__, __func__, argc, argv, __VA_ARGS__) #endif /* indicate the start of the test */ #define STARTW(argc, argv, ...)\ ut_startW(__FILE__, __LINE__, __func__, argc, argv, __VA_ARGS__) /* normal exit from test */ #ifndef _WIN32 #define DONE(...)\ ut_done(__FILE__, __LINE__, __func__, __VA_ARGS__) #else #define DONE(...)\ for (int i = argc; i > 0; i--)\ free(argv[i - 1]);\ ut_done(__FILE__, __LINE__, __func__, __VA_ARGS__) #endif #define DONEW(...)\ ut_done(__FILE__, __LINE__, __func__, __VA_ARGS__) #define END(ret, ...)\ ut_end(__FILE__, __LINE__, __func__, ret) /* fatal error detected */ #define UT_FATAL(...)\ ut_fatal(__FILE__, __LINE__, __func__, __VA_ARGS__) /* normal output */ #define UT_OUT(...)\ ut_out(__FILE__, __LINE__, __func__, __VA_ARGS__) /* error output */ #define UT_ERR(...)\ ut_err(__FILE__, __LINE__, __func__, __VA_ARGS__) /* * assertions... */ /* assert a condition is true at runtime */ #define UT_ASSERT_rt(cnd)\ ((void)((cnd) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s", #cnd), 0))) /* assertion with extra info printed if assertion fails at runtime */ #define UT_ASSERTinfo_rt(cnd, info) \ ((void)((cnd) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s (%s = %s)", #cnd, #info, info), 0))) /* assert two integer values are equal at runtime */ #define UT_ASSERTeq_rt(lhs, rhs)\ ((void)(((lhs) == (rhs)) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s (0x%llx) == %s (0x%llx)", #lhs,\ (unsigned long long)(lhs), #rhs, (unsigned long long)(rhs)), 0))) /* assert two integer values are not equal at runtime */ #define UT_ASSERTne_rt(lhs, rhs)\ ((void)(((lhs) != (rhs)) || (ut_fatal(__FILE__, __LINE__, __func__,\ "assertion failure: %s (0x%llx) != %s (0x%llx)", #lhs,\ (unsigned long long)(lhs), #rhs, (unsigned long long)(rhs)), 0))) #if defined(__CHECKER__) #define UT_COMPILE_ERROR_ON(cond) #define UT_ASSERT_COMPILE_ERROR_ON(cond) #elif defined(_MSC_VER) #define UT_COMPILE_ERROR_ON(cond) C_ASSERT(!(cond)) /* XXX - can't be done with C_ASSERT() unless we have __builtin_constant_p() */ #define UT_ASSERT_COMPILE_ERROR_ON(cond) (void)(cond) #else #define UT_COMPILE_ERROR_ON(cond) ((void)sizeof(char[(cond) ? -1 : 1])) #ifndef __cplusplus #define UT_ASSERT_COMPILE_ERROR_ON(cond) UT_COMPILE_ERROR_ON(cond) #else /* __cplusplus */ /* * XXX - workaround for http://github.com/pmem/issues/issues/189 */ #define UT_ASSERT_COMPILE_ERROR_ON(cond) UT_ASSERT_rt(!(cond)) #endif /* __cplusplus */ #endif /* _MSC_VER */ /* assert a condition is true */ #define UT_ASSERT(cnd)\ do {\ /*\ * Detect useless asserts on always true expression. Please use\ * UT_COMPILE_ERROR_ON(!cnd) or UT_ASSERT_rt(cnd) in such\ * cases.\ */\ if (__builtin_constant_p(cnd))\ UT_ASSERT_COMPILE_ERROR_ON(cnd);\ UT_ASSERT_rt(cnd);\ } while (0) /* assertion with extra info printed if assertion fails */ #define UT_ASSERTinfo(cnd, info) \ do {\ /* See comment in UT_ASSERT. */\ if (__builtin_constant_p(cnd))\ UT_ASSERT_COMPILE_ERROR_ON(cnd);\ UT_ASSERTinfo_rt(cnd, info);\ } while (0) /* assert two integer values are equal */ #define UT_ASSERTeq(lhs, rhs)\ do {\ /* See comment in UT_ASSERT. */\ if (__builtin_constant_p(lhs) && __builtin_constant_p(rhs))\ UT_ASSERT_COMPILE_ERROR_ON((lhs) == (rhs));\ UT_ASSERTeq_rt(lhs, rhs);\ } while (0) /* assert two integer values are not equal */ #define UT_ASSERTne(lhs, rhs)\ do {\ /* See comment in UT_ASSERT. */\ if (__builtin_constant_p(lhs) && __builtin_constant_p(rhs))\ UT_ASSERT_COMPILE_ERROR_ON((lhs) != (rhs));\ UT_ASSERTne_rt(lhs, rhs);\ } while (0) /* assert pointer is fits range of [start, start + size) */ #define UT_ASSERTrange(ptr, start, size)\ ((void)(((uintptr_t)(ptr) >= (uintptr_t)(start) &&\ (uintptr_t)(ptr) < (uintptr_t)(start) + (uintptr_t)(size)) ||\ (ut_fatal(__FILE__, __LINE__, __func__,\ "assert failure: %s (%p) is outside range [%s (%p), %s (%p))", #ptr,\ (void *)(ptr), #start, (void *)(start), #start"+"#size,\ (void *)((uintptr_t)(start) + (uintptr_t)(size))), 0))) /* * memory allocation... */ void *ut_malloc(const char *file, int line, const char *func, size_t size); void *ut_calloc(const char *file, int line, const char *func, size_t nmemb, size_t size); void ut_free(const char *file, int line, const char *func, void *ptr); void ut_aligned_free(const char *file, int line, const char *func, void *ptr); void *ut_realloc(const char *file, int line, const char *func, void *ptr, size_t size); char *ut_strdup(const char *file, int line, const char *func, const char *str); void *ut_pagealignmalloc(const char *file, int line, const char *func, size_t size); void *ut_memalign(const char *file, int line, const char *func, size_t alignment, size_t size); void *ut_mmap_anon_aligned(const char *file, int line, const char *func, size_t alignment, size_t size); int ut_munmap_anon_aligned(const char *file, int line, const char *func, void *start, size_t size); /* a malloc() that can't return NULL */ #define MALLOC(size)\ ut_malloc(__FILE__, __LINE__, __func__, size) /* a calloc() that can't return NULL */ #define CALLOC(nmemb, size)\ ut_calloc(__FILE__, __LINE__, __func__, nmemb, size) /* a malloc() of zeroed memory */ #define ZALLOC(size)\ ut_calloc(__FILE__, __LINE__, __func__, 1, size) #define FREE(ptr)\ ut_free(__FILE__, __LINE__, __func__, ptr) #define ALIGNED_FREE(ptr)\ ut_aligned_free(__FILE__, __LINE__, __func__, ptr) /* a realloc() that can't return NULL */ #define REALLOC(ptr, size)\ ut_realloc(__FILE__, __LINE__, __func__, ptr, size) /* a strdup() that can't return NULL */ #define STRDUP(str)\ ut_strdup(__FILE__, __LINE__, __func__, str) /* a malloc() that only returns page aligned memory */ #define PAGEALIGNMALLOC(size)\ ut_pagealignmalloc(__FILE__, __LINE__, __func__, size) /* a malloc() that returns memory with given alignment */ #define MEMALIGN(alignment, size)\ ut_memalign(__FILE__, __LINE__, __func__, alignment, size) /* * A mmap() that returns anonymous memory with given alignment and guard * pages. */ #define MMAP_ANON_ALIGNED(size, alignment)\ ut_mmap_anon_aligned(__FILE__, __LINE__, __func__, alignment, size) #define MUNMAP_ANON_ALIGNED(start, size)\ ut_munmap_anon_aligned(__FILE__, __LINE__, __func__, start, size) /* * file operations */ int ut_open(const char *file, int line, const char *func, const char *path, int flags, ...); int ut_wopen(const char *file, int line, const char *func, const wchar_t *path, int flags, ...); int ut_close(const char *file, int line, const char *func, int fd); FILE *ut_fopen(const char *file, int line, const char *func, const char *path, const char *mode); int ut_fclose(const char *file, int line, const char *func, FILE *stream); int ut_unlink(const char *file, int line, const char *func, const char *path); size_t ut_write(const char *file, int line, const char *func, int fd, const void *buf, size_t len); size_t ut_read(const char *file, int line, const char *func, int fd, void *buf, size_t len); os_off_t ut_lseek(const char *file, int line, const char *func, int fd, os_off_t offset, int whence); int ut_posix_fallocate(const char *file, int line, const char *func, int fd, os_off_t offset, os_off_t len); int ut_stat(const char *file, int line, const char *func, const char *path, os_stat_t *st_bufp); int ut_statW(const char *file, int line, const char *func, const wchar_t *path, os_stat_t *st_bufp); int ut_fstat(const char *file, int line, const char *func, int fd, os_stat_t *st_bufp); void *ut_mmap(const char *file, int line, const char *func, void *addr, size_t length, int prot, int flags, int fd, os_off_t offset); int ut_munmap(const char *file, int line, const char *func, void *addr, size_t length); int ut_mprotect(const char *file, int line, const char *func, void *addr, size_t len, int prot); int ut_ftruncate(const char *file, int line, const char *func, int fd, os_off_t length); long long ut_strtoll(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); long ut_strtol(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); int ut_strtoi(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); unsigned long long ut_strtoull(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); unsigned long ut_strtoul(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); unsigned ut_strtou(const char *file, int line, const char *func, const char *nptr, char **endptr, int base); /* an open() that can't return < 0 */ #define OPEN(path, ...)\ ut_open(__FILE__, __LINE__, __func__, path, __VA_ARGS__) /* a _wopen() that can't return < 0 */ #define WOPEN(path, ...)\ ut_wopen(__FILE__, __LINE__, __func__, path, __VA_ARGS__) /* a close() that can't return -1 */ #define CLOSE(fd)\ ut_close(__FILE__, __LINE__, __func__, fd) /* an fopen() that can't return != 0 */ #define FOPEN(path, mode)\ ut_fopen(__FILE__, __LINE__, __func__, path, mode) /* a fclose() that can't return != 0 */ #define FCLOSE(stream)\ ut_fclose(__FILE__, __LINE__, __func__, stream) /* an unlink() that can't return -1 */ #define UNLINK(path)\ ut_unlink(__FILE__, __LINE__, __func__, path) /* a write() that can't return -1 */ #define WRITE(fd, buf, len)\ ut_write(__FILE__, __LINE__, __func__, fd, buf, len) /* a read() that can't return -1 */ #define READ(fd, buf, len)\ ut_read(__FILE__, __LINE__, __func__, fd, buf, len) /* a lseek() that can't return -1 */ #define LSEEK(fd, offset, whence)\ ut_lseek(__FILE__, __LINE__, __func__, fd, offset, whence) #define POSIX_FALLOCATE(fd, off, len)\ ut_posix_fallocate(__FILE__, __LINE__, __func__, fd, off, len) #define FSTAT(fd, st_bufp)\ ut_fstat(__FILE__, __LINE__, __func__, fd, st_bufp) /* a mmap() that can't return MAP_FAILED */ #define MMAP(addr, len, prot, flags, fd, offset)\ ut_mmap(__FILE__, __LINE__, __func__, addr, len, prot, flags, fd, offset); /* a munmap() that can't return -1 */ #define MUNMAP(addr, length)\ ut_munmap(__FILE__, __LINE__, __func__, addr, length); /* a mprotect() that can't return -1 */ #define MPROTECT(addr, len, prot)\ ut_mprotect(__FILE__, __LINE__, __func__, addr, len, prot); #define STAT(path, st_bufp)\ ut_stat(__FILE__, __LINE__, __func__, path, st_bufp) #define STATW(path, st_bufp)\ ut_statW(__FILE__, __LINE__, __func__, path, st_bufp) #define FTRUNCATE(fd, length)\ ut_ftruncate(__FILE__, __LINE__, __func__, fd, length) #define ATOU(nptr) STRTOU(nptr, NULL, 10) #define ATOUL(nptr) STRTOUL(nptr, NULL, 10) #define ATOULL(nptr) STRTOULL(nptr, NULL, 10) #define ATOI(nptr) STRTOI(nptr, NULL, 10) #define ATOL(nptr) STRTOL(nptr, NULL, 10) #define ATOLL(nptr) STRTOLL(nptr, NULL, 10) #define STRTOULL(nptr, endptr, base)\ ut_strtoull(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOUL(nptr, endptr, base)\ ut_strtoul(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOL(nptr, endptr, base)\ ut_strtol(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOLL(nptr, endptr, base)\ ut_strtoll(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOU(nptr, endptr, base)\ ut_strtou(__FILE__, __LINE__, __func__, nptr, endptr, base) #define STRTOI(nptr, endptr, base)\ ut_strtoi(__FILE__, __LINE__, __func__, nptr, endptr, base) #ifndef _WIN32 #define ut_jmp_buf_t sigjmp_buf #define ut_siglongjmp(b) siglongjmp(b, 1) #define ut_sigsetjmp(b) sigsetjmp(b, 1) #else #define ut_jmp_buf_t jmp_buf #define ut_siglongjmp(b) longjmp(b, 1) #define ut_sigsetjmp(b) setjmp(b) static DWORD ErrMode; static BOOL Suppressed = FALSE; static UINT AbortBehave; #endif void ut_suppress_errmsg(void); void ut_unsuppress_errmsg(void); /* * signals... */ int ut_sigaction(const char *file, int line, const char *func, int signum, struct sigaction *act, struct sigaction *oldact); /* a sigaction() that can't return an error */ #define SIGACTION(signum, act, oldact)\ ut_sigaction(__FILE__, __LINE__, __func__, signum, act, oldact) /* * pthreads... */ int ut_thread_create(const char *file, int line, const char *func, os_thread_t *__restrict thread, const os_thread_attr_t *__restrict attr, void *(*start_routine)(void *), void *__restrict arg); int ut_thread_join(const char *file, int line, const char *func, os_thread_t *thread, void **value_ptr); /* a os_thread_create() that can't return an error */ #define PTHREAD_CREATE(thread, attr, start_routine, arg)\ ut_thread_create(__FILE__, __LINE__, __func__,\ thread, attr, start_routine, arg) /* a os_thread_join() that can't return an error */ #define PTHREAD_JOIN(thread, value_ptr)\ ut_thread_join(__FILE__, __LINE__, __func__, thread, value_ptr) /* * processes... */ #ifdef _WIN32 intptr_t ut_spawnv(int argc, const char **argv, ...); #endif /* * mocks... * * NOTE: On Linux, function mocking is implemented using wrapper functions. * See "--wrap" option of the GNU linker. * There is no such feature in VC++, so on Windows we do the mocking at * compile time, by redefining symbol names: * - all the references to <symbol> are replaced with <__wrap_symbol> * in all the compilation units, except the one where the <symbol> is * defined and the test source file * - the original definition of <symbol> is replaced with <__real_symbol> * - a wrapper function <__wrap_symbol> must be defined in the test program * (it may still call the original function via <__real_symbol>) * Such solution seems to be sufficient for the purpose of our tests, even * though it has some limitations. I.e. it does no work well with malloc/free, * so to wrap the system memory allocator functions, we use the built-in * feature of all the PMDK libraries, allowing to override default memory * allocator with the custom one. */ #ifndef _WIN32 #define _FUNC_REAL_DECL(name, ret_type, ...)\ ret_type __real_##name(__VA_ARGS__) __attribute__((unused)); #else #define _FUNC_REAL_DECL(name, ret_type, ...)\ ret_type name(__VA_ARGS__); #endif #ifndef _WIN32 #define _FUNC_REAL(name)\ __real_##name #else #define _FUNC_REAL(name)\ name #endif #define RCOUNTER(name)\ _rcounter##name #define FUNC_MOCK_RCOUNTER_SET(name, val)\ RCOUNTER(name) = val; #define FUNC_MOCK(name, ret_type, ...)\ _FUNC_REAL_DECL(name, ret_type, ##__VA_ARGS__)\ static unsigned RCOUNTER(name);\ ret_type __wrap_##name(__VA_ARGS__);\ ret_type __wrap_##name(__VA_ARGS__) {\ switch (util_fetch_and_add32(&RCOUNTER(name), 1)) { #define FUNC_MOCK_DLLIMPORT(name, ret_type, ...)\ __declspec(dllimport) _FUNC_REAL_DECL(name, ret_type, ##__VA_ARGS__)\ static unsigned RCOUNTER(name);\ ret_type __wrap_##name(__VA_ARGS__);\ ret_type __wrap_##name(__VA_ARGS__) {\ switch (util_fetch_and_add32(&RCOUNTER(name), 1)) { #define FUNC_MOCK_END\ }} #define FUNC_MOCK_RUN(run)\ case run: #define FUNC_MOCK_RUN_DEFAULT\ default: #define FUNC_MOCK_RUN_RET(run, ret)\ case run: return (ret); #define FUNC_MOCK_RUN_RET_DEFAULT_REAL(name, ...)\ default: return _FUNC_REAL(name)(__VA_ARGS__); #define FUNC_MOCK_RUN_RET_DEFAULT(ret)\ default: return (ret); #define FUNC_MOCK_RET_ALWAYS(name, ret_type, ret, ...)\ FUNC_MOCK(name, ret_type, __VA_ARGS__)\ FUNC_MOCK_RUN_RET_DEFAULT(ret);\ FUNC_MOCK_END #define FUNC_MOCK_RET_ALWAYS_VOID(name, ...)\ FUNC_MOCK(name, void, __VA_ARGS__)\ default: return;\ FUNC_MOCK_END extern unsigned long Ut_pagesize; extern unsigned long long Ut_mmap_align; extern os_mutex_t Sigactions_lock; void ut_dump_backtrace(void); void ut_sighandler(int); void ut_register_sighandlers(void); uint16_t ut_checksum(uint8_t *addr, size_t len); char *ut_toUTF8(const wchar_t *wstr); wchar_t *ut_toUTF16(const char *wstr); struct test_case { const char *name; int (*func)(const struct test_case *tc, int argc, char *argv[]); }; /* * get_tc -- return test case of specified name */ static inline const struct test_case * get_tc(const char *name, const struct test_case *test_cases, size_t ntests) { for (size_t i = 0; i < ntests; i++) { if (strcmp(name, test_cases[i].name) == 0) return &test_cases[i]; } return NULL; } static inline void TEST_CASE_PROCESS(int argc, char *argv[], const struct test_case *test_cases, size_t ntests) { if (argc < 2) UT_FATAL("usage: %s <test case> [<args>]", argv[0]); for (int i = 1; i < argc; i++) { char *str_test = argv[i]; const int args_off = i + 1; const struct test_case *tc = get_tc(str_test, test_cases, ntests); if (!tc) UT_FATAL("unknown test case -- '%s'", str_test); i += tc->func(tc, argc - args_off, &argv[args_off]); } } #define TEST_CASE_DECLARE(_name)\ int \ _name(const struct test_case *tc, int argc, char *argv[]) #define TEST_CASE(_name)\ {\ .name = #_name,\ .func = (_name),\ } #define STR(x) #x #define ASSERT_ALIGNED_BEGIN(type) do {\ size_t off = 0;\ const char *last = "(none)";\ type t; #define ASSERT_ALIGNED_FIELD(type, field) do {\ if (offsetof(type, field) != off)\ UT_FATAL("%s: padding, missing field or fields not in order between "\ "'%s' and '%s' -- offset %lu, real offset %lu",\ STR(type), last, STR(field), off, offsetof(type, field));\ off += sizeof(t.field);\ last = STR(field);\ } while (0) #define ASSERT_FIELD_SIZE(field, size) do {\ UT_COMPILE_ERROR_ON(size != sizeof(t.field));\ } while (0) #define ASSERT_OFFSET_CHECKPOINT(type, checkpoint) do {\ if (off != checkpoint)\ UT_FATAL("%s: violated offset checkpoint -- "\ "checkpoint %lu, real offset %lu",\ STR(type), checkpoint, off);\ } while (0) #define ASSERT_ALIGNED_CHECK(type)\ if (off != sizeof(type))\ UT_FATAL("%s: missing field or padding after '%s': "\ "sizeof(%s) = %lu, fields size = %lu",\ STR(type), last, STR(type), sizeof(type), off);\ } while (0) /* * AddressSanitizer */ #ifdef __clang__ #if __has_feature(address_sanitizer) #define UT_DEFINE_ASAN_POISON #endif #else #ifdef __SANITIZE_ADDRESS__ #define UT_DEFINE_ASAN_POISON #endif #endif #ifdef UT_DEFINE_ASAN_POISON void __asan_poison_memory_region(void const volatile *addr, size_t size); void __asan_unpoison_memory_region(void const volatile *addr, size_t size); #define ASAN_POISON_MEMORY_REGION(addr, size) \ __asan_poison_memory_region((addr), (size)) #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ __asan_unpoison_memory_region((addr), (size)) #else #define ASAN_POISON_MEMORY_REGION(addr, size) \ ((void)(addr), (void)(size)) #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ ((void)(addr), (void)(size)) #endif #ifdef __cplusplus } #endif #endif /* unittest.h */
25,141
30.506266
79
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/unittest/unittest.sh
# # Copyright 2014-2018, Intel Corporation # Copyright (c) 2016, Microsoft Corporation. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # set -e # make sure we have a well defined locale for string operations here export LC_ALL="C" #export LC_ALL="en_US.UTF-8" . ../testconfig.sh function verbose_msg() { if [ "$UNITTEST_LOG_LEVEL" -ge 2 ]; then echo "$*" fi } function msg() { if [ "$UNITTEST_LOG_LEVEL" -ge 1 ]; then echo "$*" fi } function fatal() { echo "$*" >&2 exit 1 } if [ -z "${UNITTEST_NAME}" ]; then CURDIR=$(basename $(pwd)) SCRIPTNAME=$(basename $0) export UNITTEST_NAME=$CURDIR/$SCRIPTNAME export UNITTEST_NUM=$(echo $SCRIPTNAME | sed "s/TEST//") fi # defaults [ "$UNITTEST_LOG_LEVEL" ] || UNITTEST_LOG_LEVEL=2 [ "$GREP" ] || GREP="grep -a" [ "$TEST" ] || TEST=check [ "$FS" ] || FS=any [ "$BUILD" ] || BUILD=debug [ "$CHECK_TYPE" ] || CHECK_TYPE=auto [ "$CHECK_POOL" ] || CHECK_POOL=0 [ "$VERBOSE" ] || VERBOSE=0 [ -n "${SUFFIX+x}" ] || SUFFIX="😘⠝⠧⠍⠇ɗPMDKӜ⥺🙋" export UNITTEST_LOG_LEVEL GREP TEST FS BUILD CHECK_TYPE CHECK_POOL VERBOSE SUFFIX VMMALLOC=libvmmalloc.so.1 TOOLS=../tools LIB_TOOLS="../../tools" # Paths to some useful tools [ "$PMEMPOOL" ] || PMEMPOOL=$LIB_TOOLS/pmempool/pmempool [ "$DAXIO" ] || DAXIO=$LIB_TOOLS/daxio/daxio [ "$PMEMSPOIL" ] || PMEMSPOIL=$TOOLS/pmemspoil/pmemspoil.static-nondebug [ "$BTTCREATE" ] || BTTCREATE=$TOOLS/bttcreate/bttcreate.static-nondebug [ "$PMEMWRITE" ] || PMEMWRITE=$TOOLS/pmemwrite/pmemwrite [ "$PMEMALLOC" ] || PMEMALLOC=$TOOLS/pmemalloc/pmemalloc [ "$PMEMOBJCLI" ] || PMEMOBJCLI=$TOOLS/pmemobjcli/pmemobjcli [ "$PMEMDETECT" ] || PMEMDETECT=$TOOLS/pmemdetect/pmemdetect.static-nondebug [ "$PMREORDER" ] || PMREORDER=$LIB_TOOLS/pmreorder/pmreorder.py [ "$FIP" ] || FIP=$TOOLS/fip/fip [ "$DDMAP" ] || DDMAP=$TOOLS/ddmap/ddmap [ "$CMPMAP" ] || CMPMAP=$TOOLS/cmpmap/cmpmap [ "$EXTENTS" ] || EXTENTS=$TOOLS/extents/extents [ "$FALLOCATE_DETECT" ] || FALLOCATE_DETECT=$TOOLS/fallocate_detect/fallocate_detect.static-nondebug [ "$OBJ_VERIFY" ] || OBJ_VERIFY=$TOOLS/obj_verify/obj_verify # force globs to fail if they don't match shopt -s failglob # number of remote nodes required in the current unit test NODES_MAX=-1 # sizes of aligments SIZE_4KB=4096 SIZE_2MB=2097152 # SSH and SCP options SSH_OPTS="-o BatchMode=yes" SCP_OPTS="-o BatchMode=yes -r -p" # list of common files to be copied to all remote nodes DIR_SRC="../.." FILES_COMMON_DIR="\ $DIR_SRC/test/*.supp \ $DIR_SRC/tools/rpmemd/rpmemd \ $DIR_SRC/tools/pmempool/pmempool \ $DIR_SRC/test/tools/extents/extents \ $DIR_SRC/test/tools/obj_verify/obj_verify \ $DIR_SRC/test/tools/ctrld/ctrld \ $DIR_SRC/test/tools/fip/fip" # Portability VALGRIND_SUPP="--suppressions=../ld.supp --suppressions=../memcheck-libunwind.supp" if [ "$(uname -s)" = "FreeBSD" ]; then DATE="gdate" DD="gdd" FALLOCATE="mkfile" VM_OVERCOMMIT="[ $(sysctl vm.overcommit | awk '{print $2}') == 0 ]" RM_ONEFS="-x" STAT_MODE="-f%Lp" STAT_PERM="-f%Sp" STAT_SIZE="-f%z" STRACE="truss" VALGRIND_SUPP="$VALGRIND_SUPP --suppressions=../freebsd.supp" else DATE="date" DD="dd" FALLOCATE="fallocate -l" VM_OVERCOMMIT="[ $(cat /proc/sys/vm/overcommit_memory) != 2 ]" RM_ONEFS="--one-file-system" STAT_MODE="-c%a" STAT_PERM="-c%A" STAT_SIZE="-c%s" STRACE="strace" fi # array of lists of PID files to be cleaned in case of an error NODE_PID_FILES[0]="" # # The variable TEST_LD_LIBRARY_PATH is constructed so the test pulls in # the appropriate library from this source tree. To override this behavior # (i.e. to force the test to use the libraries installed elsewhere on # the system), set TEST_LD_LIBRARY_PATH and this script will not override it. # # For example, in a test directory, run: # TEST_LD_LIBRARY_PATH=/usr/lib ./TEST0 # [ "$TEST_LD_LIBRARY_PATH" ] || { case "$BUILD" in debug|static-debug) if [ -z "$PMDK_LIB_PATH_DEBUG" ]; then TEST_LD_LIBRARY_PATH=../../debug REMOTE_LD_LIBRARY_PATH=../debug else TEST_LD_LIBRARY_PATH=$PMDK_LIB_PATH_DEBUG REMOTE_LD_LIBRARY_PATH=$PMDK_LIB_PATH_DEBUG fi ;; nondebug|static-nondebug) if [ -z "$PMDK_LIB_PATH_NONDEBUG" ]; then TEST_LD_LIBRARY_PATH=../../nondebug REMOTE_LD_LIBRARY_PATH=../nondebug else TEST_LD_LIBRARY_PATH=$PMDK_LIB_PATH_NONDEBUG REMOTE_LD_LIBRARY_PATH=$PMDK_LIB_PATH_NONDEBUG fi ;; esac } # # When running static binary tests, append the build type to the binary # case "$BUILD" in static-*) EXESUFFIX=.$BUILD ;; esac # # The variable DIR is constructed so the test uses that directory when # constructing test files. DIR is chosen based on the fs-type for # this test, and if the appropriate fs-type doesn't have a directory # defined in testconfig.sh, the test is skipped. # # This behavior can be overridden by setting DIR. For example: # DIR=/force/test/dir ./TEST0 # curtestdir=`basename $PWD` # just in case if [ ! "$curtestdir" ]; then fatal "curtestdir does not have a value" fi curtestdir=test_$curtestdir if [ ! "$UNITTEST_NUM" ]; then fatal "UNITTEST_NUM does not have a value" fi if [ ! "$UNITTEST_NAME" ]; then fatal "UNITTEST_NAME does not have a value" fi REAL_FS=$FS if [ "$DIR" ]; then DIR=$DIR/$curtestdir$UNITTEST_NUM else case "$FS" in pmem) # if a variable is set - it must point to a valid directory if [ "$PMEM_FS_DIR" == "" ]; then fatal "$UNITTEST_NAME: PMEM_FS_DIR is not set" fi DIR=$PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM if [ "$PMEM_FS_DIR_FORCE_PMEM" = "1" ] || [ "$PMEM_FS_DIR_FORCE_PMEM" = "2" ]; then export PMEM_IS_PMEM_FORCE=1 fi ;; non-pmem) # if a variable is set - it must point to a valid directory if [ "$NON_PMEM_FS_DIR" == "" ]; then fatal "$UNITTEST_NAME: NON_PMEM_FS_DIR is not set" fi DIR=$NON_PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM ;; any) if [ "$PMEM_FS_DIR" != "" ]; then DIR=$PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM REAL_FS=pmem if [ "$PMEM_FS_DIR_FORCE_PMEM" = "1" ] || [ "$PMEM_FS_DIR_FORCE_PMEM" = "2" ]; then export PMEM_IS_PMEM_FORCE=1 fi elif [ "$NON_PMEM_FS_DIR" != "" ]; then DIR=$NON_PMEM_FS_DIR/$DIRSUFFIX/$curtestdir$UNITTEST_NUM REAL_FS=non-pmem else fatal "$UNITTEST_NAME: fs-type=any and both env vars are empty" fi ;; none) DIR=/dev/null/not_existing_dir/$DIRSUFFIX/$curtestdir$UNITTEST_NUM ;; *) verbose_msg "$UNITTEST_NAME: SKIP fs-type $FS (not configured)" exit 0 ;; esac fi # # The default is to turn on library logging to level 3 and save it to local files. # Tests that don't want it on, should override these environment variables. # export VMEM_LOG_LEVEL=3 export VMEM_LOG_FILE=vmem$UNITTEST_NUM.log export PMEM_LOG_LEVEL=3 export PMEM_LOG_FILE=pmem$UNITTEST_NUM.log export PMEMBLK_LOG_LEVEL=3 export PMEMBLK_LOG_FILE=pmemblk$UNITTEST_NUM.log export PMEMLOG_LOG_LEVEL=3 export PMEMLOG_LOG_FILE=pmemlog$UNITTEST_NUM.log export PMEMOBJ_LOG_LEVEL=3 export PMEMOBJ_LOG_FILE=pmemobj$UNITTEST_NUM.log export PMEMCTO_LOG_LEVEL=3 export PMEMCTO_LOG_FILE=pmemcto$UNITTEST_NUM.log export PMEMPOOL_LOG_LEVEL=3 export PMEMPOOL_LOG_FILE=pmempool$UNITTEST_NUM.log export PMREORDER_LOG_FILE=pmreorder$UNITTEST_NUM.log export VMMALLOC_POOL_SIZE=$((16 * 1024 * 1024)) export VMMALLOC_LOG_LEVEL=3 export VMMALLOC_LOG_FILE=vmmalloc$UNITTEST_NUM.log export OUT_LOG_FILE=out$UNITTEST_NUM.log export ERR_LOG_FILE=err$UNITTEST_NUM.log export TRACE_LOG_FILE=trace$UNITTEST_NUM.log export PREP_LOG_FILE=prep$UNITTEST_NUM.log export VALGRIND_LOG_FILE=${CHECK_TYPE}${UNITTEST_NUM}.log export VALIDATE_VALGRIND_LOG=1 export RPMEM_LOG_LEVEL=3 export RPMEM_LOG_FILE=rpmem$UNITTEST_NUM.log export RPMEMD_LOG_LEVEL=info export RPMEMD_LOG_FILE=rpmemd$UNITTEST_NUM.log export REMOTE_VARS=" RPMEMD_LOG_FILE RPMEMD_LOG_LEVEL RPMEM_LOG_FILE RPMEM_LOG_LEVEL PMEM_LOG_FILE PMEM_LOG_LEVEL PMEMOBJ_LOG_FILE PMEMOBJ_LOG_LEVEL PMEMPOOL_LOG_FILE PMEMPOOL_LOG_LEVEL" [ "$UT_DUMP_LINES" ] || UT_DUMP_LINES=30 export CHECK_POOL_LOG_FILE=check_pool_${BUILD}_${UNITTEST_NUM}.log # In case a lock is required for Device DAXes DEVDAX_LOCK=../devdax.lock # # store_exit_on_error -- store on a stack a sign that reflects the current state # of the 'errexit' shell option # function store_exit_on_error() { if [ "${-#*e}" != "$-" ]; then estack+=- else estack+=+ fi } # # restore_exit_on_error -- restore the state of the 'errexit' shell option # function restore_exit_on_error() { if [ -z $estack ]; then fatal "error: store_exit_on_error function has to be called first" fi eval "set ${estack:${#estack}-1:1}e" estack=${estack%?} } # # disable_exit_on_error -- store the state of the 'errexit' shell option and # disable it # function disable_exit_on_error() { store_exit_on_error set +e } # # get_files -- print list of files in the current directory matching the given regex to stdout # # This function has been implemented to workaround a race condition in # `find`, which fails if any file disappears in the middle of the operation. # # example, to list all *.log files in the current directory # get_files ".*\.log" function get_files() { disable_exit_on_error ls -1 | grep -E "^$*$" restore_exit_on_error } # # get_executables -- print list of executable files in the current directory to stdout # # This function has been implemented to workaround a race condition in # `find`, which fails if any file disappears in the middle of the operation. # function get_executables() { disable_exit_on_error for c in * do if [ -f $c -a -x $c ] then echo "$c" fi done restore_exit_on_error } # # convert_to_bytes -- converts the string with K, M, G or T suffixes # to bytes # # example: # "1G" --> "1073741824" # "2T" --> "2199023255552" # "3k" --> "3072" # "1K" --> "1024" # "10" --> "10" # function convert_to_bytes() { size="$(echo $1 | tr '[:upper:]' '[:lower:]')" if [[ $size == *kib ]] then size=$(($(echo $size | tr -d 'kib') * 1024)) elif [[ $size == *mib ]] then size=$(($(echo $size | tr -d 'mib') * 1024 * 1024)) elif [[ $size == *gib ]] then size=$(($(echo $size | tr -d 'gib') * 1024 * 1024 * 1024)) elif [[ $size == *tib ]] then size=$(($(echo $size | tr -d 'tib') * 1024 * 1024 * 1024 * 1024)) elif [[ $size == *pib ]] then size=$(($(echo $size | tr -d 'pib') * 1024 * 1024 * 1024 * 1024 * 1024)) elif [[ $size == *kb ]] then size=$(($(echo $size | tr -d 'kb') * 1000)) elif [[ $size == *mb ]] then size=$(($(echo $size | tr -d 'mb') * 1000 * 1000)) elif [[ $size == *gb ]] then size=$(($(echo $size | tr -d 'gb') * 1000 * 1000 * 1000)) elif [[ $size == *tb ]] then size=$(($(echo $size | tr -d 'tb') * 1000 * 1000 * 1000 * 1000)) elif [[ $size == *pb ]] then size=$(($(echo $size | tr -d 'pb') * 1000 * 1000 * 1000 * 1000 * 1000)) elif [[ $size == *b ]] then size=$(($(echo $size | tr -d 'b'))) elif [[ $size == *k ]] then size=$(($(echo $size | tr -d 'k') * 1024)) elif [[ $size == *m ]] then size=$(($(echo $size | tr -d 'm') * 1024 * 1024)) elif [[ $size == *g ]] then size=$(($(echo $size | tr -d 'g') * 1024 * 1024 * 1024)) elif [[ $size == *t ]] then size=$(($(echo $size | tr -d 't') * 1024 * 1024 * 1024 * 1024)) elif [[ $size == *p ]] then size=$(($(echo $size | tr -d 'p') * 1024 * 1024 * 1024 * 1024 * 1024)) fi echo "$size" } # # create_file -- create zeroed out files of a given length # # example, to create two files, each 1GB in size: # create_file 1G testfile1 testfile2 # function create_file() { size=$(convert_to_bytes $1) shift for file in $* do $DD if=/dev/zero of=$file bs=1M count=$size iflag=count_bytes >> $PREP_LOG_FILE done } # # create_nonzeroed_file -- create non-zeroed files of a given length # # A given first kilobytes of the file is zeroed out. # # example, to create two files, each 1GB in size, with first 4K zeroed # create_nonzeroed_file 1G 4K testfile1 testfile2 # function create_nonzeroed_file() { offset=$(convert_to_bytes $2) size=$(($(convert_to_bytes $1) - $offset)) shift 2 for file in $* do truncate -s ${offset} $file >> $PREP_LOG_FILE $DD if=/dev/zero bs=1K count=${size} iflag=count_bytes 2>>$PREP_LOG_FILE | tr '\0' '\132' >> $file done } # # create_holey_file -- create holey files of a given length # # examples: # create_holey_file 1024k testfile1 testfile2 # create_holey_file 2048M testfile1 testfile2 # create_holey_file 234 testfile1 # create_holey_file 2340b testfile1 # # Input unit size is in bytes with optional suffixes like k, KB, M, etc. # function create_holey_file() { size=$(convert_to_bytes $1) shift for file in $* do truncate -s ${size} $file >> $PREP_LOG_FILE done } # # create_poolset -- create a dummy pool set # # Creates a pool set file using the provided list of part sizes and paths. # Optionally, it also creates the selected part files (zeroed, partially zeroed # or non-zeroed) with requested size and mode. The actual file size may be # different than the part size in the pool set file. # 'r' or 'R' on the list of arguments indicate the beginning of the next # replica set and 'm' or 'M' the beginning of the next remote replica set. # 'o' or 'O' indicates the next argument is a pool set option. # A remote replica requires two parameters: a target node and a pool set # descriptor. # # Each part argument has the following format: # psize:ppath[:cmd[:fsize[:mode]]] # # where: # psize - part size or AUTO (only for DAX device) # ppath - path # cmd - (optional) can be: # x - do nothing (may be skipped if there's no 'fsize', 'mode') # z - create zeroed (holey) file # n - create non-zeroed file # h - create non-zeroed file, but with zeroed header (first 4KB) # d - create directory # fsize - (optional) the actual size of the part file (if 'cmd' is not 'x') # mode - (optional) same format as for 'chmod' command # # Each remote replica argument has the following format: # node:desc # # where: # node - target node # desc - pool set descriptor # # example: # The following command define a pool set consisting of two parts: 16MB # and 32MB, a local replica with only one part of 48MB and a remote replica. # The first part file is not created, the second is zeroed. The only replica # part is non-zeroed. Also, the last file is read-only and its size # does not match the information from pool set file. The last but one line # describes a remote replica. The SINGLEHDR poolset option is set, so only # the first part in each replica contains a pool header. The remote poolset # also has to have the SINGLEHDR option. # # create_poolset ./pool.set 16M:testfile1 32M:testfile2:z \ # R 48M:testfile3:n:11M:0400 \ # M remote_node:remote_pool.set \ # O SINGLEHDR # function create_poolset() { psfile=$1 shift 1 echo "PMEMPOOLSET" > $psfile while [ "$1" ] do if [ "$1" = "M" ] || [ "$1" = "m" ] # remote replica then shift 1 cmd=$1 shift 1 # extract last ":" separated segment as descriptor # extract everything before last ":" as node address # this extraction method is compatible with IPv6 and IPv4 node=${cmd%:*} desc=${cmd##*:} echo "REPLICA $node $desc" >> $psfile continue fi if [ "$1" = "R" ] || [ "$1" = "r" ] then echo "REPLICA" >> $psfile shift 1 continue fi if [ "$1" = "O" ] || [ "$1" = "o" ] then echo "OPTION $2" >> $psfile shift 2 continue fi cmd=$1 fparms=(${cmd//:/ }) shift 1 fsize=${fparms[0]} fpath=${fparms[1]} cmd=${fparms[2]} asize=${fparms[3]} mode=${fparms[4]} if [ ! $asize ]; then asize=$fsize fi if [ "$asize" != "AUTO" ]; then asize=$(convert_to_bytes $asize) fi case "$cmd" in x) # do nothing ;; z) # zeroed (holey) file truncate -s $asize $fpath >> $PREP_LOG_FILE ;; n) # non-zeroed file $DD if=/dev/zero bs=$asize count=1 2>>$PREP_LOG_FILE | tr '\0' '\132' >> $fpath ;; h) # non-zeroed file, except 4K header truncate -s 4K $fpath >> prep$UNITTEST_NUM.log $DD if=/dev/zero bs=$asize count=1 2>>$PREP_LOG_FILE | tr '\0' '\132' >> $fpath truncate -s $asize $fpath >> $PREP_LOG_FILE ;; d) mkdir -p $fpath ;; esac if [ $mode ]; then chmod $mode $fpath fi echo "$fsize $fpath" >> $psfile done } function dump_last_n_lines() { if [ "$1" != "" -a -f "$1" ]; then ln=`wc -l < $1` if [ $ln -gt $UT_DUMP_LINES ]; then echo -e "Last $UT_DUMP_LINES lines of $1 below (whole file has $ln lines)." >&2 ln=$UT_DUMP_LINES else echo -e "$1 below." >&2 fi paste -d " " <(yes $UNITTEST_NAME $1 | head -n $ln) <(tail -n $ln $1) >&2 echo >&2 fi } # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810295 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780173 # https://bugs.kde.org/show_bug.cgi?id=303877 # # valgrind issues an unsuppressable warning when exceeding # the brk segment, causing matching failures. We can safely # ignore it because malloc() will fallback to mmap() anyway. function valgrind_ignore_warnings() { cat $1 | grep -v \ -e "WARNING: Serious error when reading debug info" \ -e "When reading debug info from " \ -e "Ignoring non-Dwarf2/3/4 block in .debug_info" \ -e "Last block truncated in .debug_info; ignoring" \ -e "parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4" \ -e "brk segment overflow" \ -e "see section Limitations in user manual" \ -e "Warning: set address range perms: large range"\ -e "further instances of this message will not be shown"\ > $1.tmp mv $1.tmp $1 } # # get_trace -- return tracing tool command line if applicable # usage: get_trace <check type> <log file> [<node>] # function get_trace() { if [ "$1" == "none" ]; then echo "$TRACE" return fi local exe=$VALGRINDEXE local check_type=$1 local log_file=$2 local opts="$VALGRIND_OPTS" local node=-1 [ "$#" -eq 3 ] && node=$3 if [ "$check_type" = "memcheck" -a "$MEMCHECK_DONT_CHECK_LEAKS" != "1" ]; then opts="$opts --leak-check=full" fi if [ "$check_type" = "pmemcheck" ]; then # Before Skylake, Intel CPUs did not have clflushopt instruction, so # pmem_flush and pmem_persist both translated to clflush. # This means that missing pmem_drain after pmem_flush could only be # detected on Skylake+ CPUs. # This option tells pmemcheck to expect fence (sfence or # VALGRIND_PMC_DO_FENCE client request, used by pmem_drain) after # clflush and makes pmemcheck output the same on pre-Skylake and # post-Skylake CPUs. opts="$opts --expect-fence-after-clflush=yes" fi opts="$opts $VALGRIND_SUPP" if [ "$node" -ne -1 ]; then exe=${NODE_VALGRINDEXE[$node]} opts="$opts" case "$check_type" in memcheck) opts="$opts --suppressions=../memcheck-libibverbs.supp" ;; helgrind) opts="$opts --suppressions=../helgrind-cxgb4.supp" opts="$opts --suppressions=../helgrind-libfabric.supp" ;; drd) opts="$opts --suppressions=../drd-libfabric.supp" ;; esac fi echo "$exe --tool=$check_type --log-file=$log_file $opts $TRACE" return } # # validate_valgrind_log -- validate valgrind log # usage: validate_valgrind_log <log-file> # function validate_valgrind_log() { [ "$VALIDATE_VALGRIND_LOG" != "1" ] && return # fail if there are valgrind errors found or # if it detects overlapping chunks if [ ! -e "$1.match" ] && grep \ -e "ERROR SUMMARY: [^0]" \ -e "Bad mempool" \ $1 >/dev/null ; then msg="failed" [ -t 2 ] && command -v tput >/dev/null && msg="$(tput setaf 1)$msg$(tput sgr0)" echo -e "$UNITTEST_NAME $msg with Valgrind. See $1. Last 20 lines below." >&2 paste -d " " <(yes $UNITTEST_NAME $1 | head -n 20) <(tail -n 20 $1) >&2 false fi } # # expect_normal_exit -- run a given command, expect it to exit 0 # # if VALGRIND_DISABLED is not empty valgrind tool will be omitted # function expect_normal_exit() { local VALGRIND_LOG_FILE=${CHECK_TYPE}${UNITTEST_NUM}.log local N=$2 # in case of a remote execution disable valgrind check if valgrind is not # enabled on node local _CHECK_TYPE=$CHECK_TYPE if [ "x$VALGRIND_DISABLED" != "x" ]; then _CHECK_TYPE=none fi if [ "$1" == "run_on_node" -o "$1" == "run_on_node_background" ]; then if [ -z $(is_valgrind_enabled_on_node $N) ]; then _CHECK_TYPE="none" fi else N=-1 fi if [ -n "$TRACE" ]; then case "$1" in *_on_node*) msg "$UNITTEST_NAME: SKIP: TRACE is not supported if test is executed on remote nodes" exit 0 esac fi local trace=$(get_trace $_CHECK_TYPE $VALGRIND_LOG_FILE $N) if [ "$MEMCHECK_DONT_CHECK_LEAKS" = "1" -a "$CHECK_TYPE" = "memcheck" ]; then export OLD_ASAN_OPTIONS="${ASAN_OPTIONS}" export ASAN_OPTIONS="detect_leaks=0 ${ASAN_OPTIONS}" fi if [ "$CHECK_TYPE" = "helgrind" ]; then export VALGRIND_OPTS="--suppressions=../helgrind-log.supp" fi if [ "$CHECK_TYPE" = "memcheck" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=../memcheck-dlopen.supp" fi # in case of preloading libvmmalloc.so.1 force valgrind to not override malloc if [ -n "$VALGRINDEXE" -a -n "$TEST_LD_PRELOAD" ]; then if [ $(valgrind_version) -ge 312 ]; then preload=`basename $TEST_LD_PRELOAD` fi if [ "$preload" == "$VMMALLOC" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --soname-synonyms=somalloc=nouserintercepts" fi fi local REMOTE_VALGRIND_LOG=0 if [ "$CHECK_TYPE" != "none" ]; then case "$1" in run_on_node) REMOTE_VALGRIND_LOG=1 trace="$1 $2 $trace" [ $# -ge 2 ] && shift 2 || shift $# ;; run_on_node_background) trace="$1 $2 $3 $trace" [ $# -ge 3 ] && shift 3 || shift $# ;; wait_on_node|wait_on_node_port|kill_on_node) [ "$1" = "wait_on_node" ] && REMOTE_VALGRIND_LOG=1 trace="$1 $2 $3 $4" [ $# -ge 4 ] && shift 4 || shift $# ;; esac fi if [ "$CHECK_TYPE" = "drd" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=../drd-log.supp" fi disable_exit_on_error eval $ECHO LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH LD_PRELOAD=$TEST_LD_PRELOAD \ $trace $* ret=$? if [ $REMOTE_VALGRIND_LOG -eq 1 ]; then for node in $CHECK_NODES do local new_log_file=node\_$node\_$VALGRIND_LOG_FILE copy_files_from_node $node "." ${NODE_TEST_DIR[$node]}/$VALGRIND_LOG_FILE mv $VALGRIND_LOG_FILE $new_log_file done fi restore_exit_on_error if [ "$ret" -ne "0" ]; then if [ "$ret" -gt "128" ]; then msg="crashed (signal $(($ret - 128)))" else msg="failed with exit code $ret" fi [ -t 2 ] && command -v tput >/dev/null && msg="$(tput setaf 1)$msg$(tput sgr0)" if [ -f $ERR_LOG_FILE ]; then if [ "$UNITTEST_LOG_LEVEL" -ge "1" ]; then echo -e "$UNITTEST_NAME $msg. $ERR_LOG_FILE below." >&2 cat $ERR_LOG_FILE >&2 else echo -e "$UNITTEST_NAME $msg. $ERR_LOG_FILE above." >&2 fi else echo -e "$UNITTEST_NAME $msg." >&2 fi if [ "$CHECK_TYPE" != "none" -a -f $VALGRIND_LOG_FILE ]; then dump_last_n_lines $VALGRIND_LOG_FILE fi # ignore Ctrl-C if [ $ret != 130 ]; then for f in $(get_files "node_.*${UNITTEST_NUM}\.log"); do dump_last_n_lines $f done dump_last_n_lines $TRACE_LOG_FILE dump_last_n_lines $PMEM_LOG_FILE dump_last_n_lines $PMEMOBJ_LOG_FILE dump_last_n_lines $PMEMLOG_LOG_FILE dump_last_n_lines $PMEMBLK_LOG_FILE dump_last_n_lines $PMEMCTO_LOG_FILE dump_last_n_lines $PMEMPOOL_LOG_FILE dump_last_n_lines $VMEM_LOG_FILE dump_last_n_lines $VMMALLOC_LOG_FILE dump_last_n_lines $RPMEM_LOG_FILE dump_last_n_lines $RPMEMD_LOG_FILE fi [ $NODES_MAX -ge 0 ] && clean_all_remote_nodes false fi if [ "$CHECK_TYPE" != "none" ]; then if [ $REMOTE_VALGRIND_LOG -eq 1 ]; then for node in $CHECK_NODES do local log_file=node\_$node\_$VALGRIND_LOG_FILE valgrind_ignore_warnings $new_log_file validate_valgrind_log $new_log_file done else if [ -f $VALGRIND_LOG_FILE ]; then valgrind_ignore_warnings $VALGRIND_LOG_FILE validate_valgrind_log $VALGRIND_LOG_FILE fi fi fi if [ "$MEMCHECK_DONT_CHECK_LEAKS" = "1" -a "$CHECK_TYPE" = "memcheck" ]; then export ASAN_OPTIONS="${OLD_ASAN_OPTIONS}" fi } # # expect_abnormal_exit -- run a given command, expect it to exit non-zero # function expect_abnormal_exit() { if [ -n "$TRACE" ]; then case "$1" in *_on_node*) msg "$UNITTEST_NAME: SKIP: TRACE is not supported if test is executed on remote nodes" exit 0 esac fi # in case of preloading libvmmalloc.so.1 force valgrind to not override malloc if [ -n "$VALGRINDEXE" -a -n "$TEST_LD_PRELOAD" ]; then if [ $(valgrind_version) -ge 312 ]; then preload=`basename $TEST_LD_PRELOAD` fi if [ "$preload" == "$VMMALLOC" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --soname-synonyms=somalloc=nouserintercepts" fi fi if [ "$CHECK_TYPE" = "drd" ]; then export VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=../drd-log.supp" fi disable_exit_on_error eval $ECHO ASAN_OPTIONS="detect_leaks=0 ${ASAN_OPTIONS}" \ LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH LD_PRELOAD=$TEST_LD_PRELOAD $TRACE $* ret=$? restore_exit_on_error if [ "$ret" -eq "0" ]; then msg="succeeded" [ -t 2 ] && command -v tput >/dev/null && msg="$(tput setaf 1)$msg$(tput sgr0)" echo -e "$UNITTEST_NAME command $msg unexpectedly." >&2 [ $NODES_MAX -ge 0 ] && clean_all_remote_nodes false fi } # # check_pool -- run pmempool check on specified pool file # function check_pool() { if [ "$CHECK_POOL" == "1" ] then if [ "$VERBOSE" != "0" ] then echo "$UNITTEST_NAME: checking consistency of pool ${1}" fi ${PMEMPOOL}.static-nondebug check $1 2>&1 1>>$CHECK_POOL_LOG_FILE fi } # # check_pools -- run pmempool check on specified pool files # function check_pools() { if [ "$CHECK_POOL" == "1" ] then for f in $* do check_pool $f done fi } # # require_unlimited_vm -- require unlimited virtual memory # # This implies requirements for: # - overcommit_memory enabled (/proc/sys/vm/overcommit_memory is 0 or 1) # - unlimited virtual memory (ulimit -v is unlimited) # function require_unlimited_vm() { $VM_OVERCOMMIT && [ $(ulimit -v) = "unlimited" ] && return msg "$UNITTEST_NAME: SKIP required: overcommit_memory enabled and unlimited virtual memory" exit 0 } # # require_linked_with_ndctl -- require an executable linked with libndctl # # usage: require_linked_with_ndctl <executable-file> # function require_linked_with_ndctl() { [ "$1" == "" -o ! -x "$1" ] && \ fatal "$UNITTEST_NAME: ERROR: require_linked_with_ndctl() requires one argument - an executable file" local lddndctl=$(expect_normal_exit ldd $1 | $GREP -ce "libndctl") [ "$lddndctl" == "1" ] && return msg "$UNITTEST_NAME: SKIP required: executable $1 linked with libndctl" exit 0 } # # require_sudo_allowed -- require sudo command is allowed # function require_sudo_allowed() { if [ "$ENABLE_SUDO_TESTS" != "y" ]; then msg "$UNITTEST_NAME: SKIP: tests using 'sudo' are not enabled in testconfig.sh (ENABLE_SUDO_TESTS)" exit 0 fi if ! timeout --signal=SIGKILL --kill-after=3s 3s sudo date >/dev/null 2>&1 then msg "$UNITTEST_NAME: SKIP required: sudo allowed" exit 0 fi } # # require_sudo_allowed_node -- require sudo command on a remote node # # usage: require_sudo_allowed_node <node-number> # function require_sudo_allowed_node() { if [ "$ENABLE_SUDO_TESTS" != "y" ]; then msg "$UNITTEST_NAME: SKIP: tests using 'sudo' are not enabled in testconfig.sh (ENABLE_SUDO_TESTS)" exit 0 fi if ! run_on_node $1 "timeout --signal=SIGKILL --kill-after=3s 3s sudo date" >/dev/null 2>&1 then msg "$UNITTEST_NAME: SKIP required: sudo allowed on node $1" exit 0 fi } # # require_no_superuser -- require user without superuser rights # function require_no_superuser() { local user_id=$(id -u) [ "$user_id" != "0" ] && return msg "$UNITTEST_NAME: SKIP required: run without superuser rights" exit 0 } # # require_no_freebsd -- Skip test on FreeBSD # function require_no_freebsd() { [ "$(uname -s)" != "FreeBSD" ] && return msg "$UNITTEST_NAME: SKIP: Not supported on FreeBSD" exit 0 } # # require_procfs -- Skip test if /proc is not mounted # function require_procfs() { mount | grep -q "/proc" && return msg "$UNITTEST_NAME: SKIP: /proc not mounted" exit 0 } function get_arch() { gcc -dumpmachine | awk -F'[/-]' '{print $1}' } function require_x86_64() { [ $(get_arch) = "x86_64" ] && return msg "$UNITTEST_NAME: SKIP: Not supported on arch != x86_64" exit 0 } # # require_test_type -- only allow script to continue for a certain test type # function require_test_type() { req_test_type=1 for type in $* do case "$TEST" in all) # "all" is a synonym of "short + medium + long" return ;; check) # "check" is a synonym of "short + medium" [ "$type" = "short" -o "$type" = "medium" ] && return ;; *) [ "$type" = "$TEST" ] && return ;; esac done verbose_msg "$UNITTEST_NAME: SKIP test-type $TEST ($* required)" exit 0 } # # require_dev_dax_region -- check if region id file exist for dev dax # function require_dev_dax_region() { local prefix="$UNITTEST_NAME: SKIP" local cmd="$PMEMDETECT -r" for path in ${DEVICE_DAX_PATH[@]} do disable_exit_on_error out=$($cmd $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then continue elif [ "$ret" == "1" ]; then msg "$prefix $out" exit 0 else fatal "$UNITTEST_NAME: pmemdetect: $out" fi done DEVDAX_TO_LOCK=1 } # # lock_devdax -- acquire a lock on Device DAXes # lock_devdax() { exec {DEVDAX_LOCK_FD}> $DEVDAX_LOCK flock $DEVDAX_LOCK_FD } # # unlock_devdax -- release a lock on Device DAXes # unlock_devdax() { flock -u $DEVDAX_LOCK_FD eval "exec ${DEVDAX_LOCK_FD}>&-" } # # require_dev_dax_node -- common function for require_dax_devices and # node_require_dax_device # # usage: require_dev_dax_node <N devices> [<node>] # function require_dev_dax_node() { req_dax_dev=1 if [ "$req_dax_dev_align" == "1" ]; then fatal "$UNITTEST_NAME: Do not use 'require_(node_)dax_devices' and " "'require_(node_)dax_device_alignments' together. Use the latter instead." fi local min=$1 local node=$2 if [ -n "$node" ]; then local DIR=${NODE_WORKING_DIR[$node]}/$curtestdir local prefix="$UNITTEST_NAME: SKIP NODE $node:" local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) if [ ${#device_dax_path[@]} -lt $min ]; then msg "$prefix NODE_${node}_DEVICE_DAX_PATH does not specify enough dax devices (min: $min)" exit 0 fi local cmd="ssh $SSH_OPTS ${NODE[$node]} cd $DIR && LD_LIBRARY_PATH=$REMOTE_LD_LIBRARY_PATH ../pmemdetect -d" else local prefix="$UNITTEST_NAME: SKIP" if [ ${#DEVICE_DAX_PATH[@]} -lt $min ]; then msg "$prefix DEVICE_DAX_PATH does not specify enough dax devices (min: $min)" exit 0 fi local device_dax_path=${DEVICE_DAX_PATH[@]} local cmd="$PMEMDETECT -d" fi for path in ${device_dax_path[@]} do disable_exit_on_error out=$($cmd $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then continue elif [ "$ret" == "1" ]; then msg "$prefix $out" exit 0 else fatal "$UNITTEST_NAME: pmemdetect: $out" fi done DEVDAX_TO_LOCK=1 } # # require_dax_devices -- only allow script to continue if there is a required # number of Device DAX devices # function require_dax_devices() { require_dev_dax_node $1 } # # require_node_dax_device -- only allow script to continue if specified node # has enough Device DAX devices defined in testconfig.sh # function require_node_dax_device() { validate_node_number $1 require_dev_dax_node $2 $1 } # # require_no_unicode -- overwrite unicode suffix to empty string # function require_no_unicode() { export SUFFIX="" } # # get_node_devdax_path -- get path of a Device DAX device on a node # # usage: get_node_devdax_path <node> <device> # get_node_devdax_path() { local node=$1 local device=$2 local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) echo ${device_dax_path[$device]} } # # dax_device_zero -- zero all local dax devices # dax_device_zero() { for path in ${DEVICE_DAX_PATH[@]} do ${PMEMPOOL}.static-debug rm -f $path done } # # node_dax_device_zero -- zero all dax devices on a node # node_dax_device_zero() { local node=$1 local DIR=${NODE_WORKING_DIR[$node]}/$curtestdir local prefix="$UNITTEST_NAME: SKIP NODE $node:" local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) local cmd="ssh $SSH_OPTS ${NODE[$node]} cd $DIR && LD_LIBRARY_PATH=$REMOTE_LD_LIBRARY_PATH ../pmempool rm -f" for path in ${device_dax_path[@]} do disable_exit_on_error out=$($cmd $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then continue elif [ "$ret" == "1" ]; then msg "$prefix $out" exit 0 else fatal "$UNITTEST_NAME: pmempool rm: $out" fi done } # # get_devdax_size -- get the size of a device dax # function get_devdax_size() { local device=$1 local path=${DEVICE_DAX_PATH[$device]} local major_hex=$(stat -c "%t" $path) local minor_hex=$(stat -c "%T" $path) local major_dec=$((16#$major_hex)) local minor_dec=$((16#$minor_hex)) cat /sys/dev/char/$major_dec:$minor_dec/size } # # get_node_devdax_size -- get the size of a device dax on a node # function get_node_devdax_size() { local node=$1 local device=$2 local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) local path=${device_dax_path[$device]} local cmd_prefix="ssh $SSH_OPTS ${NODE[$node]} " disable_exit_on_error out=$($cmd_prefix stat -c %t $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" != "0" ]; then fatal "$UNITTEST_NAME: stat on node $node: $out" fi local major=$((16#$out)) disable_exit_on_error out=$($cmd_prefix stat -c %T $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" != "0" ]; then fatal "$UNITTEST_NAME: stat on node $node: $out" fi local minor=$((16#$out)) disable_exit_on_error out=$($cmd_prefix "cat /sys/dev/char/$major:$minor/size" 2>&1) ret=$? restore_exit_on_error if [ "$ret" != "0" ]; then fatal "$UNITTEST_NAME: stat on node $node: $out" fi echo $out } # # dax_get_alignment -- get the alignment of a device dax # function dax_get_alignment() { major_hex=$(stat -c "%t" $1) minor_hex=$(stat -c "%T" $1) major_dec=$((16#$major_hex)) minor_dec=$((16#$minor_hex)) cat /sys/dev/char/$major_dec:$minor_dec/device/align } # # require_dax_device_node_alignments -- only allow script to continue if # the internal Device DAX alignments on a remote nodes are as specified. # If necessary, it sorts DEVICE_DAX_PATH entries to match # the requested alignment order. # # usage: require_node_dax_device_alignments <node> <alignment1> [ alignment2 ... ] # function require_node_dax_device_alignments() { req_dax_dev_align=1 if [ "$req_dax_dev" == "$1" ]; then fatal "$UNITTEST_NAME: Do not use 'require_(node_)dax_devices' and " "'require_(node_)dax_device_alignments' together. Use the latter instead." fi local node=$1 shift if [ "$node" == "-1" ]; then local device_dax_path=(${DEVICE_DAX_PATH[@]}) local cmd="$PMEMDETECT -a" else local device_dax_path=(${NODE_DEVICE_DAX_PATH[$node]}) local DIR=${NODE_WORKING_DIR[$node]}/$curtestdir local cmd="ssh $SSH_OPTS ${NODE[$node]} cd $DIR && LD_LIBRARY_PATH=$REMOTE_LD_LIBRARY_PATH ../pmemdetect -a" fi local cnt=${#device_dax_path[@]} local j=0 for alignment in $* do for (( i=j; i<cnt; i++ )) do path=${device_dax_path[$i]} disable_exit_on_error out=$($cmd $alignment $path 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then if [ $i -ne $j ]; then # swap device paths tmp=${device_dax_path[$j]} device_dax_path[$j]=$path device_dax_path[$i]=$tmp if [ "$node" == "-1" ]; then DEVICE_DAX_PATH=(${device_dax_path[@]}) else NODE_DEVICE_DAX_PATH[$node]=${device_dax_path[@]} fi fi break fi done if [ $i -eq $cnt ]; then if [ "$node" == "-1" ]; then msg "$UNITTEST_NAME: SKIP DEVICE_DAX_PATH"\ "does not specify enough dax devices or they don't have required alignments (min: $#, alignments: $*)" else msg "$UNITTEST_NAME: SKIP NODE $node: NODE_${node}_DEVICE_DAX_PATH"\ "does not specify enough dax devices or they don't have required alignments (min: $#, alignments: $*)" fi exit 0 fi j=$(( j + 1 )) done } # # require_dax_device_alignments -- only allow script to continue if # the internal Device DAX alignments are as specified. # If necessary, it sorts DEVICE_DAX_PATH entries to match # the requested alignment order. # # usage: require_dax_device_alignments alignment1 [ alignment2 ... ] # require_dax_device_alignments() { require_node_dax_device_alignments -1 $* } # # require_fs_type -- only allow script to continue for a certain fs type # function require_fs_type() { req_fs_type=1 for type in $* do # treat any as either pmem or non-pmem [ "$type" = "$FS" ] || ([ -n "${FORCE_FS:+x}" ] && [ "$type" = "any" ] && [ "$FS" != "none" ]) && return done verbose_msg "$UNITTEST_NAME: SKIP fs-type $FS ($* required)" exit 0 } # # require_native_fallocate -- verify if filesystem supports fallocate # function require_native_fallocate() { require_fs_type pmem non-pmem set +e $FALLOCATE_DETECT $1 status=$? set -e if [ $status -eq 1 ]; then msg "$UNITTEST_NAME: SKIP: filesystem does not support fallocate" exit 0 elif [ $status -ne 0 ]; then msg "$UNITTEST_NAME: fallocate_detect failed" exit 1 fi } # # require_fs_name -- verify if the $DIR is on the required file system # # Must be AFTER setup() because $DIR must exist # function require_fs_name() { fsname=`df $DIR -PT | awk '{if (NR == 2) print $2}'` for name in $* do if [ "$name" == "$fsname" ]; then return fi done echo "$UNITTEST_NAME: SKIP file system $fsname ($* required)" exit 0 } # # require_build_type -- only allow script to continue for a certain build type # function require_build_type() { for type in $* do [ "$type" = "$BUILD" ] && return done verbose_msg "$UNITTEST_NAME: SKIP build-type $BUILD ($* required)" exit 0 } # # require_command -- only allow script to continue if specified command exists # function require_command() { if ! which $1 &>/dev/null; then msg "$UNITTEST_NAME: SKIP: '$1' command required" exit 0 fi } # # require_command_node -- only allow script to continue if specified command exists on a remote node # # usage: require_command_node <node-number> # function require_command_node() { if ! run_on_node $1 "which $2 &>/dev/null"; then msg "$UNITTEST_NAME: SKIP: node $1: '$2' command required" exit 0 fi } # # require_kernel_module -- only allow script to continue if specified kernel module exists # # usage: require_kernel_module <module_name> [path_to_modinfo] # function require_kernel_module() { MODULE=$1 MODINFO=$2 if [ "$MODINFO" == "" ]; then set +e [ "$MODINFO" == "" ] && \ MODINFO=$(which modinfo 2>/dev/null) set -e [ "$MODINFO" == "" ] && \ [ -x /usr/sbin/modinfo ] && MODINFO=/usr/sbin/modinfo [ "$MODINFO" == "" ] && \ [ -x /sbin/modinfo ] && MODINFO=/sbin/modinfo [ "$MODINFO" == "" ] && \ msg "$UNITTEST_NAME: SKIP: modinfo command required" && \ exit 0 else [ ! -x $MODINFO ] && \ msg "$UNITTEST_NAME: SKIP: modinfo command required" && \ exit 0 fi $MODINFO -F name $MODULE &>/dev/null && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP: '$MODULE' kernel module required" exit 0 fi } # # require_kernel_module_node -- only allow script to continue if specified kernel module exists on a remote node # # usage: require_kernel_module_node <node> <module_name> [path_to_modinfo] # function require_kernel_module_node() { NODE_N=$1 MODULE=$2 MODINFO=$3 if [ "$MODINFO" == "" ]; then set +e [ "$MODINFO" == "" ] && \ MODINFO=$(run_on_node $NODE_N which modinfo 2>/dev/null) set -e [ "$MODINFO" == "" ] && \ run_on_node $NODE_N "test -x /usr/sbin/modinfo" && MODINFO=/usr/sbin/modinfo [ "$MODINFO" == "" ] && \ run_on_node $NODE_N "test -x /sbin/modinfo" && MODINFO=/sbin/modinfo [ "$MODINFO" == "" ] && \ msg "$UNITTEST_NAME: SKIP: node $NODE_N: modinfo command required" && \ exit 0 else run_on_node $NODE_N "test ! -x $MODINFO" && \ msg "$UNITTEST_NAME: SKIP: node $NODE_N: modinfo command required" && \ exit 0 fi run_on_node $NODE_N "$MODINFO -F name $MODULE &>/dev/null" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP: node $NODE_N: '$MODULE' kernel module required" exit 0 fi } # # require_pkg -- only allow script to continue if specified package exists # usage: require_pkg <package name> [<package minimal version>] # function require_pkg() { if ! command -v pkg-config 1>/dev/null then msg "$UNITTEST_NAME: SKIP pkg-config required" exit 0 fi local COMMAND="pkg-config $1" local MSG="$UNITTEST_NAME: SKIP '$1' package" if [ "$#" -eq "2" ]; then COMMAND="$COMMAND --atleast-version $2" MSG="$MSG (version >= $2)" fi MSG="$MSG required" if ! $COMMAND then msg "$MSG" exit 0 fi } # # require_node_pkg -- only allow script to continue if specified package exists # on specified node # usage: require_node_pkg <node> <package name> [<package minimal version>] # function require_node_pkg() { validate_node_number $1 local N=$1 shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="${NODE_ENV[$N]}" if [ -n "${NODE_LD_LIBRARY_PATH[$N]}" ]; then local PKG_CONFIG_PATH=${NODE_LD_LIBRARY_PATH[$N]//:/\/pkgconfig:}/pkgconfig COMMAND="$COMMAND PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:$PKG_CONFIG_PATH" fi COMMAND="$COMMAND pkg-config $1" MSG="$UNITTEST_NAME: SKIP NODE $N: '$1' package" if [ "$#" -eq "2" ]; then COMMAND="$COMMAND --atleast-version $2" MSG="$MSG (version >= $2)" fi MSG="$MSG required" disable_exit_on_error run_command ssh $SSH_OPTS ${NODE[$N]} "$COMMAND" 2>&1 ret=$? restore_exit_on_error if [ "$ret" == 1 ]; then msg "$MSG" exit 0 fi } # # configure_valgrind -- only allow script to continue when settings match # function configure_valgrind() { case "$1" in memcheck|pmemcheck|helgrind|drd|force-disable) ;; *) usage "bad test-type: $1" ;; esac if [ "$CHECK_TYPE" == "none" ]; then if [ "$1" == "force-disable" ]; then msg "$UNITTEST_NAME: all valgrind tests disabled" elif [ "$2" = "force-enable" ]; then CHECK_TYPE="$1" require_valgrind_tool $1 $3 elif [ "$2" = "force-disable" ]; then CHECK_TYPE=none else fatal "invalid parameter" fi else if [ "$1" == "force-disable" ]; then msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable valgrind test when all valgrind tests are disabled in TEST" exit 0 elif [ "$CHECK_TYPE" != "$1" -a "$2" == "force-enable" ]; then msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable different valgrind test than one defined in TEST" exit 0 elif [ "$CHECK_TYPE" == "$1" -a "$2" == "force-disable" ]; then msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable test defined in TEST as force-disable" exit 0 fi require_valgrind_tool $CHECK_TYPE $3 fi if [ "$UT_VALGRIND_SKIP_PRINT_MISMATCHED" == 1 ]; then export UT_SKIP_PRINT_MISMATCHED=1 fi } # # valgrind_version_no_check -- returns Valgrind version without checking # for valgrind first # function valgrind_version_no_check() { require_command bc $VALGRINDEXE --version | sed "s/valgrind-\([0-9]*\)\.\([0-9]*\).*/\1*100+\2/" | bc } # # require_valgrind -- continue script execution only if # valgrind package is installed # function require_valgrind() { require_no_asan disable_exit_on_error VALGRINDEXE=`which valgrind 2>/dev/null` local ret=$? restore_exit_on_error if [ $ret -ne 0 ]; then msg "$UNITTEST_NAME: SKIP valgrind required" exit 0 fi [ $NODES_MAX -lt 0 ] && return; if [ ! -z "$1" ]; then available=$(valgrind_version_no_check) required=`echo $1 | sed "s/\([0-9]*\)\.\([0-9]*\).*/\1*100+\2/" | bc` if [ $available -lt $required ]; then msg "$UNITTEST_NAME: SKIP valgrind required (ver $1 or later)" exit 0 fi fi for N in $NODES_SEQ; do if [ "${NODE_VALGRINDEXE[$N]}" = "" ]; then disable_exit_on_error NODE_VALGRINDEXE[$N]=$(ssh $SSH_OPTS ${NODE[$N]} "which valgrind 2>/dev/null") ret=$? restore_exit_on_error if [ $ret -ne 0 ]; then msg "$UNITTEST_NAME: SKIP valgrind required on remote node #$N" exit 0 fi fi done } # # valgrind_version -- returns Valgrind version # function valgrind_version() { require_valgrind valgrind_version_no_check } # # require_valgrind_tool -- continue script execution only if valgrind with # specified tool is installed # # usage: require_valgrind_tool <tool> [<binary>] # function require_valgrind_tool() { require_valgrind local tool=$1 local binary=$2 local dir=. [ -d "$2" ] && dir="$2" && binary= pushd "$dir" > /dev/null [ -n "$binary" ] || binary=$(get_executables) if [ -z "$binary" ]; then fatal "require_valgrind_tool: error: no binary found" fi strings ${binary} 2>&1 | \ grep -q "compiled with support for Valgrind $tool" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP not compiled with support for Valgrind $tool" exit 0 fi if [ "$tool" == "helgrind" ]; then valgrind --tool=$tool --help 2>&1 | \ grep -qi "$tool is Copyright (c)" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP Valgrind with $tool required" exit 0; fi fi if [ "$tool" == "pmemcheck" ]; then out=`valgrind --tool=$tool --help 2>&1` && true echo "$out" | grep -qi "$tool is Copyright (c)" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP Valgrind with $tool required" exit 0; fi echo "$out" | grep -qi "expect-fence-after-clflush" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP pmemcheck does not support --expect-fence-after-clflush option. Please update it to the latest version." exit 0; fi fi popd > /dev/null return 0 } # # set_valgrind_exe_name -- set the actual Valgrind executable name # # On some systems (Ubuntu), "valgrind" is a shell script that calls # the actual executable "valgrind.bin". # The wrapper script doesn't work well with LD_PRELOAD, so we want # to call Valgrind directly. # function set_valgrind_exe_name() { if [ "$VALGRINDEXE" = "" ]; then fatal "set_valgrind_exe_name: error: valgrind is not set up" fi local VALGRINDDIR=`dirname $VALGRINDEXE` if [ -x $VALGRINDDIR/valgrind.bin ]; then VALGRINDEXE=$VALGRINDDIR/valgrind.bin fi [ $NODES_MAX -lt 0 ] && return; for N in $NODES_SEQ; do local COMMAND="\ [ -x $(dirname ${NODE_VALGRINDEXE[$N]})/valgrind.bin ] && \ echo $(dirname ${NODE_VALGRINDEXE[$N]})/valgrind.bin || \ echo ${NODE_VALGRINDEXE[$N]}" NODE_VALGRINDEXE[$N]=$(ssh $SSH_OPTS ${NODE[$N]} $COMMAND) if [ $? -ne 0 ]; then fatal ${NODE_VALGRINDEXE[$N]} fi done } # # require_no_asan_for - continue script execution only if passed binary does # NOT require libasan # function require_no_asan_for() { disable_exit_on_error nm $1 | grep -q __asan_ ASAN_ENABLED=$? restore_exit_on_error if [ "$ASAN_ENABLED" == "0" ]; then msg "$UNITTEST_NAME: SKIP: ASAN enabled" exit 0 fi } # # require_cxx11 -- continue script execution only if C++11 supporting compiler # is installed # function require_cxx11() { [ "$CXX" ] || CXX=c++ CXX11_AVAILABLE=`echo "int main(){return 0;}" |\ $CXX -std=c++11 -x c++ -o /dev/null - 2>/dev/null &&\ echo y || echo n` if [ "$CXX11_AVAILABLE" == "n" ]; then msg "$UNITTEST_NAME: SKIP: C++11 required" exit 0 fi } # # require_no_asan - continue script execution only if libpmem does NOT require # libasan # function require_no_asan() { case "$BUILD" in debug) require_no_asan_for ../../debug/libpmem.so ;; nondebug) require_no_asan_for ../../nondebug/libpmem.so ;; static-debug) require_no_asan_for ../../debug/libpmem.a ;; static-nondebug) require_no_asan_for ../../nondebug/libpmem.a ;; esac } # # require_tty - continue script execution only if standard output is a terminal # function require_tty() { if ! tty >/dev/null; then msg "$UNITTEST_NAME: SKIP no terminal" exit 0 fi } # # require_binary -- continue script execution only if the binary has been compiled # # In case of conditional compilation, skip this test. # function require_binary() { if [ -z "$1" ]; then fatal "require_binary: error: binary not provided" fi if [ ! -x "$1" ]; then msg "$UNITTEST_NAME: SKIP no binary found" exit 0 fi return } # # require_preload - continue script execution only if supplied # executable does not generate SIGABRT # # Used to check that LD_PRELOAD of, e.g., libvmmalloc is possible # # usage: require_preload <errorstr> <executable> [<exec_args>] # function require_preload() { msg=$1 shift trap SIGABRT disable_exit_on_error ret=$(LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH LD_PRELOAD=$TEST_LD_PRELOAD $* 2>&1 /dev/null) ret=$? restore_exit_on_error if [ $ret == 134 ]; then msg "$UNITTEST_NAME: SKIP: $msg not supported" rm -f $1.core exit 0 fi } # # require_sds -- continue script execution only if binary is compiled with # shutdown state support # # usage: require_sds <binary> # function require_sds() { local binary=$1 local dir=. if [ -z "$binary" ]; then fatal "require_sds: error: no binary found" fi strings ${binary} 2>&1 | \ grep -q "compiled with support for shutdown state" && true if [ $? -ne 0 ]; then msg "$UNITTEST_NAME: SKIP not compiled with support for shutdown state" exit 0 fi return 0 } # # require_no_sds -- continue script execution only if binary is NOT compiled with # shutdown state support # # usage: require_no_sds <binary> # function require_no_sds() { local binary=$1 local dir=. if [ -z "$binary" ]; then fatal "require_sds: error: no binary found" fi set +e found=$(strings ${binary} 2>&1 | \ grep -c "compiled with support for shutdown state") set -e if [ "$found" -ne "0" ]; then msg "$UNITTEST_NAME: SKIP compiled with support for shutdown state" exit 0 fi return 0 } # # check_absolute_path -- continue script execution only if $DIR path is # an absolute path; do not resolve symlinks # function check_absolute_path() { if [ "${DIR:0:1}" != "/" ]; then fatal "Directory \$DIR has to be an absolute path. $DIR was given." fi } # # run_command -- run a command in a verbose or quiet way # function run_command() { local COMMAND="$*" if [ "$VERBOSE" != "0" ]; then echo "$ $COMMAND" $COMMAND else $COMMAND fi } # # validate_node_number -- validate a node number # function validate_node_number() { [ $1 -gt $NODES_MAX ] \ && fatal "error: node number ($1) greater than maximum allowed node number ($NODES_MAX)" return 0 } # # clean_remote_node -- usage: clean_remote_node <node> <list-of-pid-files> # function clean_remote_node() { validate_node_number $1 local N=$1 shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir # register the list of PID files to be cleaned in case of an error NODE_PID_FILES[$N]="${NODE_PID_FILES[$N]} $*" # clean the remote node disable_exit_on_error for pidfile in ${NODE_PID_FILES[$N]}; do require_ctrld_err $N $pidfile run_command ssh $SSH_OPTS ${NODE[$N]} "\ cd $DIR && [ -f $pidfile ] && \ ../ctrld $pidfile kill SIGINT && \ ../ctrld $pidfile wait 1 ; \ rm -f $pidfile" done; restore_exit_on_error return 0 } # # clean_all_remote_nodes -- clean all remote nodes in case of an error # function clean_all_remote_nodes() { msg "$UNITTEST_NAME: CLEAN (cleaning processes on remote nodes)" local N=0 disable_exit_on_error for N in $NODES_SEQ; do local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for pidfile in ${NODE_PID_FILES[$N]}; do run_command ssh $SSH_OPTS ${NODE[$N]} "\ cd $DIR && [ -f $pidfile ] && \ ../ctrld $pidfile kill SIGINT && \ ../ctrld $pidfile wait 1 ; \ rm -f $pidfile" done done restore_exit_on_error return 0 } # # export_vars_node -- export specified variables on specified node # function export_vars_node() { local N=$1 shift validate_node_number $N for var in "$@"; do NODE_ENV[$N]="${NODE_ENV[$N]} $var=${!var}" done } # # require_nodes_libfabric -- only allow script to continue if libfabric with # optionally specified provider is available on # specified node # usage: require_nodes_libfabric <node> <provider> [<libfabric-version>] # function require_node_libfabric() { validate_node_number $1 local N=$1 local provider=$2 # Minimal required version of libfabric. # Keep in sync with requirements in src/common.inc. local version=${3:-1.4.2} require_pkg libfabric "$version" require_node_pkg $N libfabric "$version" if [ "$RPMEM_DISABLE_LIBIBVERBS" != "y" ]; then if ! fi_info --list | grep -q verbs; then msg "$UNITTEST_NAME: SKIP libfabric not compiled with verbs provider" exit 0 fi if ! run_on_node $N "fi_info --list | grep -q verbs"; then msg "$UNITTEST_NAME: SKIP libfabric on node $N not compiled with verbs provider" exit 0 fi fi local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="$COMMAND ${NODE_ENV[$N]}" COMMAND="$COMMAND LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[$N]}" COMMAND="$COMMAND ../fip ${NODE_ADDR[$N]} $provider" disable_exit_on_error fip_out=$(ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && $COMMAND" 2>&1) ret=$? restore_exit_on_error if [ "$ret" == "0" ]; then return elif [ "$ret" == "1" ]; then msg "$UNITTEST_NAME: SKIP NODE $N: $fip_out" exit 0 else fatal "NODE $N: require_libfabric $provider: $fip_out" fi } # # check_if_node_is_reachable -- check if the $1 node is reachable # function check_if_node_is_reachable() { disable_exit_on_error run_command ssh $SSH_OPTS ${NODE[$1]} exit local ret=$? restore_exit_on_error return $ret } # # require_nodes -- only allow script to continue for a certain number # of defined and reachable nodes # # Input arguments: # NODE[] - (required) array of nodes' addresses # NODE_WORKING_DIR[] - (required) array of nodes' working directories # function require_nodes() { local N_NODES=${#NODE[@]} local N=$1 [ -z "$N" ] \ && fatal "require_nodes: missing reguired parameter: number of nodes" # if it has already been called, check if number of required nodes is bigger than previously [ -n "$NODES_MAX" ] \ && [ $(($N - 1)) -le $NODES_MAX ] && return [ $N -gt $N_NODES ] \ && msg "$UNITTEST_NAME: SKIP: requires $N node(s), but $N_NODES node(s) provided" \ && exit 0 NODES_MAX=$(($N - 1)) NODES_SEQ=$(seq -s' ' 0 $NODES_MAX) # check if all required nodes are reachable for N in $NODES_SEQ; do # validate node's address [ "${NODE[$N]}" = "" ] \ && msg "$UNITTEST_NAME: SKIP: address of node #$N is not provided" \ && exit 0 # validate the working directory [ "${NODE_WORKING_DIR[$N]}" = "" ] \ && fatal "error: working directory for node #$N (${NODE[$N]}) is not provided" # check if the node is reachable check_if_node_is_reachable $N [ $? -ne 0 ] \ && fatal "error: node #$N (${NODE[$N]}) is unreachable" # clear the list of PID files for each node NODE_PID_FILES[$N]="" NODE_TEST_DIR[$N]=${NODE_WORKING_DIR[$N]}/$curtestdir NODE_DIR[$N]=${NODE_WORKING_DIR[$N]}/$curtestdir/data/ require_node_log_files $N $ERR_LOG_FILE $OUT_LOG_FILE $TRACE_LOG_FILE if [ "$CHECK_TYPE" != "none" -a "${NODE_VALGRINDEXE[$N]}" = "" ]; then disable_exit_on_error NODE_VALGRINDEXE[$N]=$(ssh $SSH_OPTS ${NODE[$N]} "which valgrind 2>/dev/null") local ret=$? restore_exit_on_error if [ $ret -ne 0 ]; then msg "$UNITTEST_NAME: SKIP valgrind required on remote node #$N" exit 0 fi fi done # remove all log files of the current unit test from the required nodes # and export the 'log' variables to these nodes for N in $NODES_SEQ; do for f in $(get_files "node_${N}.*${UNITTEST_NUM}\.log"); do rm -f $f done export_vars_node $N $REMOTE_VARS done # register function to clean all remote nodes in case of an error or SIGINT trap clean_all_remote_nodes ERR SIGINT return 0 } # # check_files_on_node -- check if specified files exist on given node # function check_files_on_node() { validate_node_number $1 local N=$1 shift local REMOTE_DIR=${NODE_DIR[$N]} run_command ssh $SSH_OPTS ${NODE[$N]} "for f in $*; do if [ ! -f $REMOTE_DIR/\$f ]; then echo \"Missing file \$f on node #$N\" 1>&2; exit 1; fi; done" } # # check_no_files_on_node -- check if specified files does not exist on given node # function check_no_files_on_node() { validate_node_number $1 local N=$1 shift local REMOTE_DIR=${NODE_DIR[$N]} run_command ssh $SSH_OPTS ${NODE[$N]} "for f in $*; do if [ -f $REMOTE_DIR/\$f ]; then echo \"Not deleted file \$f on node #$N\" 1>&2; exit 1; fi; done" } # # copy_files_to_node -- copy all required files to the given remote node # usage: copy_files_to_node <node> <destination dir> <file_1> [<file_2>] ... # function copy_files_to_node() { validate_node_number $1 local N=$1 local DEST_DIR=$2 shift 2 [ $# -eq 0 ] &&\ fatal "error: copy_files_to_node(): no files provided" # copy all required files run_command scp $SCP_OPTS $@ ${NODE[$N]}:$DEST_DIR > /dev/null return 0 } # # copy_files_from_node -- copy all required files from the given remote node # usage: copy_files_from_node <node> <destination_dir> <file_1> [<file_2>] ... # function copy_files_from_node() { validate_node_number $1 local N=$1 local DEST_DIR=$2 [ ! -d $DEST_DIR ] &&\ fatal "error: destination directory $DEST_DIR does not exist" shift 2 [ $# -eq 0 ] &&\ fatal "error: copy_files_from_node(): no files provided" # compress required files, copy and extract local temp_file=node_${N}_temp_file.tar files="" dir_name="" files=$(basename -a $@) dir_name=$(dirname $1) run_command ssh $SSH_OPTS ${NODE[$N]} "cd $dir_name && tar -czf $temp_file $files" run_command scp $SCP_OPTS ${NODE[$N]}:$dir_name/$temp_file $DEST_DIR > /dev/null cd $DEST_DIR \ && tar -xzf $temp_file \ && rm $temp_file \ && cd - > /dev/null return 0 } # # copy_log_files -- copy log files from remote node # function copy_log_files() { local NODE_SCP_LOG_FILES[0]="" for N in $NODES_SEQ; do local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for file in ${NODE_LOG_FILES[$N]}; do NODE_SCP_LOG_FILES[$N]="${NODE_SCP_LOG_FILES[$N]} ${NODE[$N]}:$DIR/${file}" done [ "${NODE_SCP_LOG_FILES[$N]}" ] && run_command scp $SCP_OPTS ${NODE_SCP_LOG_FILES[$N]} . &>> $PREP_LOG_FILE for file in ${NODE_LOG_FILES[$N]}; do [ -f $file ] && mv $file node_${N}_${file} done done } # # rm_files_from_node -- removes all listed files from the given remote node # usage: rm_files_from_node <node> <file_1> [<file_2>] ... # function rm_files_from_node() { validate_node_number $1 local N=$1 shift [ $# -eq 0 ] &&\ fatal "error: rm_files_from_node(): no files provided" run_command ssh $SSH_OPTS ${NODE[$N]} "rm -f $@" return 0 } # # # require_node_log_files -- store log files which must be copied from # specified node on failure # function require_node_log_files() { validate_node_number $1 local N=$1 shift NODE_LOG_FILES[$N]="${NODE_LOG_FILES[$N]} $*" } # # require_ctrld_err -- store ctrld's log files to copy from specified # node on failure # function require_ctrld_err() { local N=$1 local PID_FILE=$2 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir for cmd in run wait kill wait_port; do NODE_LOG_FILES[$N]="${NODE_LOG_FILES[$N]} $PID_FILE.$cmd.ctrld.log" done } # # run_on_node -- usage: run_on_node <node> <command> # # Run the <command> in background on the remote <node>. # LD_LIBRARY_PATH for the n-th remote node can be provided # in the array NODE_LD_LIBRARY_PATH[n] # function run_on_node() { validate_node_number $1 local N=$1 shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="UNITTEST_NUM=$UNITTEST_NUM UNITTEST_NAME=$UNITTEST_NAME" COMMAND="$COMMAND UNITTEST_LOG_LEVEL=1" COMMAND="$COMMAND ${NODE_ENV[$N]}" COMMAND="$COMMAND LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[$N]} $*" run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && $COMMAND" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # run_on_node_background -- usage: # run_on_node_background <node> <pid-file> <command> # # Run the <command> in background on the remote <node> # and create a <pid-file> for this process. # LD_LIBRARY_PATH for the n-th remote node # can be provided in the array NODE_LD_LIBRARY_PATH[n] # function run_on_node_background() { validate_node_number $1 local N=$1 local PID_FILE=$2 shift shift local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local COMMAND="UNITTEST_NUM=$UNITTEST_NUM UNITTEST_NAME=$UNITTEST_NAME" COMMAND="$COMMAND UNITTEST_LOG_LEVEL=1" COMMAND="$COMMAND ${NODE_ENV[$N]}" COMMAND="$COMMAND LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[$N]}" COMMAND="$COMMAND ../ctrld $PID_FILE run $RUNTEST_TIMEOUT $*" # register the PID file to be cleaned in case of an error NODE_PID_FILES[$N]="${NODE_PID_FILES[$N]} $PID_FILE" run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && $COMMAND" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # wait_on_node -- usage: wait_on_node <node> <pid-file> [<timeout>] # # Wait until the process with the <pid-file> on the <node> # exits or <timeout> expires. # function wait_on_node() { validate_node_number $1 local N=$1 local PID_FILE=$2 local TIMEOUT=$3 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && ../ctrld $PID_FILE wait $TIMEOUT" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # wait_on_node_port -- usage: wait_on_node_port <node> <pid-file> <portno> # # Wait until the process with the <pid-file> on the <node> # opens the port <portno>. # function wait_on_node_port() { validate_node_number $1 local N=$1 local PID_FILE=$2 local PORTNO=$3 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && ../ctrld $PID_FILE wait_port $PORTNO" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # kill_on_node -- usage: kill_on_node <node> <pid-file> <signo> # # Send the <signo> signal to the process with the <pid-file> # on the <node>. # function kill_on_node() { validate_node_number $1 local N=$1 local PID_FILE=$2 local SIGNO=$3 local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir run_command ssh $SSH_OPTS ${NODE[$N]} "cd $DIR && ../ctrld $PID_FILE kill $SIGNO" ret=$? if [ "$ret" -ne "0" ]; then copy_log_files fi return $ret } # # create_holey_file_on_node -- create holey files of a given length # usage: create_holey_file_on_node <node> <size> # # example, to create two files, each 1GB in size on node 0: # create_holey_file_on_node 0 1G testfile1 testfile2 # # Input unit size is in bytes with optional suffixes like k, KB, M, etc. # function create_holey_file_on_node() { validate_node_number $1 local N=$1 size=$(convert_to_bytes $2) shift 2 for file in $* do run_on_node $N truncate -s ${size} $file >> $PREP_LOG_FILE done } # # setup -- print message that test setup is commencing # function setup() { DIR=$DIR$SUFFIX export VMMALLOC_POOL_DIR="$DIR" # writes test working directory to temporary file # that allows read location of data after test failure if [ -f "$TEMP_LOC" ]; then echo "$DIR" > $TEMP_LOC fi # test type must be explicitly specified if [ "$req_test_type" != "1" ]; then fatal "error: required test type is not specified" fi # fs type "none" must be explicitly enabled if [ "$FS" = "none" -a "$req_fs_type" != "1" ]; then exit 0 fi # fs type "any" must be explicitly enabled if [ "$FS" = "any" -a "$req_fs_type" != "1" ]; then exit 0 fi if [ "$CHECK_TYPE" != "none" ]; then require_valgrind export VALGRIND_LOG_FILE=$CHECK_TYPE${UNITTEST_NUM}.log MCSTR="/$CHECK_TYPE" else MCSTR="" fi [ -n "$RPMEM_PROVIDER" ] && PROV="/$RPMEM_PROVIDER" [ -n "$RPMEM_PM" ] && PM="/$RPMEM_PM" msg "$UNITTEST_NAME: SETUP ($TEST/$REAL_FS/$BUILD$MCSTR$PROV$PM)" for f in $(get_files ".*[a-zA-Z_]${UNITTEST_NUM}\.log"); do rm -f $f done # $DIR has to be an absolute path check_absolute_path if [ "$FS" != "none" ]; then if [ -d "$DIR" ]; then rm $RM_ONEFS -rf -- $DIR fi mkdir -p $DIR fi if [ "$TM" = "1" ]; then start_time=$($DATE +%s.%N) fi if [ "$DEVDAX_TO_LOCK" == 1 ]; then lock_devdax fi } # # check_log_empty -- if match file does not exist, assume log should be empty # function check_log_empty() { if [ ! -f ${1}.match ] && [ $(get_size $1) -ne 0 ]; then echo "unexpected output in $1" dump_last_n_lines $1 exit 1 fi } # # check_local -- check local test results (using .match files) # function check_local() { if [ "$UT_SKIP_PRINT_MISMATCHED" == 1 ]; then option=-q fi check_log_empty $ERR_LOG_FILE FILES=$(get_files "[^0-9w]*${UNITTEST_NUM}\.log\.match") if [ -n "$FILES" ]; then ../match $option $FILES fi } # # match -- execute match # function match() { ../match $@ } # # check -- check local or remote test results (using .match files) # function check() { if [ $NODES_MAX -lt 0 ]; then check_local else FILES=$(get_files "node_[0-9]+_[^0-9w]*${UNITTEST_NUM}\.log\.match") local NODE_MATCH_FILES[0]="" local NODE_SCP_MATCH_FILES[0]="" for file in $FILES; do local N=`echo $file | cut -d"_" -f2` local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir local FILE=`echo $file | cut -d"_" -f3 | sed "s/\.match$//g"` validate_node_number $N NODE_MATCH_FILES[$N]="${NODE_MATCH_FILES[$N]} $FILE" NODE_SCP_MATCH_FILES[$N]="${NODE_SCP_MATCH_FILES[$N]} ${NODE[$N]}:$DIR/$FILE" done for N in $NODES_SEQ; do [ "${NODE_SCP_MATCH_FILES[$N]}" ] && run_command scp $SCP_OPTS ${NODE_SCP_MATCH_FILES[$N]} . > /dev/null for file in ${NODE_MATCH_FILES[$N]}; do mv $file node_${N}_${file} done done if [ "$UT_SKIP_PRINT_MISMATCHED" == 1 ]; then option=-q fi for N in $NODES_SEQ; do check_log_empty node_${N}_${ERR_LOG_FILE} done if [ -n "$FILES" ]; then match $option $FILES fi fi } # # pass -- print message that the test has passed # function pass() { if [ "$DEVDAX_TO_LOCK" == 1 ]; then unlock_devdax fi if [ "$TM" = "1" ]; then end_time=$($DATE +%s.%N) start_time_sec=$($DATE -d "0 $start_time sec" +%s) end_time_sec=$($DATE -d "0 $end_time sec" +%s) days=$(((end_time_sec - start_time_sec) / (24*3600))) days=$(printf "%03d" $days) tm=$($DATE -d "0 $end_time sec - $start_time sec" +%H:%M:%S.%N) tm=$(echo "$days:$tm" | sed -e "s/^000://g" -e "s/^00://g" -e "s/^00://g" -e "s/\([0-9]*\)\.\([0-9][0-9][0-9]\).*/\1.\2/") tm="\t\t\t[$tm s]" else tm="" fi msg="PASS" [ -t 1 ] && command -v tput >/dev/null && msg="$(tput setaf 2)$msg$(tput sgr0)" if [ "$UNITTEST_LOG_LEVEL" -ge 1 ]; then echo -e "$UNITTEST_NAME: $msg$tm" fi if [ "$FS" != "none" ]; then rm $RM_ONEFS -rf -- $DIR fi } # Length of pool file's signature SIG_LEN=8 # Offset and length of pmemobj layout LAYOUT_OFFSET=4096 LAYOUT_LEN=1024 # Length of arena's signature ARENA_SIG_LEN=16 # Signature of BTT Arena ARENA_SIG="BTT_ARENA_INFO" # Offset to first arena ARENA_OFF=8192 # # check_file -- check if file exists and print error message if not # check_file() { if [ ! -f $1 ] then fatal "Missing file: ${1}" fi } # # check_files -- check if files exist and print error message if not # check_files() { for file in $* do check_file $file done } # # check_no_file -- check if file has been deleted and print error message if not # check_no_file() { if [ -f $1 ] then fatal "Not deleted file: ${1}" fi } # # check_no_files -- check if files has been deleted and print error message if not # check_no_files() { for file in $* do check_no_file $file done } # # get_size -- return size of file (0 if file does not exist) # get_size() { if [ ! -f $1 ]; then echo "0" else stat $STAT_SIZE $1 fi } # # get_mode -- return mode of file # get_mode() { stat $STAT_MODE $1 } # # check_size -- validate file size # check_size() { local size=$1 local file=$2 local file_size=$(get_size $file) if [[ $size != $file_size ]] then fatal "error: wrong size ${file_size} != ${size}" fi } # # check_mode -- validate file mode # check_mode() { local mode=$1 local file=$2 local file_mode=$(get_mode $file) if [[ $mode != $file_mode ]] then fatal "error: wrong mode ${file_mode} != ${mode}" fi } # # check_signature -- check if file contains specified signature # check_signature() { local sig=$1 local file=$2 local file_sig=$($DD if=$file bs=1 count=$SIG_LEN 2>/dev/null | tr -d \\0) if [[ $sig != $file_sig ]] then fatal "error: $file: signature doesn't match ${file_sig} != ${sig}" fi } # # check_signatures -- check if multiple files contain specified signature # check_signatures() { local sig=$1 shift 1 for file in $* do check_signature $sig $file done } # # check_layout -- check if pmemobj pool contains specified layout # check_layout() { local layout=$1 local file=$2 local file_layout=$($DD if=$file bs=1\ skip=$LAYOUT_OFFSET count=$LAYOUT_LEN 2>/dev/null | tr -d \\0) if [[ $layout != $file_layout ]] then fatal "error: layout doesn't match ${file_layout} != ${layout}" fi } # # check_arena -- check if file contains specified arena signature # check_arena() { local file=$1 local sig=$($DD if=$file bs=1 skip=$ARENA_OFF count=$ARENA_SIG_LEN 2>/dev/null | tr -d \\0) if [[ $sig != $ARENA_SIG ]] then fatal "error: can't find arena signature" fi } # # dump_pool_info -- dump selected pool metadata and/or user data # function dump_pool_info() { # ignore selected header fields that differ by definition ${PMEMPOOL}.static-nondebug info $* | sed -e "/^UUID/,/^Checksum/d" } # # compare_replicas -- check replicas consistency by comparing `pmempool info` output # function compare_replicas() { disable_exit_on_error diff <(dump_pool_info $1 $2) <(dump_pool_info $1 $3) -I "^path" -I "^size" restore_exit_on_error } # # get_node_dir -- returns node dir for current test # usage: get_node_dir <node> # function get_node_dir() { validate_node_number $1 echo ${NODE_WORKING_DIR[$1]}/$curtestdir } # # init_rpmem_on_node -- prepare rpmem environment variables on node # usage: init_rpmem_on_node <master-node> <slave-node-1> [<slave-node-2> ...] # # example: # The following command initialize rpmem environment variables on the node 1 # to perform replication to node 0, node 2 and node 3. # Additionally: # - on node 2 rpmemd pid will be stored in file.pid # - on node 3 no pid file will be created (SKIP) and rpmemd will use # file.conf config file # # init_rpmem_on_node 1 0 2:file.pid 3:SKIP:file.conf # function init_rpmem_on_node() { local master=$1 shift validate_node_number $master case "$RPMEM_PM" in APM|GPSPM) ;; *) msg "$UNITTEST_NAME: SKIP required: RPMEM_PM is invalid or empty" exit 0 ;; esac # Workaround for SIGSEGV in the infinipath-psm during abort # The infinipath-psm is registering a signal handler and do not unregister # it when rpmem handle is dlclosed. SIGABRT (potentially any other signal) # would try to call the signal handler which does not exist after dlclose. # Issue require a fix in the infinipath-psm or the libfabric. IPATH_NO_BACKTRACE=1 export_vars_node $master IPATH_NO_BACKTRACE RPMEM_CMD="" local SEPARATOR="|" for slave in "$@" do slave=(${slave//:/ }) conf=${slave[2]} pid=${slave[1]} slave=${slave[0]} validate_node_number $slave local poolset_dir=${NODE_DIR[$slave]} if [ -n "${RPMEM_POOLSET_DIR[$slave]}" ]; then poolset_dir=${RPMEM_POOLSET_DIR[$slave]} fi local trace= if [ -n "$(is_valgrind_enabled_on_node $slave)" ]; then log_file=${CHECK_TYPE}${UNITTEST_NUM}.log trace=$(get_trace $CHECK_TYPE $log_file $slave) fi if [ -n "$pid" -a "$pid" != "SKIP" ]; then trace="$trace ../ctrld $pid exe" fi if [ -n ${UNITTEST_DO_NOT_CHECK_OPEN_FILES+x} ]; then export_vars_node $slave UNITTEST_DO_NOT_CHECK_OPEN_FILES fi if [ -n ${IPATH_NO_BACKTRACE+x} ]; then export_vars_node $slave IPATH_NO_BACKTRACE fi CMD="cd ${NODE_TEST_DIR[$slave]} && " # Force pmem for APM. Otherwise in case of lack of a pmem rpmemd will # silently fallback to GPSPM. [ "$RPMEM_PM" == "APM" ] && CMD="$CMD PMEM_IS_PMEM_FORCE=1" CMD="$CMD ${NODE_ENV[$slave]}" CMD="$CMD LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[$slave]}" CMD="$CMD $trace ../rpmemd" CMD="$CMD --log-file=$RPMEMD_LOG_FILE" CMD="$CMD --log-level=$RPMEMD_LOG_LEVEL" CMD="$CMD --poolset-dir=$poolset_dir" if [ -n "$conf" ]; then CMD="$CMD --config=$conf" fi if [ "$RPMEM_PM" == "APM" ]; then CMD="$CMD --persist-apm" fi if [ "$RPMEM_CMD" ]; then RPMEM_CMD="$RPMEM_CMD$SEPARATOR$CMD" else RPMEM_CMD=$CMD fi require_node_log_files $slave rpmemd$UNITTEST_NUM.log done RPMEM_CMD="\"$RPMEM_CMD\"" RPMEM_ENABLE_SOCKETS=0 RPMEM_ENABLE_VERBS=0 case "$RPMEM_PROVIDER" in sockets) RPMEM_ENABLE_SOCKETS=1 ;; verbs) RPMEM_ENABLE_VERBS=1 ;; *) msg "$UNITTEST_NAME: SKIP required: RPMEM_PROVIDER is invalid or empty" exit 0 ;; esac export_vars_node $master RPMEM_CMD export_vars_node $master RPMEM_ENABLE_SOCKETS export_vars_node $master RPMEM_ENABLE_VERBS if [ -n ${UNITTEST_DO_NOT_CHECK_OPEN_FILES+x} ]; then export_vars_node $master UNITTEST_DO_NOT_CHECK_OPEN_FILES fi if [ -n ${PMEMOBJ_NLANES+x} ]; then export_vars_node $master PMEMOBJ_NLANES fi if [ -n ${RPMEM_MAX_NLANES+x} ]; then export_vars_node $master RPMEM_MAX_NLANES fi require_node_log_files $master rpmem$UNITTEST_NUM.log require_node_log_files $master $PMEMOBJ_LOG_FILE } # # init_valgrind_on_node -- prepare valgrind on nodes # usage: init_valgrind_on_node <node list> # function init_valgrind_on_node() { # When librpmem is preloaded libfabric does not close all opened files # before list of opened files is checked. local UNITTEST_DO_NOT_CHECK_OPEN_FILES=1 local LD_PRELOAD=../$BUILD/librpmem.so CHECK_NODES="" for node in "$@" do validate_node_number $node export_vars_node $node LD_PRELOAD export_vars_node $node UNITTEST_DO_NOT_CHECK_OPEN_FILES CHECK_NODES="$CHECK_NODES $node" done } # # is_valgrind_enabled_on_node -- echo the node number if the node has # initialized valgrind environment by calling # init_valgrind_on_node # usage: is_valgrind_enabled_on_node <node> # function is_valgrind_enabled_on_node() { for node in $CHECK_NODES do if [ "$node" -eq "$1" ]; then echo $1 return fi done return } # # pack_all_libs -- put all libraries and their links to one tarball # function pack_all_libs() { local LIBS_TAR_DIR=$(pwd)/$1 cd $DIR_SRC tar -cf $LIBS_TAR_DIR ./debug/*.so* ./nondebug/*.so* cd - > /dev/null } # # copy_common_to_remote_nodes -- copy common files to all remote nodes # function copy_common_to_remote_nodes() { local NODES_ALL_MAX=$((${#NODE[@]} - 1)) local NODES_ALL_SEQ=$(seq -s' ' 0 $NODES_ALL_MAX) DIR_SYNC=$1 if [ "$DIR_SYNC" != "" ]; then [ ! -d $DIR_SYNC ] \ && fatal "error: $DIR_SYNC does not exist or is not a directory" fi # add all libraries to the 'to-copy' list local LIBS_TAR=libs.tar pack_all_libs $LIBS_TAR if [ "$DIR_SYNC" != "" -a "$(ls $DIR_SYNC)" != "" ]; then FILES_COMMON_DIR="$DIR_SYNC/* $LIBS_TAR" else FILES_COMMON_DIR="$FILES_COMMON_DIR $LIBS_TAR" fi for N in $NODES_ALL_SEQ; do # validate node's address [ "${NODE[$N]}" = "" ] \ && fatal "error: address of node #$N is not provided" check_if_node_is_reachable $N [ $? -ne 0 ] \ && msg "warning: node #$N (${NODE[$N]}) is unreachable, skipping..." \ && continue # validate the working directory [ "${NODE_WORKING_DIR[$N]}" = "" ] \ && msg ": warning: working directory for node #$N (${NODE[$N]}) is not provided, skipping..." \ && continue # create the working dir if it does not exist run_command ssh $SSH_OPTS ${NODE[$N]} "mkdir -p ${NODE_WORKING_DIR[$N]}" # copy all common files run_command scp $SCP_OPTS $FILES_COMMON_DIR ${NODE[$N]}:${NODE_WORKING_DIR[$N]} > /dev/null # unpack libraries run_command ssh $SSH_OPTS ${NODE[$N]} "cd ${NODE_WORKING_DIR[$N]} \ && tar -xf $LIBS_TAR && rm -f $LIBS_TAR" done rm -f $LIBS_TAR } # # copy_test_to_remote_nodes -- copy all unit test binaries to all remote nodes # function copy_test_to_remote_nodes() { local NODES_ALL_MAX=$((${#NODE[@]} - 1)) local NODES_ALL_SEQ=$(seq -s' ' 0 $NODES_ALL_MAX) for N in $NODES_ALL_SEQ; do # validate node's address [ "${NODE[$N]}" = "" ] \ && fatal "error: address of node #$N is not provided" check_if_node_is_reachable $N [ $? -ne 0 ] \ && msg "warning: node #$N (${NODE[$N]}) is unreachable, skipping..." \ && continue # validate the working directory [ "${NODE_WORKING_DIR[$N]}" = "" ] \ && msg ": warning: working directory for node #$N (${NODE[$N]}) is not provided, skipping..." \ && continue local DIR=${NODE_WORKING_DIR[$N]}/$curtestdir # create a new test dir run_command ssh $SSH_OPTS ${NODE[$N]} "rm -rf $DIR && mkdir -p $DIR" # create the working data dir run_command ssh $SSH_OPTS ${NODE[$N]} "mkdir -p \ ${DIR}/data" # copy all required files [ $# -gt 0 ] && run_command scp $SCP_OPTS $* ${NODE[$N]}:$DIR > /dev/null done return 0 } # # enable_log_append -- turn on appending to the log files rather than truncating them # It also removes all log files created by tests: out*.log, err*.log and trace*.log # function enable_log_append() { rm -f $OUT_LOG_FILE rm -f $ERR_LOG_FILE rm -f $TRACE_LOG_FILE export UNITTEST_LOG_APPEND=1 } # clean data directory on all remote # nodes if remote test failed if [ "$CLEAN_FAILED_REMOTE" == "y" ]; then NODES_ALL=$((${#NODE[@]} - 1)) MYPID=$$ for ((i=0;i<=$NODES_ALL;i++)); do if [[ -z "${NODE_WORKING_DIR[$i]}" || -z "$curtestdir" ]]; then echo "Invalid path to tests data: ${NODE_WORKING_DIR[$i]}/$curtestdir/data/" exit 1 fi N[$i]=${NODE_WORKING_DIR[$i]}/$curtestdir/data/ run_command ssh $SSH_OPTS ${NODE[$i]} "rm -rf ${N[$i]}; mkdir ${N[$i]}" if [ $? -eq 0 ]; then verbose_msg "Removed data from: ${NODE[$i]}:${N[$i]}" fi done exit 0 fi # calculate the minimum of two or more numbers minimum() { local min=$1 shift for val in $*; do if [[ "$val" < "$min" ]]; then min=$val fi done echo $min } # # count_lines - count number of lines that match pattern $1 in file $2 # function count_lines() { # grep returns 1 on no match disable_exit_on_error $GREP -ce "$1" $2 restore_exit_on_error } # # get_pmemcheck_version() - return pmemcheck API major or minor version # usage: get_pmemcheck_version <0|1> # function get_pmemcheck_version() { PMEMCHECK_VERSION=$($VALGRINDEXE --tool=pmemcheck true 2>&1 \ | head -n 1 | sed "s/.*-\([0-9.]*\),.*/\1/") OIFS=$IFS IFS="." PMEMCHECK_MAJ_MIN=($PMEMCHECK_VERSION) IFS=$OIFS PMEMCHECK_VERSION_PART=${PMEMCHECK_MAJ_MIN[$1]} echo "$PMEMCHECK_VERSION_PART" } # # require_pmemcheck_version_ge - check if pmemcheck API # version is greater or equal to required value # usage: require_pmemcheck_version_ge <major> <minor> # function require_pmemcheck_version_ge() { require_valgrind_tool pmemcheck REQUIRE_MAJOR=$1 REQUIRE_MINOR=$2 PMEMCHECK_MAJOR=$(get_pmemcheck_version 0) PMEMCHECK_MINOR=$(get_pmemcheck_version 1) # compare MAJOR if [ $PMEMCHECK_MAJOR -gt $REQUIRE_MAJOR ]; then return 0 fi # compare MINOR if [ $PMEMCHECK_MAJOR -eq $REQUIRE_MAJOR ]; then if [ $PMEMCHECK_MINOR -ge $REQUIRE_MINOR ]; then return 0 fi fi msg "$UNITTEST_NAME: SKIP pmemcheck API version:" \ "$PMEMCHECK_MAJOR.$PMEMCHECK_MINOR" \ "is less than required" \ "$REQUIRE_MAJOR.$REQUIRE_MINOR" exit 0 } # # require_pmemcheck_version_lt - check if pmemcheck API # version is less than required value # usage: require_pmemcheck_version_lt <major> <minor> # function require_pmemcheck_version_lt() { require_valgrind_tool pmemcheck REQUIRE_MAJOR=$1 REQUIRE_MINOR=$2 PMEMCHECK_MAJOR=$(get_pmemcheck_version 0) PMEMCHECK_MINOR=$(get_pmemcheck_version 1) # compare MAJOR if [ $PMEMCHECK_MAJOR -lt $REQUIRE_MAJOR ]; then return 0 fi # compare MINOR if [ $PMEMCHECK_MAJOR -eq $REQUIRE_MAJOR ]; then if [ $PMEMCHECK_MINOR -lt $REQUIRE_MINOR ]; then return 0 fi fi msg "$UNITTEST_NAME: SKIP pmemcheck API version:" \ "$PMEMCHECK_MAJOR.$PMEMCHECK_MINOR" \ "is greater or equal than" \ "$REQUIRE_MAJOR.$REQUIRE_MINOR" exit 0 } # # require_python_3 -- check if python3 is available # function require_python3() { if hash python3 &>/dev/null; then PYTHON_EXE=python3 else PYTHON_EXE=python fi case "$($PYTHON_EXE --version 2>&1)" in *" 3."*) return ;; *) msg "$UNITTEST_NAME: SKIP: required python version 3" exit 0 ;; esac } # # require_pmreorder -- check all necessarily conditions to run pmreorder # function require_pmreorder() { # python3 and valgrind are necessary require_python3 # pmemcheck is required to generate store_log configure_valgrind pmemcheck force-enable # pmreorder tool does not support unicode yet require_no_unicode } # # pmreorder_run_tool -- run pmreorder with parameters and return exit status # # 1 - reorder engine type [nochecker|full|noreorder|partial|accumulative] # 2 - marker-engine pairs in format: MARKER=ENGINE,MARKER1=ENGINE1 or # config file in json format: { "MARKER":"ENGINE","MARKER1":"ENGINE1" } # 3 - the path to the checker binary/library and remaining parameters which # will be passed to the consistency checker binary. # If you are using a library checker, prepend '-n funcname' # function pmreorder_run_tool() { rm -f pmreorder$UNITTEST_NUM.log disable_exit_on_error LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH $PYTHON_EXE $PMREORDER \ -l store_log$UNITTEST_NUM.log \ -o pmreorder$UNITTEST_NUM.log \ -r $1 \ -x $2 \ -p "$3" ret=$? restore_exit_on_error echo $ret } # # pmreorder_expect_success -- run pmreoreder with forwarded parameters, # expect it to exit zero # function pmreorder_expect_success() { ret=$(pmreorder_run_tool "$@") if [ "$ret" -ne "0" ]; then msg="failed with exit code $ret" [ -t 2 ] && command -v tput >/dev/null && msg="$(tput setaf 1)$msg$(tput sgr0)" # exit code 130 - script terminated by user (Control-C) if [ "$ret" -ne "130" ]; then echo -e "$UNITTEST_NAME $msg." >&2 dump_last_n_lines $PMREORDER_LOG_FILE fi false fi } # # pmreorder_expect_failure -- run pmreoreder with forwarded parameters, # expect it to exit non zero # function pmreorder_expect_failure() { ret=$(pmreorder_run_tool "$@") if [ "$ret" -eq "0" ]; then msg="succeeded" [ -t 2 ] && command -v tput >/dev/null && msg="$(tput setaf 1)$msg$(tput sgr0)" echo -e "$UNITTEST_NAME command $msg unexpectedly." >&2 false fi } # # pmreorder_create_store_log -- perform a reordering test # # This function expects 5 additional parameters. They are in order: # 1 - the pool file to be tested # 2 - the application and necessary parameters to run pmemcheck logging # function pmreorder_create_store_log() { #copy original file and perform store logging cp $1 "$1.pmr" rm -f store_log$UNITTEST_NUM.log LD_LIBRARY_PATH=$TEST_LD_LIBRARY_PATH $VALGRINDEXE \ --tool=pmemcheck -q \ --log-stores=yes \ --print-summary=no \ --log-file=store_log$UNITTEST_NUM.log \ --log-stores-stacktraces=yes \ --log-stores-stacktraces-depth=2 \ --expect-fence-after-clflush=yes \ $2 # uncomment this line for debug purposes # mv $1 "$1.bak" mv "$1.pmr" $1 } # # require_free_space -- check if there is enough free space to run the test # Example, checking if there is 1 GB of free space on disk: # require_free_space 1G # function require_free_space() { req_free_space=$(convert_to_bytes $1) output=$(df -k $DIR) found=false i=1 for elem in $(echo "$output" | head -1); do if [ ${elem:0:5} == "Avail" ]; then found=true break else let "i+=1" fi done if [ $found = true ]; then row=$(echo "$output" | tail -1) free_space=$(( $(echo $row | awk "{print \$$i}")*1024 )) else msg "$UNITTEST_NAME: SKIP: unable to check free space" exit 0 fi if [ $free_space -lt $req_free_space ]; then msg "$UNITTEST_NAME: SKIP: not enough free space" exit 0 fi } # # require_nfit_tests_enabled - check if tests using the nfit_test kernel module are not enabled # function require_nfit_tests_enabled() { if [ "$ENABLE_NFIT_TESTS" != "y" ]; then msg "$UNITTEST_NAME: SKIP: tests using the nfit_test kernel module are not enabled in testconfig.sh" exit 0 fi } # # create_recovery_file - create bad block recovery file # # Usage: create_recovery_file <file> [<offset_1> <length_1> ...] # function create_recovery_file() { [ $# -lt 1 ] && fatal "create_recovery_file(): not enough parameters: $*" FILE=$1 shift rm -f $FILE while [ $# -ge 2 ]; do OFFSET=$1 LENGTH=$2 shift 2 echo "$(($OFFSET * 512)) $(($LENGTH * 512))" >> $FILE done # write the finish flag echo "0 0" >> $FILE } # # zero_blocks - zero blocks in a file # # Usage: zero_blocks <file> <offset> <length> # function zero_blocks() { [ $# -lt 3 ] && fatal "zero_blocks(): not enough parameters: $*" FILE=$1 shift while [ $# -ge 2 ]; do OFFSET=$1 LENGTH=$2 shift 2 dd if=/dev/zero of=$FILE bs=512 seek=$OFFSET count=$LENGTH conv=notrunc status=none done } # # turn_on_checking_bad_blocks -- set the compat_feature POOL_FEAT_CHECK_BAD_BLOCKS on # function turn_on_checking_bad_blocks() { FILE=$1 expect_normal_exit "$PMEMPOOL feature -e CHECK_BAD_BLOCKS $FILE &>> $PREP_LOG_FILE" } # # turn_on_checking_bad_blocks_node -- set the compat_feature POOL_FEAT_CHECK_BAD_BLOCKS on # function turn_on_checking_bad_blocks_node() { FILE=$2 expect_normal_exit run_on_node $1 "../pmempool feature -e CHECK_BAD_BLOCKS $FILE &>> $PREP_LOG_FILE" }
88,034
24.031277
153
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_memblock/mocks_windows.h
/* * Copyright 2016, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of memops functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_memblock test. * It would replace default implementation with mocked functions defined * in obj_memblock.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define operation_add_typed_entry __wrap_operation_add_typed_entry #define operation_add_entry __wrap_operation_add_entry #endif
2,149
42
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_sds/mocks_windows.h
/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of dimm functions */ #ifndef WRAP_REAL #define os_dimm_usc __wrap_os_dimm_usc #define os_dimm_uid __wrap_os_dimm_uid #endif
1,762
42
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/util_sds/mocks_windows.h
/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of dimm functions */ #ifndef WRAP_REAL #define os_dimm_usc __wrap_os_dimm_usc #define os_dimm_uid __wrap_os_dimm_uid #endif
1,762
42
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_tx_add_range/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # obj_tx_add_range/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
1,767
41.095238
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmem_has_auto_flush_win/mocks_windows.h
/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of EnumSystemFirmwareTables and * GetSystemFirmwareTable * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of pmem_has_auto_flush_win test. * It would replace default implementation with mocked functions defined * in mocks_windows.c * * This WRAP_REAL define could be also passed as preprocessor definition. */ #include <windows.h> #ifndef WRAP_REAL #define EnumSystemFirmwareTables __wrap_EnumSystemFirmwareTables #define GetSystemFirmwareTable __wrap_GetSystemFirmwareTable UINT __wrap_EnumSystemFirmwareTables(DWORD FirmwareTableProviderSignature, PVOID pFirmwareTableEnumBuffer, DWORD BufferSize); UINT __wrap_GetSystemFirmwareTable(DWORD FirmwareTableProviderSignature, DWORD FirmwareTableID, PVOID pFirmwareTableBuffer, DWORD BufferSize); #endif
2,503
42.172414
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmem_has_auto_flush_win/pmem_has_auto_flush_win.h
/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * pmem_has_auto_flush_win.h -- header file for windows mocks * for pmem_has_auto_flush_win */ #ifndef PMDK_HAS_AUTO_FLUSH_WIN_H #define PMDK_HAS_AUTO_FLUSH_WIN_H 1 extern size_t Is_nfit; extern size_t Pc_type; extern size_t Pc_capabilities; #endif
1,853
40.2
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/vmmalloc_dummy_funcs/vmmalloc_dummy_funcs.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * vmmalloc_weakfuncs.h -- definitions for vmmalloc tests */ #ifndef VMMALLOC_WEAKFUNCS_H #define VMMALLOC_WEAKFUNCS_H #include <stddef.h> #ifndef __FreeBSD__ #include <malloc.h> #endif void *aligned_alloc(size_t alignment, size_t size); #ifdef __FreeBSD__ void *memalign(size_t boundary, size_t size); void *pvalloc(size_t size); /* XXX These exist only to allow the tests to compile - they are never used */ extern void (*__free_hook)(void *, const void *); extern void *(*__malloc_hook)(size_t size, const void *); extern void *(*__memalign_hook)(size_t alignment, size_t size, const void *); extern void *(*__realloc_hook)(void *ptr, size_t size, const void *); #endif #endif
2,292
37.864407
78
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_heap_interrupt/mocks_windows.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of memops functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_heap_interrupt test. * It would replace default implementation with mocked functions defined * in obj_heap_interrupt.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define operation_finish __wrap_operation_finish #endif
2,093
41.734694
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_list/mocks_windows.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of obj list functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_list test. * It would replace default implementation with mocked functions defined * in obj_list.c. * * These defines could be also passed as preprocessor definitions. */ #if defined(__cplusplus) extern "C" { #endif #ifdef WRAP_REAL #define WRAP_REAL_PMALLOC #define WRAP_REAL_ULOG #define WRAP_REAL_LANE #define WRAP_REAL_HEAP #define WRAP_REAL_PMEMOBJ #endif #ifndef WRAP_REAL_PMALLOC #define pmalloc __wrap_pmalloc #define pfree __wrap_pfree #define pmalloc_construct __wrap_pmalloc_construct #define prealloc __wrap_prealloc #define prealloc_construct __wrap_prealloc_construct #define palloc_usable_size __wrap_palloc_usable_size #define palloc_reserve __wrap_palloc_reserve #define palloc_publish __wrap_palloc_publish #define palloc_defer_free __wrap_palloc_defer_free #endif #ifndef WRAP_REAL_ULOG #define ulog_store __wrap_ulog_store #define ulog_process __wrap_ulog_process #endif #ifndef WRAP_REAL_LANE #define lane_hold __wrap_lane_hold #define lane_release __wrap_lane_release #define lane_recover_and_section_boot __wrap_lane_recover_and_section_boot #define lane_section_cleanup __wrap_lane_section_cleanup #endif #ifndef WRAP_REAL_HEAP #define heap_boot __wrap_heap_boot #endif #ifndef WRAP_REAL_PMEMOBJ #define pmemobj_alloc __wrap_pmemobj_alloc #define pmemobj_alloc_usable_size __wrap_pmemobj_alloc_usable_size #define pmemobj_openU __wrap_pmemobj_open #define pmemobj_close __wrap_pmemobj_close #define pmemobj_direct __wrap_pmemobj_direct #define pmemobj_pool_by_oid __wrap_pmemobj_pool_by_oid #define pmemobj_pool_by_ptr __wrap_pmemobj_pool_by_ptr #endif #if defined(__cplusplus) } #endif
3,448
33.838384
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_list/obj_list.h
/* * Copyright 2015-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * obj_list.h -- unit tests for list module */ #include <stddef.h> #include <sys/param.h> #include "list.h" #include "obj.h" #include "lane.h" #include "unittest.h" #include "util.h" /* offset to "in band" item */ #define OOB_OFF (sizeof(struct oob_header)) /* pmemobj initial heap offset */ #define HEAP_OFFSET 8192 TOID_DECLARE(struct item, 0); TOID_DECLARE(struct list, 1); TOID_DECLARE(struct oob_list, 2); TOID_DECLARE(struct oob_item, 3); struct item { int id; POBJ_LIST_ENTRY(struct item) next; }; struct oob_header { char data[48]; }; struct oob_item { struct oob_header oob; struct item item; }; struct oob_list { struct list_head head; }; struct list { POBJ_LIST_HEAD(listhead, struct item) head; }; enum ulog_fail { /* don't fail at all */ NO_FAIL, /* fail after ulog_store */ FAIL_AFTER_FINISH, /* fail before ulog_store */ FAIL_BEFORE_FINISH, /* fail after process */ FAIL_AFTER_PROCESS }; /* global handle to pmemobj pool */ extern PMEMobjpool *Pop; /* pointer to heap offset */ extern uint64_t *Heap_offset; /* list lane section */ extern struct lane Lane; /* actual item id */ extern int *Id; /* fail event */ extern enum ulog_fail Ulog_fail; /* global "in band" lists */ extern TOID(struct list) List; extern TOID(struct list) List_sec; /* global "out of band" lists */ extern TOID(struct oob_list) List_oob; extern TOID(struct oob_list) List_oob_sec; extern TOID(struct oob_item) *Item; /* usage macros */ #define FATAL_USAGE()\ UT_FATAL("usage: obj_list <file> [PRnifr]") #define FATAL_USAGE_PRINT()\ UT_FATAL("usage: obj_list <file> P:<list>") #define FATAL_USAGE_PRINT_REVERSE()\ UT_FATAL("usage: obj_list <file> R:<list>") #define FATAL_USAGE_INSERT()\ UT_FATAL("usage: obj_list <file> i:<where>:<num>") #define FATAL_USAGE_INSERT_NEW()\ UT_FATAL("usage: obj_list <file> n:<where>:<num>:<value>") #define FATAL_USAGE_REMOVE_FREE()\ UT_FATAL("usage: obj_list <file> f:<list>:<num>:<from>") #define FATAL_USAGE_REMOVE()\ UT_FATAL("usage: obj_list <file> r:<num>") #define FATAL_USAGE_MOVE()\ UT_FATAL("usage: obj_list <file> m:<num>:<where>:<num>") #define FATAL_USAGE_FAIL()\ UT_FATAL("usage: obj_list <file> "\ "F:<after_finish|before_finish|after_process>")
3,829
28.015152
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/blk_rw_mt/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # blk_rw_mt/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
1,760
40.928571
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_persist_count/mocks_windows.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of pmem functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_persist_count test. * It would replace default implementation with mocked functions defined * in obj_persist_count.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define pmem_persist __wrap_pmem_persist #define pmem_flush __wrap_pmem_flush #define pmem_drain __wrap_pmem_drain #define pmem_msync __wrap_pmem_msync #define pmem_memcpy_persist __wrap_pmem_memcpy_persist #define pmem_memcpy_nodrain __wrap_pmem_memcpy_nodrain #define pmem_memcpy __wrap_pmem_memcpy #define pmem_memmove_persist __wrap_pmem_memmove_persist #define pmem_memmove_nodrain __wrap_pmem_memmove_nodrain #define pmem_memmove __wrap_pmem_memmove #define pmem_memset_persist __wrap_pmem_memset_persist #define pmem_memset_nodrain __wrap_pmem_memset_nodrain #define pmem_memset __wrap_pmem_memset #endif
2,645
42.377049
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/compat_incompat_features/common.sh
#!/usr/bin/env bash # # Copyright 2017-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # compat_incompat_features/common.sh -- common stuff for compat/incompat feature # flags tests # ERR=err${UNITTEST_NUM}.log ERR_TEMP=err${UNITTEST_NUM}_part.log LOG=out${UNITTEST_NUM}.log LOG_TEMP=out${UNITTEST_NUM}_part.log rm -f $LOG && touch $LOG rm -f $LOG_TEMP && touch $LOG_TEMP rm -f $ERR && touch $ERR rm -f $ERR_TEMP && touch $ERR_TEMP LAYOUT=OBJ_LAYOUT$SUFFIX POOLSET=$DIR/pool.set POOL_TYPES=(obj blk log cto) # pmempool create arguments: declare -A create_args create_args[obj]="obj $POOLSET" create_args[blk]="blk 512 $POOLSET" create_args[log]="log $POOLSET" create_args[cto]="cto $POOLSET" # Known compat flags: # Known incompat flags: let "POOL_FEAT_SINGLEHDR = 0x0001" let "POOL_FEAT_CKSUM_2K = 0x0002" let "POOL_FEAT_SDS = 0x0004" # Unknown compat flags: UNKNOWN_COMPAT=(2 4 8 1024) # Unknown incompat flags: UNKNOWN_INCOMPAT=(8 15 1111) # set compat flags in header set_compat() { local part=$1 local flag=$2 expect_normal_exit $PMEMSPOIL $part pool_hdr.features.compat=$flag \ "pool_hdr.checksum_gen\(\)" } # set incompat flags in header set_incompat() { local part=$1 local flag=$2 expect_normal_exit $PMEMSPOIL $part pool_hdr.features.incompat=$flag \ "pool_hdr.checksum_gen\(\)" }
2,852
32.174419
80
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/util_poolset/mocks_windows.h
/* * Copyright 2016-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of libc functions used in util_poolset * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of util_poolset test. * It would replace default implementation with mocked functions defined * in util_poolset.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL_OPEN #define os_open __wrap_os_open #endif #ifndef WRAP_REAL_FALLOCATE #define os_posix_fallocate __wrap_os_posix_fallocate #endif #ifndef WRAP_REAL_PMEM #define pmem_is_pmem __wrap_pmem_is_pmem #endif
2,245
38.403509
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/util_poolset/mocks.h
/* * Copyright 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef MOCKS_H #define MOCKS_H extern const char *Open_path; extern os_off_t Fallocate_len; extern size_t Is_pmem_len; #endif
1,731
41.243902
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_direct/obj_direct.h
/* * Copyright 2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * obj_direct.h -- unit test for pmemobj_direct() */ #ifndef OBJ_DIRECT_H #define OBJ_DIRECT_H 1 #include "libpmemobj.h" void *obj_direct_inline(PMEMoid oid); void *obj_direct_non_inline(PMEMoid oid); #endif /* OBJ_DIRECT_H */
1,831
39.711111
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_tx_mt/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # obj_tx_mt/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
1,760
40.928571
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmem_map_file_win/mocks_windows.h
/* * Copyright 2016-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of libc functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of pmem_map_file test. * It would replace default implementation with mocked functions defined * in pmem_map_file.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define os_posix_fallocate __wrap_os_posix_fallocate #define os_ftruncate __wrap_os_ftruncate #endif
2,123
41.48
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_rpmem_heap_state/config.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # obj_rpmem_heap_state/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
1,776
41.309524
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_addr_ext/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # rpmem_addr_ext/config.sh -- test configuration file # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
1,775
41.285714
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/vmmalloc_init/libtest.h
/* * Copyright 2015-2016, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef LIBTEST_H #define LIBTEST_H #include <stddef.h> void *falloc(size_t size, int c); #endif
1,701
41.55
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmemd_obc/setup.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/rpmemd_obc/setup.sh -- common setup for rpmemd_obc tests # require_nodes 2 require_node_log_files 1 $RPMEM_LOG_FILE RPMEM_CMD="\"cd ${NODE_TEST_DIR[0]} && UNITTEST_FORCE_QUIET=1" RPMEM_CMD="$RPMEM_CMD RPMEMD_LOG_FILE=$RPMEMD_LOG_FILE" RPMEM_CMD="$RPMEM_CMD RPMEMD_LOG_LEVEL=$RPMEMD_LOG_LEVEL" RPMEM_CMD="$RPMEM_CMD LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$REMOTE_LD_LIBRARY_PATH:${NODE_LD_LIBRARY_PATH[0]}" RPMEM_CMD="$RPMEM_CMD ./rpmemd_obc$EXESUFFIX\"" export_vars_node 1 RPMEM_CMD
2,084
42.4375
107
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmemd_obc/rpmemd_obc_test_common.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmemd_obc_test_common.h -- common declarations for rpmemd_obc test */ #include "unittest.h" #include "librpmem.h" #include "rpmem_proto.h" #include "rpmem_common.h" #include "rpmem_ssh.h" #include "rpmem_util.h" #include "rpmemd_log.h" #include "rpmemd_obc.h" #define PORT 1234 #define RKEY 0x0123456789abcdef #define RADDR 0xfedcba9876543210 #define PERSIST_METHOD RPMEM_PM_APM #define POOL_ATTR_INIT {\ .signature = "<RPMEM>",\ .major = 1,\ .compat_features = 2,\ .incompat_features = 3,\ .ro_compat_features = 4,\ .poolset_uuid = "POOLSET_UUID0123",\ .uuid = "UUID0123456789AB",\ .next_uuid = "NEXT_UUID0123456",\ .prev_uuid = "PREV_UUID0123456",\ .user_flags = "USER_FLAGS012345",\ } #define POOL_ATTR_ALT {\ .signature = "<ALT>",\ .major = 5,\ .compat_features = 6,\ .incompat_features = 7,\ .ro_compat_features = 8,\ .poolset_uuid = "UUID_POOLSET_ALT",\ .uuid = "ALT_UUIDCDEFFEDC",\ .next_uuid = "456UUID_NEXT_ALT",\ .prev_uuid = "UUID012_ALT_PREV",\ .user_flags = "012345USER_FLAGS",\ } #define POOL_SIZE 0x0001234567abcdef #define NLANES 0x123 #define NLANES_RESP 16 #define PROVIDER RPMEM_PROV_LIBFABRIC_SOCKETS #define POOL_DESC "pool.set" #define BUFF_SIZE 8192 static const char pool_desc[] = POOL_DESC; #define POOL_DESC_SIZE (sizeof(pool_desc) / sizeof(pool_desc[0])) struct rpmem_ssh *clnt_connect(char *target); void clnt_wait_disconnect(struct rpmem_ssh *ssh); void clnt_send(struct rpmem_ssh *ssh, const void *buff, size_t len); void clnt_recv(struct rpmem_ssh *ssh, void *buff, size_t len); void clnt_close(struct rpmem_ssh *ssh); enum conn_wait_close { CONN_CLOSE, CONN_WAIT_CLOSE, }; void set_rpmem_cmd(const char *fmt, ...); extern struct rpmemd_obc_requests REQ_CB; struct req_cb_arg { int resp; unsigned long long types; int force_ret; int ret; int status; }; static const struct rpmem_msg_hdr MSG_HDR = { .type = RPMEM_MSG_TYPE_CLOSE, .size = sizeof(struct rpmem_msg_hdr), }; static const struct rpmem_msg_create CREATE_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_CREATE, .size = sizeof(struct rpmem_msg_create), }, .c = { .major = RPMEM_PROTO_MAJOR, .minor = RPMEM_PROTO_MINOR, .pool_size = POOL_SIZE, .nlanes = NLANES, .provider = PROVIDER, .buff_size = BUFF_SIZE, }, .pool_attr = POOL_ATTR_INIT, .pool_desc = { .size = POOL_DESC_SIZE, }, }; static const struct rpmem_msg_open OPEN_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_OPEN, .size = sizeof(struct rpmem_msg_open), }, .c = { .major = RPMEM_PROTO_MAJOR, .minor = RPMEM_PROTO_MINOR, .pool_size = POOL_SIZE, .nlanes = NLANES, .provider = PROVIDER, .buff_size = BUFF_SIZE, }, .pool_desc = { .size = POOL_DESC_SIZE, }, }; static const struct rpmem_msg_close CLOSE_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_CLOSE, .size = sizeof(struct rpmem_msg_close), }, }; static const struct rpmem_msg_set_attr SET_ATTR_MSG = { .hdr = { .type = RPMEM_MSG_TYPE_SET_ATTR, .size = sizeof(struct rpmem_msg_set_attr), }, .pool_attr = POOL_ATTR_ALT, }; TEST_CASE_DECLARE(server_accept_sim); TEST_CASE_DECLARE(server_accept_sim_fork); TEST_CASE_DECLARE(client_accept_sim); TEST_CASE_DECLARE(server_accept_seq); TEST_CASE_DECLARE(server_accept_seq_fork); TEST_CASE_DECLARE(client_accept_seq); TEST_CASE_DECLARE(client_bad_msg_hdr); TEST_CASE_DECLARE(server_bad_msg); TEST_CASE_DECLARE(server_msg_noresp); TEST_CASE_DECLARE(server_msg_resp); TEST_CASE_DECLARE(client_econnreset); TEST_CASE_DECLARE(server_econnreset); TEST_CASE_DECLARE(client_create); TEST_CASE_DECLARE(server_open); TEST_CASE_DECLARE(client_close); TEST_CASE_DECLARE(server_close); TEST_CASE_DECLARE(client_open); TEST_CASE_DECLARE(client_set_attr);
5,306
27.379679
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_rm_remote/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_rm_remote/config.sh -- test configuration # set -e CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
1,781
40.44186
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_rpmem_basic_integration/config.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # obj_rpmem_basic_integration/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_TEST_TYPE=medium CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all CONF_RPMEM_PROVIDER[9]=verbs CONF_RPMEM_PROVIDER[10]=verbs CONF_RPMEM_PROVIDER[11]=verbs CONF_RPMEM_PROVIDER[13]=verbs CONF_RPMEM_PROVIDER[14]=verbs CONF_RPMEM_PROVIDER[15]=verbs CONF_RPMEM_PROVIDER[16]=verbs CONF_RPMEM_PROVIDER[17]=verbs CONF_RPMEM_PROVIDER[18]=verbs CONF_RPMEM_VALGRIND[9]=y CONF_RPMEM_VALGRIND[10]=y CONF_RPMEM_VALGRIND[11]=y CONF_RPMEM_VALGRIND[13]=y CONF_RPMEM_VALGRIND[14]=y CONF_RPMEM_VALGRIND[15]=y CONF_RPMEM_VALGRIND[16]=y CONF_RPMEM_VALGRIND[17]=y CONF_RPMEM_VALGRIND[18]=y
2,316
35.777778
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmem_map_file/mocks_windows.h
/* * Copyright 2016-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of libc functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmem * files, when compiled for the purpose of pmem_map_file test. * It would replace default implementation with mocked functions defined * in pmem_map_file.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define os_posix_fallocate __wrap_os_posix_fallocate #define os_ftruncate __wrap_os_ftruncate #endif
2,123
41.48
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_basic_integration/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # obj_basic_integration/config.sh -- test configuration # # Extend timeout for this test, as it may take a few minutes # when run on a non-pmem file system. CONF_GLOBAL_TIMEOUT='10m'
1,772
41.214286
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_feature/common.sh
#!/usr/bin/env bash # # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/pmempool_feature/common.sh -- common part of pmempool_feature tests # # for feature values please see: pmempool feature help PART_SIZE=$((10 * 1024 * 1024)) # 10MiB # define files and directories POOLSET=$DIR/testset TEST_SET_LOCAL=testset_local TEST_SET_REMOTE=testset_remote LOG=grep${UNITTEST_NUM}.log pmempool_exe=$PMEMPOOL$EXESUFFIX exit_func=expect_normal_exit # pmempool_feature_query -- query feature # # usage: pmempool_feature_query <feature> [<query-exit-type>] function pmempool_feature_query() { query_exit_type=${2-normal} query_exit_func=expect_${query_exit_type}_exit val=$($query_exit_func $pmempool_exe feature -q $1 $POOLSET 2>> $LOG) if [ "$query_exit_type" == "normal" ]; then echo "query $1 result is $val" &>> $LOG fi } # pmempool_feature_enable -- enable feature # # usage: pmempool_feature_enable <feature> [no-query] function pmempool_feature_enable() { $exit_func $pmempool_exe feature -e $1 $POOLSET &>> $LOG if [ "x$2" != "xno-query" ]; then pmempool_feature_query $1 fi } # pmempool_feature_disable -- disable feature # # usage: pmempool_feature_disable <feature> [no-query] function pmempool_feature_disable() { $exit_func $pmempool_exe feature -d $1 $POOLSET &>> $LOG if [ "x$2" != "xno-query" ]; then pmempool_feature_query $1 fi } # pmempool_feature_create_poolset -- create poolset # # usage: pmempool_feature_create_poolset <poolset-type> function pmempool_feature_create_poolset() { POOLSET_TYPE=$1 case "$1" in "no_dax_device") create_poolset $POOLSET \ $PART_SIZE:$DIR/testfile11:x \ $PART_SIZE:$DIR/testfile12:x \ r \ $PART_SIZE:$DIR/testfile21:x \ $PART_SIZE:$DIR/testfile22:x \ r \ $PART_SIZE:$DIR/testfile31:x ;; "dax_device") create_poolset $POOLSET \ AUTO:$DEVICE_DAX_PATH ;; "remote") create_poolset $DIR/$TEST_SET_LOCAL \ $PART_SIZE:${NODE_DIR[1]}/testfile_local11:x \ $PART_SIZE:${NODE_DIR[1]}/testfile_local12:x \ m ${NODE_ADDR[0]}:$TEST_SET_REMOTE create_poolset $DIR/$TEST_SET_REMOTE \ $PART_SIZE:${NODE_DIR[0]}/testfile_remote21:x \ $PART_SIZE:${NODE_DIR[0]}/testfile_remote22:x copy_files_to_node 0 ${NODE_DIR[0]} $DIR/$TEST_SET_REMOTE copy_files_to_node 1 ${NODE_DIR[1]} $DIR/$TEST_SET_LOCAL rm_files_from_node 1 \ ${NODE_DIR[1]}testfile_local11 ${NODE_DIR[1]}testfile_local12 rm_files_from_node 0 \ ${NODE_DIR[0]}testfile_remote21 ${NODE_DIR[0]}testfile_remote22 POOLSET="${NODE_DIR[1]}/$TEST_SET_LOCAL" ;; esac # XXX: pmempool rm does not pass Valgrind memcheck pmem/issues#947 VALGRIND_DISABLED=y expect_normal_exit $pmempool_exe rm -f $POOLSET # create pool # pmempool create under valgrind pmemcheck takes too long # it is not part of the test so it is run here without valgrind VALGRIND_DISABLED=y expect_normal_exit $pmempool_exe create obj $POOLSET } # pmempool_feature_test_SINGLEHDR -- test SINGLEHDR function pmempool_feature_test_SINGLEHDR() { exit_func=expect_abnormal_exit pmempool_feature_enable "SINGLEHDR" "no-query" # UNSUPPORTED pmempool_feature_disable "SINGLEHDR" "no-query" # UNSUPPORTED exit_func=expect_normal_exit pmempool_feature_query "SINGLEHDR" } # pmempool_feature_test_CKSUM_2K -- test CKSUM_2K function pmempool_feature_test_CKSUM_2K() { # PMEMPOOL_FEAT_CHCKSUM_2K is enabled by default pmempool_feature_query "CKSUM_2K" # SHUTDOWN_STATE is disabled by default on Linux # enable it to interfere toggling CKSUM_2K pmempool_feature_enable SHUTDOWN_STATE "no-query" # disable PMEMPOOL_FEAT_SHUTDOWN_STATE prior to success exit_func=expect_abnormal_exit pmempool_feature_disable "CKSUM_2K" # should fail exit_func=expect_normal_exit pmempool_feature_disable "SHUTDOWN_STATE" pmempool_feature_disable "CKSUM_2K" # should succeed pmempool_feature_enable "CKSUM_2K" } # pmempool_feature_test_SHUTDOWN_STATE -- test SHUTDOWN_STATE function pmempool_feature_test_SHUTDOWN_STATE() { # PMEMPOOL_FEAT_SHUTDOWN_STATE is disabled by default pmempool_feature_query "SHUTDOWN_STATE" # PMEMPOOL_FEAT_SHUTDOWN_STATE requires PMEMPOOL_FEAT_CHCKSUM_2K pmempool_feature_disable "CKSUM_2K" exit_func=expect_abnormal_exit pmempool_feature_enable "SHUTDOWN_STATE" # should fail exit_func=expect_normal_exit pmempool_feature_enable "CKSUM_2K" pmempool_feature_enable "SHUTDOWN_STATE" # should succeed } # pmempool_feature_test_CHECK_BAD_BLOCKS -- test SHUTDOWN_STATE function pmempool_feature_test_CHECK_BAD_BLOCKS() { # PMEMPOOL_FEAT_CHECK_BAD_BLOCKS is disabled by default pmempool_feature_query "CHECK_BAD_BLOCKS" pmempool_feature_enable "CHECK_BAD_BLOCKS" pmempool_feature_disable "CHECK_BAD_BLOCKS" } # pmempool_feature_remote_init -- initialization remote replics function pmempool_feature_remote_init() { require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER init_rpmem_on_node 1 0 pmempool_exe="run_on_node 1 ../pmempool" } # pmempool_feature_test_remote -- run remote tests function pmempool_feature_test_remote() { # create pool expect_normal_exit $pmempool_exe rm -f $POOLSET expect_normal_exit $pmempool_exe create obj $POOLSET # poolset with remote replicas are not supported exit_func=expect_abnormal_exit pmempool_feature_enable $1 no-query pmempool_feature_disable $1 no-query pmempool_feature_query $1 abnormal }
6,906
31.890476
78
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_info_remote/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_info_remote/config.sh -- test configuration # set -e CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
1,783
40.488372
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_transform_remote/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_transform_remote/config.sh -- configuration of unit tests # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
1,784
41.5
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_transform_remote/common.sh
#!/usr/bin/env bash # # Copyright 2017-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_transform_remote/common.sh -- commons for pmempool transform tests # with remote replication # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER require_node_libfabric 1 $RPMEM_PROVIDER setup init_rpmem_on_node 1 0 require_node_log_files 1 pmemobj$UNITTEST_NUM.log require_node_log_files 1 pmempool$UNITTEST_NUM.log LOG=out${UNITTEST_NUM}.log LOG_TEMP=out${UNITTEST_NUM}_part.log rm -f $LOG && touch $LOG rm -f $LOG_TEMP && touch $LOG_TEMP rm_files_from_node 0 ${NODE_TEST_DIR[0]}/$LOG rm_files_from_node 1 ${NODE_TEST_DIR[1]}/$LOG LAYOUT=OBJ_LAYOUT POOLSET_LOCAL_IN=poolset.in POOLSET_LOCAL_OUT=poolset.out POOLSET_REMOTE=poolset.remote POOLSET_REMOTE1=poolset.remote1 POOLSET_REMOTE2=poolset.remote2 # CLI scripts for writing and reading some data hitting all the parts WRITE_SCRIPT="pmemobjcli.write.script" READ_SCRIPT="pmemobjcli.read.script" copy_files_to_node 1 ${NODE_DIR[1]} $WRITE_SCRIPT $READ_SCRIPT DUMP_INFO_LOG="../pmempool info" DUMP_INFO_LOG_REMOTE="$DUMP_INFO_LOG -f obj" DUMP_INFO_SED="sed -e '/^Checksum/d' -e '/^Creation/d' -e '/^Previous replica UUID/d' -e '/^Next replica UUID/d'" DUMP_INFO_SED_REMOTE="$DUMP_INFO_SED -e '/^Previous part UUID/d' -e '/^Next part UUID/d'" function dump_info_log() { local node=$1 local poolset=$2 local name=$3 local ignore=$4 local sed_cmd="$DUMP_INFO_SED" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG $poolset | $sed_cmd >> $name\"" } function dump_info_log_remote() { local node=$1 local poolset=$2 local name=$3 local ignore=$4 local sed_cmd="$DUMP_INFO_SED_REMOTE" if [ -n "$ignore" ]; then sed_cmd="$sed_cmd -e '/^$ignore/d'" fi expect_normal_exit run_on_node $node "\"$DUMP_INFO_LOG_REMOTE $poolset | $sed_cmd >> $name\"" } function diff_log() { local node=$1 local f1=$2 local f2=$3 expect_normal_exit run_on_node $node "\"[ -s $f1 ] && [ -s $f2 ] && diff $f1 $f2\"" } exec_pmemobjcli_script() { local node=$1 local script=$2 local poolset=$3 local out=$4 expect_normal_exit run_on_node $node "\"../pmemobjcli -s $script $poolset > $out \"" }
3,784
30.541667
113
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/pmempool_feature_remote/config.sh
#!/usr/bin/env bash # # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # pmempool_feature_remote/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" # pmempool feature does not support poolsets with remote replicas # unittest contains only negative scenarios so no point to loop over # all providers and persistency methods CONF_GLOBAL_RPMEM_PROVIDER=sockets CONF_GLOBAL_RPMEM_PMETHOD=GPSPM
1,954
42.444444
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_basic/common_pm_policy.sh
#!/usr/bin/env bash # # Copyright 2017-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/rpmem_basic/common_pm_policy.sh -- common part for TEST[10-11] scripts # set -e LOG=rpmemd$UNITTEST_NUM.log OUT=out$UNITTEST_NUM.log rm -f $OUT # create poolset and upload run_on_node 0 "rm -rf ${RPMEM_POOLSET_DIR[0]} && mkdir -p ${RPMEM_POOLSET_DIR[0]} && mkdir -p ${NODE_DIR[0]}$POOLS_PART" create_poolset $DIR/pool.set 8M:$PART_DIR/pool.part0 8M:$PART_DIR/pool.part1 copy_files_to_node 0 ${RPMEM_POOLSET_DIR[0]} $DIR/pool.set # create pool and close it - local pool from file SIMPLE_ARGS="test_create 0 pool.set ${NODE_ADDR[0]} pool 8M none test_close 0" function test_pm_policy() { # initialize pmem PMEM_IS_PMEM_FORCE=$1 export_vars_node 0 PMEM_IS_PMEM_FORCE init_rpmem_on_node 1 0 # remove rpmemd log and pool parts run_on_node 0 "rm -rf $PART_DIR && mkdir -p $PART_DIR && rm -f $LOG" # execute, get log expect_normal_exit run_on_node 1 ./rpmem_basic$EXESUFFIX $SIMPLE_ARGS copy_files_from_node 0 . ${NODE_TEST_DIR[0]}/$LOG # extract persist method and flush function cat $LOG | $GREP -A2 "persistency policy:" >> $OUT }
2,648
37.955882
120
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_basic/config.sh
#!/usr/bin/env bash # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # rpmem_basic/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=any CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all CONF_RPMEM_PMETHOD[10]=APM CONF_RPMEM_PMETHOD[11]=GPSPM # Sockets provider does not detect fi_cq_signal so it does not return # from fi_cq_sread. It causes this test to hang sporadically. # https://github.com/ofiwg/libfabric/pull/3645 CONF_RPMEM_PROVIDER[12]=verbs
2,033
39.68
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_basic/setup2to1.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/rpmem_basic/setup2to1.sh -- common part for TEST[7-] scripts # POOLS_DIR=pools POOLS_PART=pool_parts TEST_LOG_FILE=test$UNITTEST_NUM.log TEST_LOG_LEVEL=3 # # This unit test requires 4 nodes, but nodes #0 and #3 should be the same # physical machine - they should have the same NODE[n] addresses but # different NODE_ADDR[n] addresses in order to test "2-to-1" configuration. # Node #1 is being replicated to the node #0 and node #2 is being replicated # to the node #3. # require_nodes 4 REPLICA[1]=0 REPLICA[2]=3 for node in 1 2; do require_node_libfabric ${node} $RPMEM_PROVIDER require_node_libfabric ${REPLICA[${node}]} $RPMEM_PROVIDER export_vars_node ${node} TEST_LOG_FILE export_vars_node ${node} TEST_LOG_LEVEL require_node_log_files ${node} $PMEM_LOG_FILE require_node_log_files ${node} $RPMEM_LOG_FILE require_node_log_files ${node} $TEST_LOG_FILE require_node_log_files ${REPLICA[${node}]} $RPMEMD_LOG_FILE REP_ADDR[${node}]=${NODE_ADDR[${REPLICA[${node}]}]} PART_DIR[${node}]=${NODE_DIR[${REPLICA[${node}]}]}$POOLS_PART RPMEM_POOLSET_DIR[${REPLICA[${node}]}]=${NODE_DIR[${REPLICA[${node}]}]}$POOLS_DIR init_rpmem_on_node ${node} ${REPLICA[${node}]} PID_FILE[${node}]="pidfile${UNITTEST_NUM}-${node}.pid" clean_remote_node ${node} ${PID_FILE[${node}]} done
2,972
37.115385
82
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/rpmem_basic/setup.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/rpmem_basic/setup.sh -- common part for TEST* scripts # set -e require_nodes 2 require_node_libfabric 0 $RPMEM_PROVIDER $SETUP_LIBFABRIC_VERSION require_node_libfabric 1 $RPMEM_PROVIDER $SETUP_LIBFABRIC_VERSION require_node_log_files 0 $RPMEMD_LOG_FILE require_node_log_files 1 $RPMEM_LOG_FILE require_node_log_files 1 $PMEM_LOG_FILE POOLS_DIR=pools POOLS_PART=pool_parts PART_DIR=${NODE_DIR[0]}/$POOLS_PART RPMEM_POOLSET_DIR[0]=${NODE_DIR[0]}$POOLS_DIR if [ -z "$SETUP_MANUAL_INIT_RPMEM" ]; then init_rpmem_on_node 1 0 fi
2,130
38.462963
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_rpmem_heap_interrupt/config.sh
#!/usr/bin/env bash # # Copyright 2016-2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # src/test/obj_rpmem_heap_interrupt/config.sh -- test configuration # CONF_GLOBAL_FS_TYPE=pmem CONF_GLOBAL_BUILD_TYPE="debug nondebug" CONF_GLOBAL_RPMEM_PROVIDER=all CONF_GLOBAL_RPMEM_PMETHOD=all
1,789
41.619048
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/libpmempool_backup/config.sh
#!/usr/bin/env bash # # Copyright 2017, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # libpmempool_backup/config.sh -- test configuration # # Extend timeout for TEST0, as it may take more than a minute # when run on a non-pmem file system. CONF_TIMEOUT[0]='10m'
1,766
41.071429
73
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/libpmempool_backup/common.sh
#!/usr/bin/env bash # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # libpmempool_backup/common.sh -- functions for libpmempool_backup unittest # set -e POOLSET=$DIR/pool.set BACKUP=_backup REPLICA=_replica POOL_PART=$DIR/pool.part OUT=out${UNITTEST_NUM}.log OUT_TEMP=out${UNITTEST_NUM}_temp.log DIFF=diff${UNITTEST_NUM}.log rm -f $LOG $DIFF $OUT_TEMP && touch $LOG $DIFF $OUT_TEMP # params for blk, log and obj pools POOL_TYPES=( blk log obj ) POOL_CREATE_PARAMS=( "--write-layout 512" "" "--layout test_layout" ) POOL_CHECK_PARAMS=( "-smgB" "-s" "-soOaAbZH -l -C" ) POOL_OBJ=2 # create_poolset_variation -- create one from the tested poolset variation # usage: create_poolset_variation <variation-id> [<suffix>] # function create_poolset_variation() { local sfx="" local variation=$1 shift if [ $# -gt 0 ]; then sfx=$1 fi case "$variation" in 1) # valid poolset file create_poolset $POOLSET$sfx \ 20M:${POOL_PART}1$sfx:x \ 20M:${POOL_PART}2$sfx:x \ 20M:${POOL_PART}3$sfx:x \ 20M:${POOL_PART}4$sfx:x ;; 2) # valid poolset file with replica create_poolset $POOLSET$sfx \ 20M:${POOL_PART}1$sfx:x \ 20M:${POOL_PART}2$sfx:x \ 20M:${POOL_PART}3$sfx:x \ 20M:${POOL_PART}4$sfx:x \ r 80M:${POOL_PART}${REPLICA}$sfx:x ;; 3) # other number of parts create_poolset $POOLSET$sfx \ 20M:${POOL_PART}1$sfx:x \ 20M:${POOL_PART}2$sfx:x \ 40M:${POOL_PART}3$sfx:x ;; 4) # no poolset # return without check_file return ;; 5) # empty create_poolset $POOLSET$sfx ;; 6) # other size of part create_poolset $POOLSET$sfx \ 20M:${POOL_PART}1$sfx:x \ 20M:${POOL_PART}2$sfx:x \ 20M:${POOL_PART}3$sfx:x \ 21M:${POOL_PART}4$sfx:x ;; esac check_file $POOLSET$sfx } # # backup_and_compare -- perform backup and compare backup result with original # if compare parameters are provided # usage: backup_and_compare <poolset> <type> [<compare-params>] # function backup_and_compare () { local poolset=$1 local type=$2 shift 2 # backup expect_normal_exit ../libpmempool_api/libpmempool_test$EXESUFFIX \ -b $poolset$BACKUP -t $type -r 1 $poolset cat $OUT >> $OUT_TEMP # compare if [ $# -gt 0 ]; then compare_replicas "$1" $poolset $poolset$BACKUP >> $DIFF fi } ALL_POOL_PARTS="${POOL_PART}1 ${POOL_PART}2 ${POOL_PART}3 ${POOL_PART}4 \ ${POOL_PART}${REPLICA}" ALL_POOL_BACKUP_PARTS="${POOL_PART}1$BACKUP ${POOL_PART}2$BACKUP \ ${POOL_PART}3$BACKUP ${POOL_PART}4$BACKUP \ ${POOL_PART}${BACKUP}${REPLICA}" # # backup_cleanup -- perform cleanup between test cases # function backup_cleanup() { rm -f $POOLSET$BACKUP $ALL_POOL_PARTS $ALL_POOL_BACKUP_PARTS }
4,177
27.421769
78
sh
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/test/obj_sync/mocks_windows.h
/* * Copyright 2016-2017, Intel Corporation * Copyright (c) 2016, Microsoft Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * mocks_windows.h -- redefinitions of pthread functions * * This file is Windows-specific. * * This file should be included (i.e. using Forced Include) by libpmemobj * files, when compiled for the purpose of obj_sync test. * It would replace default implementation with mocked functions defined * in obj_sync.c. * * These defines could be also passed as preprocessor definitions. */ #ifndef WRAP_REAL #define os_mutex_init __wrap_os_mutex_init #define os_rwlock_init __wrap_os_rwlock_init #define os_cond_init __wrap_os_cond_init #endif
2,221
41.730769
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libvmmalloc/vmmalloc.h
/* * Copyright 2014-2016, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * vmmalloc.h -- internal definitions for libvmmalloc */ #define VMMALLOC_LOG_PREFIX "libvmmalloc" #define VMMALLOC_LOG_LEVEL_VAR "VMMALLOC_LOG_LEVEL" #define VMMALLOC_LOG_FILE_VAR "VMMALLOC_LOG_FILE" #define VMMALLOC_LOG_STATS_VAR "VMMALLOC_LOG_STATS" #define VMMALLOC_POOL_DIR_VAR "VMMALLOC_POOL_DIR" #define VMMALLOC_POOL_SIZE_VAR "VMMALLOC_POOL_SIZE" #define VMMALLOC_FORK_VAR "VMMALLOC_FORK"
2,005
43.577778
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/rpmem_common/rpmem_fip_common.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_fip_common.h -- common definitions for librpmem and rpmemd */ #ifndef RPMEM_FIP_COMMON_H #define RPMEM_FIP_COMMON_H 1 #include <string.h> #include <netinet/in.h> #include <rdma/fabric.h> #include <rdma/fi_cm.h> #include <rdma/fi_rma.h> #ifdef __cplusplus extern "C" { #endif #define RPMEM_FIVERSION FI_VERSION(1, 4) #define RPMEM_FIP_CQ_WAIT_MS 100 #define min(a, b) ((a) < (b) ? (a) : (b)) /* * rpmem_fip_node -- client or server node type */ enum rpmem_fip_node { RPMEM_FIP_NODE_CLIENT, RPMEM_FIP_NODE_SERVER, MAX_RPMEM_FIP_NODE, }; /* * rpmem_fip_probe -- list of providers */ struct rpmem_fip_probe { unsigned providers; }; /* * rpmem_fip_probe -- returns true if specified provider is available */ static inline int rpmem_fip_probe(struct rpmem_fip_probe probe, enum rpmem_provider provider) { return (probe.providers & (1U << provider)) != 0; } /* * rpmem_fip_probe_any -- returns true if any provider is available */ static inline int rpmem_fip_probe_any(struct rpmem_fip_probe probe) { return probe.providers != 0; } int rpmem_fip_probe_get(const char *target, struct rpmem_fip_probe *probe); struct fi_info *rpmem_fip_get_hints(enum rpmem_provider provider); int rpmem_fip_read_eq_check(struct fid_eq *eq, struct fi_eq_cm_entry *entry, uint32_t exp_event, fid_t exp_fid, int timeout); int rpmem_fip_read_eq(struct fid_eq *eq, struct fi_eq_cm_entry *entry, uint32_t *event, int timeout); size_t rpmem_fip_cq_size(enum rpmem_persist_method pm, enum rpmem_fip_node node); size_t rpmem_fip_tx_size(enum rpmem_persist_method pm, enum rpmem_fip_node node); size_t rpmem_fip_rx_size(enum rpmem_persist_method pm, enum rpmem_fip_node node); size_t rpmem_fip_max_nlanes(struct fi_info *fi); void rpmem_fip_print_info(struct fi_info *fi); #ifdef __cplusplus } #endif #endif
3,428
28.307692
76
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/rpmem_common/rpmem_common_log.h
/* * Copyright 2016, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_common_log.h -- common log macros for librpmem and rpmemd */ #if defined(RPMEMC_LOG_RPMEM) && defined(RPMEMC_LOG_RPMEMD) #error Both RPMEMC_LOG_RPMEM and RPMEMC_LOG_RPMEMD defined #elif !defined(RPMEMC_LOG_RPMEM) && !defined(RPMEMC_LOG_RPMEMD) #define RPMEMC_LOG(level, fmt, args...) do {} while (0) #define RPMEMC_DBG(level, fmt, args...) do {} while (0) #define RPMEMC_FATAL(fmt, args...) do {} while (0) #define RPMEMC_ASSERT(cond) do {} while (0) #elif defined(RPMEMC_LOG_RPMEM) #include "out.h" #include "rpmem_util.h" #define RPMEMC_LOG(level, fmt, args...) RPMEM_LOG(level, fmt, ## args) #define RPMEMC_DBG(level, fmt, args...) RPMEM_DBG(fmt, ## args) #define RPMEMC_FATAL(fmt, args...) RPMEM_FATAL(fmt, ## args) #define RPMEMC_ASSERT(cond) RPMEM_ASSERT(cond) #else #include "rpmemd_log.h" #define RPMEMC_LOG(level, fmt, args...) RPMEMD_LOG(level, fmt, ## args) #define RPMEMC_DBG(level, fmt, args...) RPMEMD_DBG(fmt, ## args) #define RPMEMC_FATAL(fmt, args...) RPMEMD_FATAL(fmt, ## args) #define RPMEMC_ASSERT(cond) RPMEMD_ASSERT(cond) #endif
2,675
38.352941
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/rpmem_common/rpmem_common.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_common.h -- common definitions for librpmem and rpmemd */ #ifndef RPMEM_COMMON_H #define RPMEM_COMMON_H 1 /* * Values for SO_KEEPALIVE socket option */ #define RPMEM_CMD_ENV "RPMEM_CMD" #define RPMEM_SSH_ENV "RPMEM_SSH" #define RPMEM_DEF_CMD "rpmemd" #define RPMEM_DEF_SSH "ssh" #define RPMEM_PROV_SOCKET_ENV "RPMEM_ENABLE_SOCKETS" #define RPMEM_PROV_VERBS_ENV "RPMEM_ENABLE_VERBS" #define RPMEM_MAX_NLANES_ENV "RPMEM_MAX_NLANES" #define RPMEM_ACCEPT_TIMEOUT 30000 #define RPMEM_CONNECT_TIMEOUT 30000 #define RPMEM_MONITOR_TIMEOUT 1000 #include <stdint.h> #include <sys/socket.h> #include <netdb.h> #ifdef __cplusplus extern "C" { #endif /* * rpmem_err -- error codes */ enum rpmem_err { RPMEM_SUCCESS = 0, RPMEM_ERR_BADPROTO = 1, RPMEM_ERR_BADNAME = 2, RPMEM_ERR_BADSIZE = 3, RPMEM_ERR_BADNLANES = 4, RPMEM_ERR_BADPROVIDER = 5, RPMEM_ERR_FATAL = 6, RPMEM_ERR_FATAL_CONN = 7, RPMEM_ERR_BUSY = 8, RPMEM_ERR_EXISTS = 9, RPMEM_ERR_PROVNOSUP = 10, RPMEM_ERR_NOEXIST = 11, RPMEM_ERR_NOACCESS = 12, RPMEM_ERR_POOL_CFG = 13, MAX_RPMEM_ERR, }; /* * rpmem_persist_method -- remote persist operation method */ enum rpmem_persist_method { RPMEM_PM_GPSPM = 1, /* General Purpose Server Persistency Method */ RPMEM_PM_APM = 2, /* Appliance Persistency Method */ MAX_RPMEM_PM, }; const char *rpmem_persist_method_to_str(enum rpmem_persist_method pm); /* * rpmem_provider -- supported providers */ enum rpmem_provider { RPMEM_PROV_UNKNOWN = 0, RPMEM_PROV_LIBFABRIC_VERBS = 1, RPMEM_PROV_LIBFABRIC_SOCKETS = 2, MAX_RPMEM_PROV, }; enum rpmem_provider rpmem_provider_from_str(const char *str); const char *rpmem_provider_to_str(enum rpmem_provider provider); /* * rpmem_req_attr -- arguments for open/create request */ struct rpmem_req_attr { size_t pool_size; unsigned nlanes; size_t buff_size; enum rpmem_provider provider; const char *pool_desc; }; /* * rpmem_resp_attr -- return arguments from open/create request */ struct rpmem_resp_attr { unsigned short port; uint64_t rkey; uint64_t raddr; unsigned nlanes; enum rpmem_persist_method persist_method; }; #define RPMEM_HAS_USER 0x1 #define RPMEM_HAS_SERVICE 0x2 #define RPMEM_FLAGS_USE_IPV4 0x4 #define RPMEM_MAX_USER (32 + 1) /* see useradd(8) + 1 for '\0' */ #define RPMEM_MAX_NODE (255 + 1) /* see gethostname(2) + 1 for '\0' */ #define RPMEM_MAX_SERVICE (NI_MAXSERV + 1) /* + 1 for '\0' */ #define RPMEM_HDR_SIZE 4096 #define RPMEM_CLOSE_FLAGS_REMOVE 0x1 #define RPMEM_DEF_BUFF_SIZE 8192 struct rpmem_target_info { char user[RPMEM_MAX_USER]; char node[RPMEM_MAX_NODE]; char service[RPMEM_MAX_SERVICE]; unsigned flags; }; extern unsigned Rpmem_max_nlanes; extern int Rpmem_fork_unsafe; int rpmem_b64_write(int sockfd, const void *buf, size_t len, int flags); int rpmem_b64_read(int sockfd, void *buf, size_t len, int flags); const char *rpmem_get_ip_str(const struct sockaddr *addr); struct rpmem_target_info *rpmem_target_parse(const char *target); void rpmem_target_free(struct rpmem_target_info *info); int rpmem_xwrite(int fd, const void *buf, size_t len, int flags); int rpmem_xread(int fd, void *buf, size_t len, int flags); char *rpmem_get_ssh_conn_addr(void); #ifdef __cplusplus } #endif #endif
4,838
27.976048
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/rpmem_common/rpmem_proto.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_proto.h -- rpmem protocol definitions */ #ifndef RPMEM_PROTO_H #define RPMEM_PROTO_H 1 #include <stdint.h> #include <endian.h> #include "librpmem.h" #ifdef __cplusplus extern "C" { #endif #define PACKED __attribute__((packed)) #define RPMEM_PROTO "tcp" #define RPMEM_PROTO_MAJOR 0 #define RPMEM_PROTO_MINOR 1 #define RPMEM_SIG_SIZE 8 #define RPMEM_UUID_SIZE 16 #define RPMEM_PROV_SIZE 32 #define RPMEM_USER_SIZE 16 /* * rpmem_msg_type -- type of messages */ enum rpmem_msg_type { RPMEM_MSG_TYPE_CREATE = 1, /* create request */ RPMEM_MSG_TYPE_CREATE_RESP = 2, /* create request response */ RPMEM_MSG_TYPE_OPEN = 3, /* open request */ RPMEM_MSG_TYPE_OPEN_RESP = 4, /* open request response */ RPMEM_MSG_TYPE_CLOSE = 5, /* close request */ RPMEM_MSG_TYPE_CLOSE_RESP = 6, /* close request response */ RPMEM_MSG_TYPE_SET_ATTR = 7, /* set attributes request */ /* set attributes request response */ RPMEM_MSG_TYPE_SET_ATTR_RESP = 8, MAX_RPMEM_MSG_TYPE, }; /* * rpmem_pool_attr_packed -- a packed version */ struct rpmem_pool_attr_packed { char signature[RPMEM_POOL_HDR_SIG_LEN]; /* pool signature */ uint32_t major; /* format major version number */ uint32_t compat_features; /* mask: compatible "may" features */ uint32_t incompat_features; /* mask: "must support" features */ uint32_t ro_compat_features; /* mask: force RO if unsupported */ unsigned char poolset_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* pool uuid */ unsigned char uuid[RPMEM_POOL_HDR_UUID_LEN]; /* first part uuid */ unsigned char next_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* next pool uuid */ unsigned char prev_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* prev pool uuid */ unsigned char user_flags[RPMEM_POOL_USER_FLAGS_LEN]; /* user flags */ } PACKED; /* * rpmem_msg_ibc_attr -- in-band connection attributes * * Used by create request response and open request response. * Contains essential information to proceed with in-band connection * initialization. */ struct rpmem_msg_ibc_attr { uint32_t port; /* RDMA connection port */ uint32_t persist_method; /* persist method */ uint64_t rkey; /* remote key */ uint64_t raddr; /* remote address */ uint32_t nlanes; /* number of lanes */ } PACKED; /* * rpmem_msg_pool_desc -- remote pool descriptor */ struct rpmem_msg_pool_desc { uint32_t size; /* size of pool descriptor */ uint8_t desc[0]; /* pool descriptor, null-terminated string */ } PACKED; /* * rpmem_msg_hdr -- message header which consists of type and size of message * * The type must be one of the rpmem_msg_type values. */ struct rpmem_msg_hdr { uint32_t type; /* type of message */ uint64_t size; /* size of message */ uint8_t body[0]; } PACKED; /* * rpmem_msg_hdr_resp -- message response header which consists of type, size * and status. * * The type must be one of the rpmem_msg_type values. */ struct rpmem_msg_hdr_resp { uint32_t status; /* response status */ uint32_t type; /* type of message */ uint64_t size; /* size of message */ } PACKED; /* * rpmem_msg_common -- common fields for open/create messages */ struct rpmem_msg_common { uint16_t major; /* protocol version major number */ uint16_t minor; /* protocol version minor number */ uint64_t pool_size; /* minimum required size of a pool */ uint32_t nlanes; /* number of lanes used by initiator */ uint32_t provider; /* provider */ uint64_t buff_size; /* buffer size for inline persist */ } PACKED; /* * rpmem_msg_create -- create request message * * The type of message must be set to RPMEM_MSG_TYPE_CREATE. * The size of message must be set to * sizeof(struct rpmem_msg_create) + pool_desc_size */ struct rpmem_msg_create { struct rpmem_msg_hdr hdr; /* message header */ struct rpmem_msg_common c; struct rpmem_pool_attr_packed pool_attr; /* pool attributes */ struct rpmem_msg_pool_desc pool_desc; /* pool descriptor */ } PACKED; /* * rpmem_msg_create_resp -- create request response message * * The type of message must be set to RPMEM_MSG_TYPE_CREATE_RESP. * The size of message must be set to sizeof(struct rpmem_msg_create_resp). */ struct rpmem_msg_create_resp { struct rpmem_msg_hdr_resp hdr; /* message header */ struct rpmem_msg_ibc_attr ibc; /* in-band connection attributes */ } PACKED; /* * rpmem_msg_open -- open request message * * The type of message must be set to RPMEM_MSG_TYPE_OPEN. * The size of message must be set to * sizeof(struct rpmem_msg_open) + pool_desc_size */ struct rpmem_msg_open { struct rpmem_msg_hdr hdr; /* message header */ struct rpmem_msg_common c; struct rpmem_msg_pool_desc pool_desc; /* pool descriptor */ } PACKED; /* * rpmem_msg_open_resp -- open request response message * * The type of message must be set to RPMEM_MSG_TYPE_OPEN_RESP. * The size of message must be set to sizeof(struct rpmem_msg_open_resp) */ struct rpmem_msg_open_resp { struct rpmem_msg_hdr_resp hdr; /* message header */ struct rpmem_msg_ibc_attr ibc; /* in-band connection attributes */ struct rpmem_pool_attr_packed pool_attr; /* pool attributes */ } PACKED; /* * rpmem_msg_close -- close request message * * The type of message must be set to RPMEM_MSG_TYPE_CLOSE * The size of message must be set to sizeof(struct rpmem_msg_close) */ struct rpmem_msg_close { struct rpmem_msg_hdr hdr; /* message header */ uint32_t flags; /* flags */ } PACKED; /* * rpmem_msg_close_resp -- close request response message * * The type of message must be set to RPMEM_MSG_TYPE_CLOSE_RESP * The size of message must be set to sizeof(struct rpmem_msg_close_resp) */ struct rpmem_msg_close_resp { struct rpmem_msg_hdr_resp hdr; /* message header */ /* no more fields */ } PACKED; #define RPMEM_PERSIST_WRITE 0U /* persist using RDMA WRITE */ #define RPMEM_DEEP_PERSIST 1U /* deep persist operation */ #define RPMEM_PERSIST_SEND 2U /* persist using RDMA SEND */ #define RPMEM_PERSIST_MAX 2U /* maximum valid value */ /* * the two least significant bits * are reserved for mode of persist */ #define RPMEM_PERSIST_MASK 0x3U /* * rpmem_msg_persist -- remote persist message */ struct rpmem_msg_persist { uint32_t flags; /* lane flags */ uint32_t lane; /* lane identifier */ uint64_t addr; /* remote memory address */ uint64_t size; /* remote memory size */ uint8_t data[]; }; /* * rpmem_msg_persist_resp -- remote persist response message */ struct rpmem_msg_persist_resp { uint32_t flags; /* lane flags */ uint32_t lane; /* lane identifier */ }; /* * rpmem_msg_set_attr -- set attributes request message * * The type of message must be set to RPMEM_MSG_TYPE_SET_ATTR. * The size of message must be set to sizeof(struct rpmem_msg_set_attr) */ struct rpmem_msg_set_attr { struct rpmem_msg_hdr hdr; /* message header */ struct rpmem_pool_attr_packed pool_attr; /* pool attributes */ } PACKED; /* * rpmem_msg_set_attr_resp -- set attributes request response message * * The type of message must be set to RPMEM_MSG_TYPE_SET_ATTR_RESP. * The size of message must be set to sizeof(struct rpmem_msg_set_attr_resp). */ struct rpmem_msg_set_attr_resp { struct rpmem_msg_hdr_resp hdr; /* message header */ } PACKED; /* * XXX Begin: Suppress gcc conversion warnings for FreeBSD be*toh macros. */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" /* * rpmem_ntoh_msg_ibc_attr -- convert rpmem_msg_ibc attr to host byte order */ static inline void rpmem_ntoh_msg_ibc_attr(struct rpmem_msg_ibc_attr *ibc) { ibc->port = be32toh(ibc->port); ibc->persist_method = be32toh(ibc->persist_method); ibc->rkey = be64toh(ibc->rkey); ibc->raddr = be64toh(ibc->raddr); } /* * rpmem_ntoh_msg_pool_desc -- convert rpmem_msg_pool_desc to host byte order */ static inline void rpmem_ntoh_msg_pool_desc(struct rpmem_msg_pool_desc *pool_desc) { pool_desc->size = be32toh(pool_desc->size); } /* * rpmem_ntoh_pool_attr -- convert rpmem_pool_attr to host byte order */ static inline void rpmem_ntoh_pool_attr(struct rpmem_pool_attr_packed *attr) { attr->major = be32toh(attr->major); attr->ro_compat_features = be32toh(attr->ro_compat_features); attr->incompat_features = be32toh(attr->incompat_features); attr->compat_features = be32toh(attr->compat_features); } /* * rpmem_ntoh_msg_hdr -- convert rpmem_msg_hdr to host byte order */ static inline void rpmem_ntoh_msg_hdr(struct rpmem_msg_hdr *hdrp) { hdrp->type = be32toh(hdrp->type); hdrp->size = be64toh(hdrp->size); } /* * rpmem_hton_msg_hdr -- convert rpmem_msg_hdr to network byte order */ static inline void rpmem_hton_msg_hdr(struct rpmem_msg_hdr *hdrp) { rpmem_ntoh_msg_hdr(hdrp); } /* * rpmem_ntoh_msg_hdr_resp -- convert rpmem_msg_hdr_resp to host byte order */ static inline void rpmem_ntoh_msg_hdr_resp(struct rpmem_msg_hdr_resp *hdrp) { hdrp->status = be32toh(hdrp->status); hdrp->type = be32toh(hdrp->type); hdrp->size = be64toh(hdrp->size); } /* * rpmem_hton_msg_hdr_resp -- convert rpmem_msg_hdr_resp to network byte order */ static inline void rpmem_hton_msg_hdr_resp(struct rpmem_msg_hdr_resp *hdrp) { rpmem_ntoh_msg_hdr_resp(hdrp); } /* * rpmem_ntoh_msg_common -- convert rpmem_msg_common to host byte order */ static inline void rpmem_ntoh_msg_common(struct rpmem_msg_common *msg) { msg->major = be16toh(msg->major); msg->minor = be16toh(msg->minor); msg->pool_size = be64toh(msg->pool_size); msg->nlanes = be32toh(msg->nlanes); msg->provider = be32toh(msg->provider); msg->buff_size = be64toh(msg->buff_size); } /* * rpmem_hton_msg_common -- convert rpmem_msg_common to network byte order */ static inline void rpmem_hton_msg_common(struct rpmem_msg_common *msg) { rpmem_ntoh_msg_common(msg); } /* * rpmem_ntoh_msg_create -- convert rpmem_msg_create to host byte order */ static inline void rpmem_ntoh_msg_create(struct rpmem_msg_create *msg) { rpmem_ntoh_msg_hdr(&msg->hdr); rpmem_ntoh_msg_common(&msg->c); rpmem_ntoh_pool_attr(&msg->pool_attr); rpmem_ntoh_msg_pool_desc(&msg->pool_desc); } /* * rpmem_hton_msg_create -- convert rpmem_msg_create to network byte order */ static inline void rpmem_hton_msg_create(struct rpmem_msg_create *msg) { rpmem_ntoh_msg_create(msg); } /* * rpmem_ntoh_msg_create_resp -- convert rpmem_msg_create_resp to host byte * order */ static inline void rpmem_ntoh_msg_create_resp(struct rpmem_msg_create_resp *msg) { rpmem_ntoh_msg_hdr_resp(&msg->hdr); rpmem_ntoh_msg_ibc_attr(&msg->ibc); } /* * rpmem_hton_msg_create_resp -- convert rpmem_msg_create_resp to network byte * order */ static inline void rpmem_hton_msg_create_resp(struct rpmem_msg_create_resp *msg) { rpmem_ntoh_msg_create_resp(msg); } /* * rpmem_ntoh_msg_open -- convert rpmem_msg_open to host byte order */ static inline void rpmem_ntoh_msg_open(struct rpmem_msg_open *msg) { rpmem_ntoh_msg_hdr(&msg->hdr); rpmem_ntoh_msg_common(&msg->c); rpmem_ntoh_msg_pool_desc(&msg->pool_desc); } /* * XXX End: Suppress gcc conversion warnings for FreeBSD be*toh macros */ #pragma GCC diagnostic pop /* * rpmem_hton_msg_open -- convert rpmem_msg_open to network byte order */ static inline void rpmem_hton_msg_open(struct rpmem_msg_open *msg) { rpmem_ntoh_msg_open(msg); } /* * rpmem_ntoh_msg_open_resp -- convert rpmem_msg_open_resp to host byte order */ static inline void rpmem_ntoh_msg_open_resp(struct rpmem_msg_open_resp *msg) { rpmem_ntoh_msg_hdr_resp(&msg->hdr); rpmem_ntoh_msg_ibc_attr(&msg->ibc); rpmem_ntoh_pool_attr(&msg->pool_attr); } /* * rpmem_hton_msg_open_resp -- convert rpmem_msg_open_resp to network byte order */ static inline void rpmem_hton_msg_open_resp(struct rpmem_msg_open_resp *msg) { rpmem_ntoh_msg_open_resp(msg); } /* * rpmem_ntoh_msg_set_attr -- convert rpmem_msg_set_attr to host byte order */ static inline void rpmem_ntoh_msg_set_attr(struct rpmem_msg_set_attr *msg) { rpmem_ntoh_msg_hdr(&msg->hdr); rpmem_ntoh_pool_attr(&msg->pool_attr); } /* * rpmem_hton_msg_set_attr -- convert rpmem_msg_set_attr to network byte order */ static inline void rpmem_hton_msg_set_attr(struct rpmem_msg_set_attr *msg) { rpmem_ntoh_msg_set_attr(msg); } /* * rpmem_ntoh_msg_set_attr_resp -- convert rpmem_msg_set_attr_resp to host byte * order */ static inline void rpmem_ntoh_msg_set_attr_resp(struct rpmem_msg_set_attr_resp *msg) { rpmem_ntoh_msg_hdr_resp(&msg->hdr); } /* * rpmem_hton_msg_set_attr_resp -- convert rpmem_msg_set_attr_resp to network * byte order */ static inline void rpmem_hton_msg_set_attr_resp(struct rpmem_msg_set_attr_resp *msg) { rpmem_hton_msg_hdr_resp(&msg->hdr); } /* * rpmem_ntoh_msg_close -- convert rpmem_msg_close to host byte order */ static inline void rpmem_ntoh_msg_close(struct rpmem_msg_close *msg) { rpmem_ntoh_msg_hdr(&msg->hdr); } /* * rpmem_hton_msg_close -- convert rpmem_msg_close to network byte order */ static inline void rpmem_hton_msg_close(struct rpmem_msg_close *msg) { rpmem_ntoh_msg_close(msg); } /* * rpmem_ntoh_msg_close_resp -- convert rpmem_msg_close_resp to host byte order */ static inline void rpmem_ntoh_msg_close_resp(struct rpmem_msg_close_resp *msg) { rpmem_ntoh_msg_hdr_resp(&msg->hdr); } /* * rpmem_hton_msg_close_resp -- convert rpmem_msg_close_resp to network byte * order */ static inline void rpmem_hton_msg_close_resp(struct rpmem_msg_close_resp *msg) { rpmem_ntoh_msg_close_resp(msg); } /* * pack_rpmem_pool_attr -- copy pool attributes to a packed structure */ static inline void pack_rpmem_pool_attr(const struct rpmem_pool_attr *src, struct rpmem_pool_attr_packed *dst) { memcpy(dst->signature, src->signature, sizeof(src->signature)); dst->major = src->major; dst->compat_features = src->compat_features; dst->incompat_features = src->incompat_features; dst->ro_compat_features = src->ro_compat_features; memcpy(dst->poolset_uuid, src->poolset_uuid, sizeof(dst->poolset_uuid)); memcpy(dst->uuid, src->uuid, sizeof(dst->uuid)); memcpy(dst->next_uuid, src->next_uuid, sizeof(dst->next_uuid)); memcpy(dst->prev_uuid, src->prev_uuid, sizeof(dst->prev_uuid)); memcpy(dst->user_flags, src->user_flags, sizeof(dst->user_flags)); } /* * unpack_rpmem_pool_attr -- copy pool attributes to an unpacked structure */ static inline void unpack_rpmem_pool_attr(const struct rpmem_pool_attr_packed *src, struct rpmem_pool_attr *dst) { memcpy(dst->signature, src->signature, sizeof(src->signature)); dst->major = src->major; dst->compat_features = src->compat_features; dst->incompat_features = src->incompat_features; dst->ro_compat_features = src->ro_compat_features; memcpy(dst->poolset_uuid, src->poolset_uuid, sizeof(dst->poolset_uuid)); memcpy(dst->uuid, src->uuid, sizeof(dst->uuid)); memcpy(dst->next_uuid, src->next_uuid, sizeof(dst->next_uuid)); memcpy(dst->prev_uuid, src->prev_uuid, sizeof(dst->prev_uuid)); memcpy(dst->user_flags, src->user_flags, sizeof(dst->user_flags)); } #ifdef __cplusplus } #endif #endif
16,448
27.507799
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/rpmem_common/rpmem_fip_lane.h
/* * Copyright 2016-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_fip_lane.h -- rpmem fabric provider lane definition */ #include <sched.h> #include <stdint.h> #include "sys_util.h" /* * rpmem_fip_lane -- basic lane structure * * This structure consist of a synchronization object and a return value. * It is possible to wait on the lane for specified event. The event can be * signalled by another thread which can pass the return value if required. * * The sync variable can store up to 64 different events, each event on * separate bit. */ struct rpmem_fip_lane { os_spinlock_t lock; int ret; uint64_t sync; }; /* * rpmem_fip_lane_init -- initialize basic lane structure */ static inline int rpmem_fip_lane_init(struct rpmem_fip_lane *lanep) { lanep->ret = 0; lanep->sync = 0; return util_spin_init(&lanep->lock, PTHREAD_PROCESS_PRIVATE); } /* * rpmem_fip_lane_fini -- deinitialize basic lane structure */ static inline void rpmem_fip_lane_fini(struct rpmem_fip_lane *lanep) { util_spin_destroy(&lanep->lock); } /* * rpmem_fip_lane_busy -- return true if lane has pending events */ static inline int rpmem_fip_lane_busy(struct rpmem_fip_lane *lanep) { util_spin_lock(&lanep->lock); int ret = lanep->sync != 0; util_spin_unlock(&lanep->lock); return ret; } /* * rpmem_fip_lane_begin -- begin waiting for specified event(s) */ static inline void rpmem_fip_lane_begin(struct rpmem_fip_lane *lanep, uint64_t sig) { util_spin_lock(&lanep->lock); lanep->ret = 0; lanep->sync |= sig; util_spin_unlock(&lanep->lock); } static inline int rpmem_fip_lane_is_busy(struct rpmem_fip_lane *lanep, uint64_t sig) { util_spin_lock(&lanep->lock); int ret = (lanep->sync & sig) != 0; util_spin_unlock(&lanep->lock); return ret; } static inline int rpmem_fip_lane_ret(struct rpmem_fip_lane *lanep) { util_spin_lock(&lanep->lock); int ret = lanep->ret; util_spin_unlock(&lanep->lock); return ret; } /* * rpmem_fip_lane_wait -- wait for specified event(s) */ static inline int rpmem_fip_lane_wait(struct rpmem_fip_lane *lanep, uint64_t sig) { while (rpmem_fip_lane_is_busy(lanep, sig)) sched_yield(); return rpmem_fip_lane_ret(lanep); } /* * rpmem_fip_lane_signal -- signal lane about specified event */ static inline void rpmem_fip_lane_signal(struct rpmem_fip_lane *lanep, uint64_t sig) { util_spin_lock(&lanep->lock); lanep->sync &= ~sig; util_spin_unlock(&lanep->lock); } /* * rpmem_fip_lane_signal -- signal lane about specified event and store * return value */ static inline void rpmem_fip_lane_sigret(struct rpmem_fip_lane *lanep, uint64_t sig, int ret) { util_spin_lock(&lanep->lock); lanep->ret = ret; lanep->sync &= ~sig; util_spin_unlock(&lanep->lock); }
4,269
26.197452
75
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/rpmem_common/rpmem_fip_msg.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * rpmem_fip_msg.h -- simple wrappers for fi_rma(3) and fi_msg(3) functions */ #ifndef RPMEM_FIP_MSG_H #define RPMEM_FIP_MSG_H 1 #include <rdma/fi_rma.h> #ifdef __cplusplus extern "C" { #endif /* * rpmem_fip_rma -- helper struct for RMA operation */ struct rpmem_fip_rma { struct fi_msg_rma msg; /* message structure */ struct iovec msg_iov; /* IO vector buffer */ struct fi_rma_iov rma_iov; /* RMA IO vector buffer */ void *desc; /* local memory descriptor */ uint64_t flags; /* RMA operation flags */ }; /* * rpmem_fip_msg -- helper struct for MSG operation */ struct rpmem_fip_msg { struct fi_msg msg; /* message structure */ struct iovec iov; /* IO vector buffer */ void *desc; /* local memory descriptor */ uint64_t flags; /* MSG operation flags */ }; /* * rpmem_fip_rma_init -- initialize RMA helper struct */ static inline void rpmem_fip_rma_init(struct rpmem_fip_rma *rma, void *desc, fi_addr_t addr, uint64_t rkey, void *context, uint64_t flags) { memset(rma, 0, sizeof(*rma)); rma->desc = desc; rma->flags = flags; rma->rma_iov.key = rkey; rma->msg.context = context; rma->msg.addr = addr; rma->msg.desc = &rma->desc; rma->msg.rma_iov = &rma->rma_iov; rma->msg.rma_iov_count = 1; rma->msg.msg_iov = &rma->msg_iov; rma->msg.iov_count = 1; } /* * rpmem_fip_msg_init -- initialize MSG helper struct */ static inline void rpmem_fip_msg_init(struct rpmem_fip_msg *msg, void *desc, fi_addr_t addr, void *context, void *buff, size_t len, uint64_t flags) { memset(msg, 0, sizeof(*msg)); msg->desc = desc; msg->flags = flags; msg->iov.iov_base = buff; msg->iov.iov_len = len; msg->msg.context = context; msg->msg.addr = addr; msg->msg.desc = &msg->desc; msg->msg.msg_iov = &msg->iov; msg->msg.iov_count = 1; } /* * rpmem_fip_writemsg -- wrapper for fi_writemsg */ static inline int rpmem_fip_writemsg(struct fid_ep *ep, struct rpmem_fip_rma *rma, const void *buff, size_t len, uint64_t addr) { rma->rma_iov.addr = addr; rma->rma_iov.len = len; rma->msg_iov.iov_base = (void *)buff; rma->msg_iov.iov_len = len; return (int)fi_writemsg(ep, &rma->msg, rma->flags); } /* * rpmem_fip_readmsg -- wrapper for fi_readmsg */ static inline int rpmem_fip_readmsg(struct fid_ep *ep, struct rpmem_fip_rma *rma, void *buff, size_t len, uint64_t addr) { rma->rma_iov.addr = addr; rma->rma_iov.len = len; rma->msg_iov.iov_base = buff; rma->msg_iov.iov_len = len; return (int)fi_readmsg(ep, &rma->msg, rma->flags); } /* * rpmem_fip_sendmsg -- wrapper for fi_sendmsg */ static inline int rpmem_fip_sendmsg(struct fid_ep *ep, struct rpmem_fip_msg *msg, size_t len) { msg->iov.iov_len = len; return (int)fi_sendmsg(ep, &msg->msg, msg->flags); } /* * rpmem_fip_recvmsg -- wrapper for fi_recvmsg */ static inline int rpmem_fip_recvmsg(struct fid_ep *ep, struct rpmem_fip_msg *msg) { return (int)fi_recvmsg(ep, &msg->msg, msg->flags); } /* * rpmem_fip_msg_get_pmsg -- returns message buffer as a persist message */ static inline struct rpmem_msg_persist * rpmem_fip_msg_get_pmsg(struct rpmem_fip_msg *msg) { return (struct rpmem_msg_persist *)msg->iov.iov_base; } /* * rpmem_fip_msg_get_pres -- returns message buffer as a persist response */ static inline struct rpmem_msg_persist_resp * rpmem_fip_msg_get_pres(struct rpmem_fip_msg *msg) { return (struct rpmem_msg_persist_resp *)msg->iov.iov_base; } #ifdef __cplusplus } #endif #endif
5,009
27.465909
75
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmempool/replica.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * replica.h -- module for synchronizing and transforming poolset */ #ifndef REPLICA_H #define REPLICA_H #include "libpmempool.h" #include "pool.h" #include "os_badblock.h" #ifdef __cplusplus extern "C" { #endif #define UNDEF_REPLICA UINT_MAX #define UNDEF_PART UINT_MAX /* * A part marked as broken does not exist or is damaged so that * it cannot be opened and has to be recreated. */ #define IS_BROKEN (1U << 0) /* * A replica marked as inconsistent exists but has inconsistent metadata * (e.g. inconsistent parts or replicas linkage) */ #define IS_INCONSISTENT (1U << 1) /* * A part or replica marked in this way has bad blocks inside. */ #define HAS_BAD_BLOCKS (1U << 2) /* * A part marked in this way has bad blocks in the header */ #define HAS_CORRUPTED_HEADER (1U << 3) /* * A flag which can be passed to sync_replica() to indicate that the function is * called by pmempool_transform */ #define IS_TRANSFORMED (1U << 10) /* * Number of lanes utilized when working with remote replicas */ #define REMOTE_NLANES 1 /* * Helping structures for storing part's health status */ struct part_health_status { unsigned flags; struct badblocks bbs; /* structure with bad blocks */ char *recovery_file_name; /* name of bad block recovery file */ int recovery_file_exists; /* bad block recovery file exists */ }; /* * Helping structures for storing replica and poolset's health status */ struct replica_health_status { unsigned nparts; unsigned nhdrs; /* a flag for the replica */ unsigned flags; /* effective size of a pool, valid only for healthy replica */ size_t pool_size; /* flags for each part */ struct part_health_status part[]; }; struct poolset_health_status { unsigned nreplicas; /* a flag for the poolset */ unsigned flags; /* health statuses for each replica */ struct replica_health_status *replica[]; }; /* get index of the (r)th replica health status */ static inline unsigned REP_HEALTHidx(struct poolset_health_status *set, unsigned r) { ASSERTne(set->nreplicas, 0); return (set->nreplicas + r) % set->nreplicas; } /* get index of the (r + 1)th replica health status */ static inline unsigned REPN_HEALTHidx(struct poolset_health_status *set, unsigned r) { ASSERTne(set->nreplicas, 0); return (set->nreplicas + r + 1) % set->nreplicas; } /* get (p)th part health status */ static inline unsigned PART_HEALTHidx(struct replica_health_status *rep, unsigned p) { ASSERTne(rep->nparts, 0); return (rep->nparts + p) % rep->nparts; } /* get (r)th replica health status */ static inline struct replica_health_status * REP_HEALTH(struct poolset_health_status *set, unsigned r) { return set->replica[REP_HEALTHidx(set, r)]; } /* get (p)th part health status */ static inline unsigned PART_HEALTH(struct replica_health_status *rep, unsigned p) { return rep->part[PART_HEALTHidx(rep, p)].flags; } uint64_t replica_get_part_offset(struct pool_set *set, unsigned repn, unsigned partn); void replica_align_badblock_offset_length(size_t *offset, size_t *length, struct pool_set *set_in, unsigned repn, unsigned partn); size_t replica_get_part_data_len(struct pool_set *set_in, unsigned repn, unsigned partn); uint64_t replica_get_part_data_offset(struct pool_set *set_in, unsigned repn, unsigned part); /* * is_dry_run -- (internal) check whether only verification mode is enabled */ static inline bool is_dry_run(unsigned flags) { /* * PMEMPOOL_SYNC_DRY_RUN and PMEMPOOL_TRANSFORM_DRY_RUN * have to have the same value in order to use this common function. */ ASSERT_COMPILE_ERROR_ON(PMEMPOOL_SYNC_DRY_RUN != PMEMPOOL_TRANSFORM_DRY_RUN); return flags & PMEMPOOL_SYNC_DRY_RUN; } /* * fix_bad_blocks -- (internal) fix bad blocks - it causes reading or creating * bad blocks recovery files * (depending on if they exist or not) */ static inline bool fix_bad_blocks(unsigned flags) { return flags & PMEMPOOL_SYNC_FIX_BAD_BLOCKS; } int replica_remove_all_recovery_files(struct poolset_health_status *set_hs); int replica_remove_part(struct pool_set *set, unsigned repn, unsigned partn, int fix_bad_blocks); int replica_create_poolset_health_status(struct pool_set *set, struct poolset_health_status **set_hsp); void replica_free_poolset_health_status(struct poolset_health_status *set_s); int replica_check_poolset_health(struct pool_set *set, struct poolset_health_status **set_hs, int called_from_sync, unsigned flags); int replica_is_part_broken(unsigned repn, unsigned partn, struct poolset_health_status *set_hs); int replica_has_bad_blocks(unsigned repn, struct poolset_health_status *set_hs); int replica_part_has_bad_blocks(struct part_health_status *phs); int replica_part_has_corrupted_header(unsigned repn, unsigned partn, struct poolset_health_status *set_hs); unsigned replica_find_unbroken_part(unsigned repn, struct poolset_health_status *set_hs); int replica_is_replica_broken(unsigned repn, struct poolset_health_status *set_hs); int replica_is_replica_consistent(unsigned repn, struct poolset_health_status *set_hs); int replica_is_replica_healthy(unsigned repn, struct poolset_health_status *set_hs); unsigned replica_find_healthy_replica( struct poolset_health_status *set_hs); unsigned replica_find_replica_healthy_header( struct poolset_health_status *set_hs); int replica_is_poolset_healthy(struct poolset_health_status *set_hs); int replica_is_poolset_transformed(unsigned flags); ssize_t replica_get_pool_size(struct pool_set *set, unsigned repn); int replica_check_part_sizes(struct pool_set *set, size_t min_size); int replica_check_part_dirs(struct pool_set *set); int replica_check_local_part_dir(struct pool_set *set, unsigned repn, unsigned partn); int replica_open_replica_part_files(struct pool_set *set, unsigned repn); int replica_open_poolset_part_files(struct pool_set *set); int replica_sync(struct pool_set *set_in, struct poolset_health_status *set_hs, unsigned flags); int replica_transform(struct pool_set *set_in, struct pool_set *set_out, unsigned flags); #ifdef __cplusplus } #endif #endif
7,734
30.96281
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmempool/check.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * check.h -- internal definitions for logic performing check */ #ifndef CHECK_H #define CHECK_H #ifdef __cplusplus extern "C" { #endif int check_init(PMEMpoolcheck *ppc); struct check_status *check_step(PMEMpoolcheck *ppc); void check_fini(PMEMpoolcheck *ppc); int check_is_end(struct check_data *data); struct pmempool_check_status *check_status_get(struct check_status *status); #ifdef _WIN32 void convert_status_cache(PMEMpoolcheck *ppc, char *buf, size_t size); #endif #ifdef __cplusplus } #endif #endif
2,122
34.383333
76
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmempool/check_util.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * check_util.h -- internal definitions check util */ #ifndef CHECK_UTIL_H #define CHECK_UTIL_H #include <time.h> #include <limits.h> #include <sys/param.h> #ifdef __cplusplus extern "C" { #endif #define CHECK_STEP_COMPLETE UINT_MAX #define CHECK_INVALID_QUESTION UINT_MAX #define REQUIRE_ADVANCED "the following error can be fixed using " \ "PMEMPOOL_CHECK_ADVANCED flag" #ifndef min #define min(a, b) ((a) < (b) ? (a) : (b)) #endif /* check control context */ struct check_data; struct arena; /* queue of check statuses */ struct check_status; /* container storing state of all check steps */ #define PREFIX_MAX_SIZE 30 typedef struct { unsigned init_done; unsigned step; unsigned replica; unsigned part; int single_repl; int single_part; struct pool_set *set; int is_dev_dax; struct pool_hdr *hdrp; /* copy of the pool header in host byte order */ struct pool_hdr hdr; int hdr_valid; /* * If pool header has been modified this field indicates that * the pool parameters structure requires refresh. */ int pool_hdr_modified; unsigned healthy_replicas; struct pool_hdr *next_part_hdrp; struct pool_hdr *prev_part_hdrp; struct pool_hdr *next_repl_hdrp; struct pool_hdr *prev_repl_hdrp; int next_part_hdr_valid; int prev_part_hdr_valid; int next_repl_hdr_valid; int prev_repl_hdr_valid; /* valid poolset uuid */ uuid_t *valid_puuid; /* valid part uuid */ uuid_t *valid_uuid; /* valid part pool header */ struct pool_hdr *valid_part_hdrp; int valid_part_done; unsigned valid_part_replica; char prefix[PREFIX_MAX_SIZE]; struct arena *arenap; uint64_t offset; uint32_t narena; uint8_t *bitmap; uint8_t *dup_bitmap; uint8_t *fbitmap; struct list *list_inval; struct list *list_flog_inval; struct list *list_unmap; struct { int btti_header; int btti_backup; } valid; struct { struct btt_info btti; uint64_t btti_offset; } pool_valid; } location; /* check steps */ void check_bad_blocks(PMEMpoolcheck *ppc); void check_backup(PMEMpoolcheck *ppc); void check_pool_hdr(PMEMpoolcheck *ppc); void check_pool_hdr_uuids(PMEMpoolcheck *ppc); void check_sds(PMEMpoolcheck *ppc); void check_log(PMEMpoolcheck *ppc); void check_blk(PMEMpoolcheck *ppc); void check_cto(PMEMpoolcheck *ppc); void check_btt_info(PMEMpoolcheck *ppc); void check_btt_map_flog(PMEMpoolcheck *ppc); void check_write(PMEMpoolcheck *ppc); struct check_data *check_data_alloc(void); void check_data_free(struct check_data *data); uint32_t check_step_get(struct check_data *data); void check_step_inc(struct check_data *data); location *check_get_step_data(struct check_data *data); void check_end(struct check_data *data); int check_is_end_util(struct check_data *data); int check_status_create(PMEMpoolcheck *ppc, enum pmempool_check_msg_type type, uint32_t arg, const char *fmt, ...) FORMAT_PRINTF(4, 5); void check_status_release(PMEMpoolcheck *ppc, struct check_status *status); void check_clear_status_cache(struct check_data *data); struct check_status *check_pop_question(struct check_data *data); struct check_status *check_pop_error(struct check_data *data); struct check_status *check_pop_info(struct check_data *data); bool check_has_error(struct check_data *data); bool check_has_answer(struct check_data *data); int check_push_answer(PMEMpoolcheck *ppc); struct pmempool_check_status *check_status_get_util( struct check_status *status); int check_status_is(struct check_status *status, enum pmempool_check_msg_type type); /* create info status */ #define CHECK_INFO(ppc, ...)\ check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_INFO, 0, __VA_ARGS__) /* create info status and append error message based on errno */ #define CHECK_INFO_ERRNO(ppc, ...)\ check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_INFO,\ (uint32_t)errno, __VA_ARGS__) /* create error status */ #define CHECK_ERR(ppc, ...)\ check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_ERROR, 0, __VA_ARGS__) /* create question status */ #define CHECK_ASK(ppc, question, ...)\ check_status_create(ppc, PMEMPOOL_CHECK_MSG_TYPE_QUESTION, question,\ __VA_ARGS__) #define CHECK_NOT_COMPLETE(loc, steps)\ ((loc)->step != CHECK_STEP_COMPLETE &&\ ((steps)[(loc)->step].check != NULL ||\ (steps)[(loc)->step].fix != NULL)) int check_answer_loop(PMEMpoolcheck *ppc, location *data, void *ctx, int fail_on_no, int (*callback)(PMEMpoolcheck *, location *, uint32_t, void *ctx)); int check_questions_sequence_validate(PMEMpoolcheck *ppc); const char *check_get_time_str(time_t time); const char *check_get_uuid_str(uuid_t uuid); const char *check_get_pool_type_str(enum pool_type type); void check_insert_arena(PMEMpoolcheck *ppc, struct arena *arenap); #ifdef _WIN32 void cache_to_utf8(struct check_data *data, char *buf, size_t size); #endif #define CHECK_IS(ppc, flag)\ util_flag_isset((ppc)->args.flags, PMEMPOOL_CHECK_ ## flag) #define CHECK_IS_NOT(ppc, flag)\ util_flag_isclr((ppc)->args.flags, PMEMPOOL_CHECK_ ## flag) #define CHECK_WITHOUT_FIXING(ppc)\ CHECK_IS_NOT(ppc, REPAIR) || CHECK_IS(ppc, DRY_RUN) #ifdef __cplusplus } #endif #endif
6,694
28.493392
78
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmempool/pmempool.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * pmempool.h -- internal definitions for libpmempool */ #ifndef PMEMPOOL_H #define PMEMPOOL_H #ifdef __cplusplus extern "C" { #endif #define PMEMPOOL_LOG_PREFIX "libpmempool" #define PMEMPOOL_LOG_LEVEL_VAR "PMEMPOOL_LOG_LEVEL" #define PMEMPOOL_LOG_FILE_VAR "PMEMPOOL_LOG_FILE" enum check_result { CHECK_RESULT_CONSISTENT, CHECK_RESULT_NOT_CONSISTENT, CHECK_RESULT_ASK_QUESTIONS, CHECK_RESULT_PROCESS_ANSWERS, CHECK_RESULT_REPAIRED, CHECK_RESULT_CANNOT_REPAIR, CHECK_RESULT_ERROR, CHECK_RESULT_INTERNAL_ERROR }; /* * pmempool_check_ctx -- context and arguments for check command */ struct pmempool_check_ctx { struct pmempool_check_args args; char *path; char *backup_path; struct check_data *data; struct pool_data *pool; enum check_result result; unsigned sync_required; }; #ifdef __cplusplus } #endif #endif
2,442
30.320513
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmempool/pool.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * pool.h -- internal definitions for pool processing functions */ #ifndef POOL_H #define POOL_H #include <stdbool.h> #include <sys/types.h> #include "libpmemobj.h" #include "libpmemcto.h" #include "queue.h" #include "set.h" #include "log.h" #include "blk.h" #include "btt_layout.h" #include "cto.h" #ifdef __cplusplus extern "C" { #endif enum pool_type { POOL_TYPE_UNKNOWN = (1 << 0), POOL_TYPE_LOG = (1 << 1), POOL_TYPE_BLK = (1 << 2), POOL_TYPE_OBJ = (1 << 3), POOL_TYPE_BTT = (1 << 4), POOL_TYPE_CTO = (1 << 5), POOL_TYPE_ANY = POOL_TYPE_UNKNOWN | POOL_TYPE_LOG | POOL_TYPE_BLK | POOL_TYPE_OBJ | POOL_TYPE_BTT | POOL_TYPE_CTO, }; struct pool_params { enum pool_type type; char signature[POOL_HDR_SIG_LEN]; features_t features; size_t size; mode_t mode; int is_poolset; int is_part; int is_dev_dax; int is_pmem; union { struct { uint64_t bsize; } blk; struct { char layout[PMEMOBJ_MAX_LAYOUT]; } obj; struct { char layout[PMEMCTO_MAX_LAYOUT]; } cto; }; }; struct pool_set_file { int fd; char *fname; void *addr; size_t size; struct pool_set *poolset; time_t mtime; mode_t mode; }; struct arena { TAILQ_ENTRY(arena) next; struct btt_info btt_info; uint32_t id; bool valid; bool zeroed; uint64_t offset; uint8_t *flog; size_t flogsize; uint32_t *map; size_t mapsize; }; struct pool_data { struct pool_params params; struct pool_set_file *set_file; int blk_no_layout; union { struct pool_hdr pool; struct pmemlog log; struct pmemblk blk; struct pmemcto cto; } hdr; enum { UUID_NOP = 0, UUID_FROM_BTT, UUID_NOT_FROM_BTT, } uuid_op; struct arena bttc; TAILQ_HEAD(arenashead, arena) arenas; uint32_t narenas; }; struct pool_data *pool_data_alloc(PMEMpoolcheck *ppc); void pool_data_free(struct pool_data *pool); void pool_params_from_header(struct pool_params *params, const struct pool_hdr *hdr); int pool_set_parse(struct pool_set **setp, const char *path); void *pool_set_file_map(struct pool_set_file *file, uint64_t offset); int pool_read(struct pool_data *pool, void *buff, size_t nbytes, uint64_t off); int pool_write(struct pool_data *pool, const void *buff, size_t nbytes, uint64_t off); int pool_copy(struct pool_data *pool, const char *dst_path, int overwrite); int pool_set_part_copy(struct pool_set_part *dpart, struct pool_set_part *spart, int overwrite); int pool_memset(struct pool_data *pool, uint64_t off, int c, size_t count); unsigned pool_set_files_count(struct pool_set_file *file); int pool_set_file_map_headers(struct pool_set_file *file, int rdonly, int prv); void pool_set_file_unmap_headers(struct pool_set_file *file); void pool_hdr_default(enum pool_type type, struct pool_hdr *hdrp); enum pool_type pool_hdr_get_type(const struct pool_hdr *hdrp); enum pool_type pool_set_type(struct pool_set *set); const char *pool_get_pool_type_str(enum pool_type type); int pool_btt_info_valid(struct btt_info *infop); int pool_blk_get_first_valid_arena(struct pool_data *pool, struct arena *arenap); int pool_blk_bsize_valid(uint32_t bsize, uint64_t fsize); uint64_t pool_next_arena_offset(struct pool_data *pool, uint64_t header_offset); uint64_t pool_get_first_valid_btt(struct pool_data *pool, struct btt_info *infop, uint64_t offset, bool *zeroed); size_t pool_get_min_size(enum pool_type); #ifdef __cplusplus } #endif #endif
4,963
27.365714
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/pmem.h
/* * Copyright 2014-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * pmem.h -- internal definitions for libpmem */ #ifndef PMEM_H #define PMEM_H #include <stddef.h> #include "libpmem.h" #include "util.h" #ifdef __cplusplus extern "C" { #endif #define PMEM_LOG_PREFIX "libpmem" #define PMEM_LOG_LEVEL_VAR "PMEM_LOG_LEVEL" #define PMEM_LOG_FILE_VAR "PMEM_LOG_FILE" typedef void (*predrain_fence_func)(void); typedef void (*flush_func)(const void *, size_t); typedef int (*is_pmem_func)(const void *addr, size_t len); typedef void *(*memmove_nodrain_func)(void *pmemdest, const void *src, size_t len, unsigned flags); typedef void *(*memset_nodrain_func)(void *pmemdest, int c, size_t len, unsigned flags); struct pmem_funcs { predrain_fence_func predrain_fence; flush_func flush; is_pmem_func is_pmem; memmove_nodrain_func memmove_nodrain; memset_nodrain_func memset_nodrain; flush_func deep_flush; }; void pmem_init(void); void pmem_os_init(void); void pmem_init_funcs(struct pmem_funcs *funcs); int is_pmem_detect(const void *addr, size_t len); void *pmem_map_register(int fd, size_t len, const char *path, int is_dev_dax); /* * flush_empty_nolog -- (internal) do not flush the CPU cache */ static force_inline void flush_empty_nolog(const void *addr, size_t len) { /* NOP */ } /* * flush64b_empty -- (internal) do not flush the CPU cache */ static force_inline void flush64b_empty(const char *addr) { } /* * pmem_flush_flags -- internal wrapper around pmem_flush */ static inline void pmem_flush_flags(const void *addr, size_t len, unsigned flags) { if (!(flags & PMEM_F_MEM_NOFLUSH)) pmem_flush(addr, len); } void *memmove_nodrain_generic(void *pmemdest, const void *src, size_t len, unsigned flags); void *memset_nodrain_generic(void *pmemdest, int c, size_t len, unsigned flags); #ifdef __cplusplus } #endif #endif
3,394
29.585586
80
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/flush.h
/* * Copyright 2014-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef X86_64_FLUSH_H #define X86_64_FLUSH_H #include <emmintrin.h> #include <stddef.h> #include <stdint.h> #include "util.h" #define FLUSH_ALIGN ((uintptr_t)64) #ifdef _MSC_VER #define pmem_clflushopt _mm_clflushopt #define pmem_clwb _mm_clwb #else /* * The x86 memory instructions are new enough that the compiler * intrinsic functions are not always available. The intrinsic * functions are defined here in terms of asm statements for now. */ #define pmem_clflushopt(addr)\ asm volatile(".byte 0x66; clflush %0" : "+m" \ (*(volatile char *)(addr))); #define pmem_clwb(addr)\ asm volatile(".byte 0x66; xsaveopt %0" : "+m" \ (*(volatile char *)(addr))); #endif /* _MSC_VER */ /* * flush_clflush_nolog -- flush the CPU cache, using clflush */ static force_inline void flush_clflush_nolog(const void *addr, size_t len) { uintptr_t uptr; /* * Loop through cache-line-size (typically 64B) aligned chunks * covering the given range. */ for (uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1); uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN) _mm_clflush((char *)uptr); } /* * flush_clflushopt_nolog -- flush the CPU cache, using clflushopt */ static force_inline void flush_clflushopt_nolog(const void *addr, size_t len) { uintptr_t uptr; /* * Loop through cache-line-size (typically 64B) aligned chunks * covering the given range. */ for (uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1); uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN) { pmem_clflushopt((char *)uptr); } } /* * flush_clwb_nolog -- flush the CPU cache, using clwb */ static force_inline void flush_clwb_nolog(const void *addr, size_t len) { uintptr_t uptr; /* * Loop through cache-line-size (typically 64B) aligned chunks * covering the given range. */ for (uptr = (uintptr_t)addr & ~(FLUSH_ALIGN - 1); uptr < (uintptr_t)addr + len; uptr += FLUSH_ALIGN) { pmem_clwb((char *)uptr); } } #endif
3,520
29.885965
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/cpu.h
/* * Copyright 2016-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMDK_CPU_H #define PMDK_CPU_H 1 /* * cpu.h -- definitions for "cpu" module */ int is_cpu_genuine_intel(void); int is_cpu_clflush_present(void); int is_cpu_clflushopt_present(void); int is_cpu_clwb_present(void); int is_cpu_avx_present(void); int is_cpu_avx512f_present(void); #endif
1,898
38.5625
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/avx.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMEM_AVX_H #define PMEM_AVX_H #include <immintrin.h> #include "util.h" /* * avx_zeroupper -- _mm256_zeroupper wrapper * * _mm256_zeroupper clears upper parts of avx registers. * * It's needed for 2 reasons: * - it improves performance of non-avx code after avx * - it works around problem discovered by Valgrind * * In optimized builds gcc inserts VZEROUPPER automatically before * calling non-avx code (or at the end of the function). But in release * builds it doesn't, so if we don't do this by ourselves, then when * someone memcpy'ies uninitialized data, Valgrind complains whenever * someone reads those registers. * * One notable example is loader, which tries to detect whether it * needs to save whole ymm registers by looking at their current * (possibly uninitialized) value. * * Valgrind complains like that: * Conditional jump or move depends on uninitialised value(s) * at 0x4015CC9: _dl_runtime_resolve_avx_slow * (in /lib/x86_64-linux-gnu/ld-2.24.so) * by 0x10B531: test_realloc_api (obj_basic_integration.c:185) * by 0x10F1EE: main (obj_basic_integration.c:594) * * Note: We have to be careful to not read AVX registers after this * intrinsic, because of this stupid gcc bug: * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82735 */ static force_inline void avx_zeroupper(void) { _mm256_zeroupper(); } static force_inline __m128i m256_get16b(__m256i ymm) { return _mm256_extractf128_si256(ymm, 0); } #ifdef _MSC_VER static force_inline uint64_t m256_get8b(__m256i ymm) { return (uint64_t)_mm_extract_epi64(m256_get16b(ymm), 0); } static force_inline uint32_t m256_get4b(__m256i ymm) { return (uint32_t)m256_get8b(ymm); } static force_inline uint16_t m256_get2b(__m256i ymm) { return (uint16_t)m256_get8b(ymm); } #else static force_inline uint64_t m256_get8b(__m256i ymm) { return (uint64_t)_mm256_extract_epi64(ymm, 0); } static force_inline uint32_t m256_get4b(__m256i ymm) { return (uint32_t)_mm256_extract_epi32(ymm, 0); } static force_inline uint16_t m256_get2b(__m256i ymm) { return (uint16_t)_mm256_extract_epi16(ymm, 0); } #endif #endif
3,753
31.362069
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memcpy_memset.h
/* * Copyright 2014-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef MEMCPY_MEMSET_H #define MEMCPY_MEMSET_H #include <stddef.h> #include <xmmintrin.h> #include "pmem.h" static inline void barrier_after_ntstores(void) { /* * In this configuration pmem_drain does not contain sfence, so we have * to serialize non-temporal store instructions. */ _mm_sfence(); } static inline void no_barrier_after_ntstores(void) { /* * In this configuration pmem_drain contains sfence, so we don't have * to serialize non-temporal store instructions */ } #ifndef AVX512F_AVAILABLE /* XXX not supported in MSVC version we currently use */ #ifdef _MSC_VER #define AVX512F_AVAILABLE 0 #else #define AVX512F_AVAILABLE 1 #endif #endif #ifndef AVX_AVAILABLE #define AVX_AVAILABLE 1 #endif #ifndef SSE2_AVAILABLE #define SSE2_AVAILABLE 1 #endif #if SSE2_AVAILABLE void memmove_mov_sse2_clflush(char *dest, const char *src, size_t len); void memmove_mov_sse2_clflushopt(char *dest, const char *src, size_t len); void memmove_mov_sse2_clwb(char *dest, const char *src, size_t len); void memmove_mov_sse2_empty(char *dest, const char *src, size_t len); void memmove_movnt_sse2_clflush(char *dest, const char *src, size_t len); void memmove_movnt_sse2_clflushopt(char *dest, const char *src, size_t len); void memmove_movnt_sse2_clwb(char *dest, const char *src, size_t len); void memmove_movnt_sse2_empty(char *dest, const char *src, size_t len); void memset_mov_sse2_clflush(char *dest, int c, size_t len); void memset_mov_sse2_clflushopt(char *dest, int c, size_t len); void memset_mov_sse2_clwb(char *dest, int c, size_t len); void memset_mov_sse2_empty(char *dest, int c, size_t len); void memset_movnt_sse2_clflush(char *dest, int c, size_t len); void memset_movnt_sse2_clflushopt(char *dest, int c, size_t len); void memset_movnt_sse2_clwb(char *dest, int c, size_t len); void memset_movnt_sse2_empty(char *dest, int c, size_t len); #endif #if AVX_AVAILABLE void memmove_mov_avx_clflush(char *dest, const char *src, size_t len); void memmove_mov_avx_clflushopt(char *dest, const char *src, size_t len); void memmove_mov_avx_clwb(char *dest, const char *src, size_t len); void memmove_mov_avx_empty(char *dest, const char *src, size_t len); void memmove_movnt_avx_clflush(char *dest, const char *src, size_t len); void memmove_movnt_avx_clflushopt(char *dest, const char *src, size_t len); void memmove_movnt_avx_clwb(char *dest, const char *src, size_t len); void memmove_movnt_avx_empty(char *dest, const char *src, size_t len); void memset_mov_avx_clflush(char *dest, int c, size_t len); void memset_mov_avx_clflushopt(char *dest, int c, size_t len); void memset_mov_avx_clwb(char *dest, int c, size_t len); void memset_mov_avx_empty(char *dest, int c, size_t len); void memset_movnt_avx_clflush(char *dest, int c, size_t len); void memset_movnt_avx_clflushopt(char *dest, int c, size_t len); void memset_movnt_avx_clwb(char *dest, int c, size_t len); void memset_movnt_avx_empty(char *dest, int c, size_t len); #endif #if AVX512F_AVAILABLE void memmove_mov_avx512f_clflush(char *dest, const char *src, size_t len); void memmove_mov_avx512f_clflushopt(char *dest, const char *src, size_t len); void memmove_mov_avx512f_clwb(char *dest, const char *src, size_t len); void memmove_mov_avx512f_empty(char *dest, const char *src, size_t len); void memmove_movnt_avx512f_clflush(char *dest, const char *src, size_t len); void memmove_movnt_avx512f_clflushopt(char *dest, const char *src, size_t len); void memmove_movnt_avx512f_clwb(char *dest, const char *src, size_t len); void memmove_movnt_avx512f_empty(char *dest, const char *src, size_t len); void memset_mov_avx512f_clflush(char *dest, int c, size_t len); void memset_mov_avx512f_clflushopt(char *dest, int c, size_t len); void memset_mov_avx512f_clwb(char *dest, int c, size_t len); void memset_mov_avx512f_empty(char *dest, int c, size_t len); void memset_movnt_avx512f_clflush(char *dest, int c, size_t len); void memset_movnt_avx512f_clflushopt(char *dest, int c, size_t len); void memset_movnt_avx512f_clwb(char *dest, int c, size_t len); void memset_movnt_avx512f_empty(char *dest, int c, size_t len); #endif extern size_t Movnt_threshold; #endif
5,754
41.316176
79
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_avx512f.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMEM_MEMSET_AVX512F_H #define PMEM_MEMSET_AVX512F_H #include <stddef.h> #include "memset_avx.h" static force_inline void memset_small_avx512f(char *dest, __m256i ymm, size_t len) { /* We can't do better than AVX here. */ memset_small_avx(dest, ymm, len); } #endif
1,880
38.1875
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_nt_sse2.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem.h" #include "flush.h" #include "libpmem.h" #include "memcpy_memset.h" #include "memset_sse2.h" #include "out.h" #include "valgrind_internal.h" static force_inline void memset_movnt4x64b(char *dest, __m128i xmm) { _mm_stream_si128((__m128i *)dest + 0, xmm); _mm_stream_si128((__m128i *)dest + 1, xmm); _mm_stream_si128((__m128i *)dest + 2, xmm); _mm_stream_si128((__m128i *)dest + 3, xmm); _mm_stream_si128((__m128i *)dest + 4, xmm); _mm_stream_si128((__m128i *)dest + 5, xmm); _mm_stream_si128((__m128i *)dest + 6, xmm); _mm_stream_si128((__m128i *)dest + 7, xmm); _mm_stream_si128((__m128i *)dest + 8, xmm); _mm_stream_si128((__m128i *)dest + 9, xmm); _mm_stream_si128((__m128i *)dest + 10, xmm); _mm_stream_si128((__m128i *)dest + 11, xmm); _mm_stream_si128((__m128i *)dest + 12, xmm); _mm_stream_si128((__m128i *)dest + 13, xmm); _mm_stream_si128((__m128i *)dest + 14, xmm); _mm_stream_si128((__m128i *)dest + 15, xmm); VALGRIND_DO_FLUSH(dest, 4 * 64); } static force_inline void memset_movnt2x64b(char *dest, __m128i xmm) { _mm_stream_si128((__m128i *)dest + 0, xmm); _mm_stream_si128((__m128i *)dest + 1, xmm); _mm_stream_si128((__m128i *)dest + 2, xmm); _mm_stream_si128((__m128i *)dest + 3, xmm); _mm_stream_si128((__m128i *)dest + 4, xmm); _mm_stream_si128((__m128i *)dest + 5, xmm); _mm_stream_si128((__m128i *)dest + 6, xmm); _mm_stream_si128((__m128i *)dest + 7, xmm); VALGRIND_DO_FLUSH(dest, 2 * 64); } static force_inline void memset_movnt1x64b(char *dest, __m128i xmm) { _mm_stream_si128((__m128i *)dest + 0, xmm); _mm_stream_si128((__m128i *)dest + 1, xmm); _mm_stream_si128((__m128i *)dest + 2, xmm); _mm_stream_si128((__m128i *)dest + 3, xmm); VALGRIND_DO_FLUSH(dest, 64); } static force_inline void memset_movnt1x32b(char *dest, __m128i xmm) { _mm_stream_si128((__m128i *)dest + 0, xmm); _mm_stream_si128((__m128i *)dest + 1, xmm); VALGRIND_DO_FLUSH(dest, 32); } static force_inline void memset_movnt1x16b(char *dest, __m128i xmm) { _mm_stream_si128((__m128i *)dest, xmm); VALGRIND_DO_FLUSH(dest, 16); } static force_inline void memset_movnt1x8b(char *dest, __m128i xmm) { uint64_t x = (uint64_t)_mm_cvtsi128_si64(xmm); _mm_stream_si64((long long *)dest, (long long)x); VALGRIND_DO_FLUSH(dest, 8); } static force_inline void memset_movnt1x4b(char *dest, __m128i xmm) { uint32_t x = (uint32_t)_mm_cvtsi128_si32(xmm); _mm_stream_si32((int *)dest, (int)x); VALGRIND_DO_FLUSH(dest, 4); } void EXPORTED_SYMBOL(char *dest, int c, size_t len) { __m128i xmm = _mm_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_sse2(dest, xmm, cnt); dest += cnt; len -= cnt; } while (len >= 4 * 64) { memset_movnt4x64b(dest, xmm); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_movnt2x64b(dest, xmm); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_movnt1x64b(dest, xmm); dest += 1 * 64; len -= 1 * 64; } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) memset_movnt1x32b(dest, xmm); else if (len == 16) memset_movnt1x16b(dest, xmm); else if (len == 8) memset_movnt1x8b(dest, xmm); else if (len == 4) memset_movnt1x4b(dest, xmm); else goto nonnt; goto end; } nonnt: memset_small_sse2(dest, xmm, len); end: maybe_barrier(); }
5,136
25.755208
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_t_sse2.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem.h" #include "flush.h" #include "memcpy_memset.h" #include "memset_sse2.h" static force_inline void memset_mov4x64b(char *dest, __m128i xmm) { _mm_store_si128((__m128i *)dest + 0, xmm); _mm_store_si128((__m128i *)dest + 1, xmm); _mm_store_si128((__m128i *)dest + 2, xmm); _mm_store_si128((__m128i *)dest + 3, xmm); _mm_store_si128((__m128i *)dest + 4, xmm); _mm_store_si128((__m128i *)dest + 5, xmm); _mm_store_si128((__m128i *)dest + 6, xmm); _mm_store_si128((__m128i *)dest + 7, xmm); _mm_store_si128((__m128i *)dest + 8, xmm); _mm_store_si128((__m128i *)dest + 9, xmm); _mm_store_si128((__m128i *)dest + 10, xmm); _mm_store_si128((__m128i *)dest + 11, xmm); _mm_store_si128((__m128i *)dest + 12, xmm); _mm_store_si128((__m128i *)dest + 13, xmm); _mm_store_si128((__m128i *)dest + 14, xmm); _mm_store_si128((__m128i *)dest + 15, xmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memset_mov2x64b(char *dest, __m128i xmm) { _mm_store_si128((__m128i *)dest + 0, xmm); _mm_store_si128((__m128i *)dest + 1, xmm); _mm_store_si128((__m128i *)dest + 2, xmm); _mm_store_si128((__m128i *)dest + 3, xmm); _mm_store_si128((__m128i *)dest + 4, xmm); _mm_store_si128((__m128i *)dest + 5, xmm); _mm_store_si128((__m128i *)dest + 6, xmm); _mm_store_si128((__m128i *)dest + 7, xmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memset_mov1x64b(char *dest, __m128i xmm) { _mm_store_si128((__m128i *)dest + 0, xmm); _mm_store_si128((__m128i *)dest + 1, xmm); _mm_store_si128((__m128i *)dest + 2, xmm); _mm_store_si128((__m128i *)dest + 3, xmm); flush64b(dest + 0 * 64); } void EXPORTED_SYMBOL(char *dest, int c, size_t len) { __m128i xmm = _mm_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_sse2(dest, xmm, cnt); dest += cnt; len -= cnt; } while (len >= 4 * 64) { memset_mov4x64b(dest, xmm); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_mov2x64b(dest, xmm); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_mov1x64b(dest, xmm); dest += 1 * 64; len -= 1 * 64; } if (len) memset_small_sse2(dest, xmm, len); }
3,985
28.525926
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_nt_avx.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem.h" #include "avx.h" #include "flush.h" #include "libpmem.h" #include "memset_avx.h" #include "memcpy_memset.h" #include "out.h" #include "valgrind_internal.h" static force_inline void memset_movnt8x64b(char *dest, __m256i ymm) { _mm256_stream_si256((__m256i *)dest + 0, ymm); _mm256_stream_si256((__m256i *)dest + 1, ymm); _mm256_stream_si256((__m256i *)dest + 2, ymm); _mm256_stream_si256((__m256i *)dest + 3, ymm); _mm256_stream_si256((__m256i *)dest + 4, ymm); _mm256_stream_si256((__m256i *)dest + 5, ymm); _mm256_stream_si256((__m256i *)dest + 6, ymm); _mm256_stream_si256((__m256i *)dest + 7, ymm); _mm256_stream_si256((__m256i *)dest + 8, ymm); _mm256_stream_si256((__m256i *)dest + 9, ymm); _mm256_stream_si256((__m256i *)dest + 10, ymm); _mm256_stream_si256((__m256i *)dest + 11, ymm); _mm256_stream_si256((__m256i *)dest + 12, ymm); _mm256_stream_si256((__m256i *)dest + 13, ymm); _mm256_stream_si256((__m256i *)dest + 14, ymm); _mm256_stream_si256((__m256i *)dest + 15, ymm); VALGRIND_DO_FLUSH(dest, 8 * 64); } static force_inline void memset_movnt4x64b(char *dest, __m256i ymm) { _mm256_stream_si256((__m256i *)dest + 0, ymm); _mm256_stream_si256((__m256i *)dest + 1, ymm); _mm256_stream_si256((__m256i *)dest + 2, ymm); _mm256_stream_si256((__m256i *)dest + 3, ymm); _mm256_stream_si256((__m256i *)dest + 4, ymm); _mm256_stream_si256((__m256i *)dest + 5, ymm); _mm256_stream_si256((__m256i *)dest + 6, ymm); _mm256_stream_si256((__m256i *)dest + 7, ymm); VALGRIND_DO_FLUSH(dest, 4 * 64); } static force_inline void memset_movnt2x64b(char *dest, __m256i ymm) { _mm256_stream_si256((__m256i *)dest + 0, ymm); _mm256_stream_si256((__m256i *)dest + 1, ymm); _mm256_stream_si256((__m256i *)dest + 2, ymm); _mm256_stream_si256((__m256i *)dest + 3, ymm); VALGRIND_DO_FLUSH(dest, 2 * 64); } static force_inline void memset_movnt1x64b(char *dest, __m256i ymm) { _mm256_stream_si256((__m256i *)dest + 0, ymm); _mm256_stream_si256((__m256i *)dest + 1, ymm); VALGRIND_DO_FLUSH(dest, 64); } static force_inline void memset_movnt1x32b(char *dest, __m256i ymm) { _mm256_stream_si256((__m256i *)dest, ymm); VALGRIND_DO_FLUSH(dest, 32); } static force_inline void memset_movnt1x16b(char *dest, __m256i ymm) { __m128i xmm0 = m256_get16b(ymm); _mm_stream_si128((__m128i *)dest, xmm0); VALGRIND_DO_FLUSH(dest - 16, 16); } static force_inline void memset_movnt1x8b(char *dest, __m256i ymm) { uint64_t x = m256_get8b(ymm); _mm_stream_si64((long long *)dest, (long long)x); VALGRIND_DO_FLUSH(dest, 8); } static force_inline void memset_movnt1x4b(char *dest, __m256i ymm) { uint32_t x = m256_get4b(ymm); _mm_stream_si32((int *)dest, (int)x); VALGRIND_DO_FLUSH(dest, 4); } void EXPORTED_SYMBOL(char *dest, int c, size_t len) { __m256i ymm = _mm256_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_avx(dest, ymm, cnt); dest += cnt; len -= cnt; } while (len >= 8 * 64) { memset_movnt8x64b(dest, ymm); dest += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memset_movnt4x64b(dest, ymm); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_movnt2x64b(dest, ymm); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_movnt1x64b(dest, ymm); dest += 1 * 64; len -= 1 * 64; } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) memset_movnt1x32b(dest, ymm); else if (len == 16) memset_movnt1x16b(dest, ymm); else if (len == 8) memset_movnt1x8b(dest, ymm); else if (len == 4) memset_movnt1x4b(dest, ymm); else goto nonnt; goto end; } nonnt: memset_small_avx(dest, ymm, len); end: avx_zeroupper(); maybe_barrier(); }
5,514
25.137441
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_avx.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMEM_MEMSET_AVX_H #define PMEM_MEMSET_AVX_H #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include "avx.h" #include "libpmem.h" #include "out.h" static force_inline void memset_small_avx_noflush(char *dest, __m256i ymm, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; /* 33..64 */ _mm256_storeu_si256((__m256i *)dest, ymm); _mm256_storeu_si256((__m256i *)(dest + len - 32), ymm); return; le32: if (len > 16) { /* 17..32 */ __m128i xmm = m256_get16b(ymm); _mm_storeu_si128((__m128i *)dest, xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; } /* 9..16 */ uint64_t d8 = m256_get8b(ymm); *(uint64_t *)dest = d8; *(uint64_t *)(dest + len - 8) = d8; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ uint32_t d = m256_get4b(ymm); *(uint32_t *)dest = d; *(uint32_t *)(dest + len - 4) = d; return; } /* 3..4 */ uint16_t d2 = m256_get2b(ymm); *(uint16_t *)dest = d2; *(uint16_t *)(dest + len - 2) = d2; return; le2: if (len == 2) { uint16_t d2 = m256_get2b(ymm); *(uint16_t *)dest = d2; return; } *(uint8_t *)dest = (uint8_t)m256_get2b(ymm); } static force_inline void memset_small_avx(char *dest, __m256i ymm, size_t len) { memset_small_avx_noflush(dest, ymm, len); flush(dest, len); } #endif
2,975
24.655172
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_t_avx.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem.h" #include "avx.h" #include "flush.h" #include "memset_avx.h" #include "memcpy_memset.h" static force_inline void memset_mov8x64b(char *dest, __m256i ymm) { _mm256_store_si256((__m256i *)dest + 0, ymm); _mm256_store_si256((__m256i *)dest + 1, ymm); _mm256_store_si256((__m256i *)dest + 2, ymm); _mm256_store_si256((__m256i *)dest + 3, ymm); _mm256_store_si256((__m256i *)dest + 4, ymm); _mm256_store_si256((__m256i *)dest + 5, ymm); _mm256_store_si256((__m256i *)dest + 6, ymm); _mm256_store_si256((__m256i *)dest + 7, ymm); _mm256_store_si256((__m256i *)dest + 8, ymm); _mm256_store_si256((__m256i *)dest + 9, ymm); _mm256_store_si256((__m256i *)dest + 10, ymm); _mm256_store_si256((__m256i *)dest + 11, ymm); _mm256_store_si256((__m256i *)dest + 12, ymm); _mm256_store_si256((__m256i *)dest + 13, ymm); _mm256_store_si256((__m256i *)dest + 14, ymm); _mm256_store_si256((__m256i *)dest + 15, ymm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); } static force_inline void memset_mov4x64b(char *dest, __m256i ymm) { _mm256_store_si256((__m256i *)dest + 0, ymm); _mm256_store_si256((__m256i *)dest + 1, ymm); _mm256_store_si256((__m256i *)dest + 2, ymm); _mm256_store_si256((__m256i *)dest + 3, ymm); _mm256_store_si256((__m256i *)dest + 4, ymm); _mm256_store_si256((__m256i *)dest + 5, ymm); _mm256_store_si256((__m256i *)dest + 6, ymm); _mm256_store_si256((__m256i *)dest + 7, ymm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memset_mov2x64b(char *dest, __m256i ymm) { _mm256_store_si256((__m256i *)dest + 0, ymm); _mm256_store_si256((__m256i *)dest + 1, ymm); _mm256_store_si256((__m256i *)dest + 2, ymm); _mm256_store_si256((__m256i *)dest + 3, ymm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memset_mov1x64b(char *dest, __m256i ymm) { _mm256_store_si256((__m256i *)dest + 0, ymm); _mm256_store_si256((__m256i *)dest + 1, ymm); flush64b(dest + 0 * 64); } void EXPORTED_SYMBOL(char *dest, int c, size_t len) { __m256i ymm = _mm256_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_avx(dest, ymm, cnt); dest += cnt; len -= cnt; } while (len >= 8 * 64) { memset_mov8x64b(dest, ymm); dest += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memset_mov4x64b(dest, ymm); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_mov2x64b(dest, ymm); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_mov1x64b(dest, ymm); dest += 1 * 64; len -= 1 * 64; } if (len) memset_small_avx(dest, ymm, len); avx_zeroupper(); }
4,570
27.56875
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_t_avx512f.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem.h" #include "avx.h" #include "flush.h" #include "memset_avx512f.h" #include "memcpy_memset.h" static force_inline void memset_mov32x64b(char *dest, __m512i zmm) { _mm512_store_si512((__m512i *)dest + 0, zmm); _mm512_store_si512((__m512i *)dest + 1, zmm); _mm512_store_si512((__m512i *)dest + 2, zmm); _mm512_store_si512((__m512i *)dest + 3, zmm); _mm512_store_si512((__m512i *)dest + 4, zmm); _mm512_store_si512((__m512i *)dest + 5, zmm); _mm512_store_si512((__m512i *)dest + 6, zmm); _mm512_store_si512((__m512i *)dest + 7, zmm); _mm512_store_si512((__m512i *)dest + 8, zmm); _mm512_store_si512((__m512i *)dest + 9, zmm); _mm512_store_si512((__m512i *)dest + 10, zmm); _mm512_store_si512((__m512i *)dest + 11, zmm); _mm512_store_si512((__m512i *)dest + 12, zmm); _mm512_store_si512((__m512i *)dest + 13, zmm); _mm512_store_si512((__m512i *)dest + 14, zmm); _mm512_store_si512((__m512i *)dest + 15, zmm); _mm512_store_si512((__m512i *)dest + 16, zmm); _mm512_store_si512((__m512i *)dest + 17, zmm); _mm512_store_si512((__m512i *)dest + 18, zmm); _mm512_store_si512((__m512i *)dest + 19, zmm); _mm512_store_si512((__m512i *)dest + 20, zmm); _mm512_store_si512((__m512i *)dest + 21, zmm); _mm512_store_si512((__m512i *)dest + 22, zmm); _mm512_store_si512((__m512i *)dest + 23, zmm); _mm512_store_si512((__m512i *)dest + 24, zmm); _mm512_store_si512((__m512i *)dest + 25, zmm); _mm512_store_si512((__m512i *)dest + 26, zmm); _mm512_store_si512((__m512i *)dest + 27, zmm); _mm512_store_si512((__m512i *)dest + 28, zmm); _mm512_store_si512((__m512i *)dest + 29, zmm); _mm512_store_si512((__m512i *)dest + 30, zmm); _mm512_store_si512((__m512i *)dest + 31, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); flush64b(dest + 8 * 64); flush64b(dest + 9 * 64); flush64b(dest + 10 * 64); flush64b(dest + 11 * 64); flush64b(dest + 12 * 64); flush64b(dest + 13 * 64); flush64b(dest + 14 * 64); flush64b(dest + 15 * 64); flush64b(dest + 16 * 64); flush64b(dest + 17 * 64); flush64b(dest + 18 * 64); flush64b(dest + 19 * 64); flush64b(dest + 20 * 64); flush64b(dest + 21 * 64); flush64b(dest + 22 * 64); flush64b(dest + 23 * 64); flush64b(dest + 24 * 64); flush64b(dest + 25 * 64); flush64b(dest + 26 * 64); flush64b(dest + 27 * 64); flush64b(dest + 28 * 64); flush64b(dest + 29 * 64); flush64b(dest + 30 * 64); flush64b(dest + 31 * 64); } static force_inline void memset_mov16x64b(char *dest, __m512i zmm) { _mm512_store_si512((__m512i *)dest + 0, zmm); _mm512_store_si512((__m512i *)dest + 1, zmm); _mm512_store_si512((__m512i *)dest + 2, zmm); _mm512_store_si512((__m512i *)dest + 3, zmm); _mm512_store_si512((__m512i *)dest + 4, zmm); _mm512_store_si512((__m512i *)dest + 5, zmm); _mm512_store_si512((__m512i *)dest + 6, zmm); _mm512_store_si512((__m512i *)dest + 7, zmm); _mm512_store_si512((__m512i *)dest + 8, zmm); _mm512_store_si512((__m512i *)dest + 9, zmm); _mm512_store_si512((__m512i *)dest + 10, zmm); _mm512_store_si512((__m512i *)dest + 11, zmm); _mm512_store_si512((__m512i *)dest + 12, zmm); _mm512_store_si512((__m512i *)dest + 13, zmm); _mm512_store_si512((__m512i *)dest + 14, zmm); _mm512_store_si512((__m512i *)dest + 15, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); flush64b(dest + 8 * 64); flush64b(dest + 9 * 64); flush64b(dest + 10 * 64); flush64b(dest + 11 * 64); flush64b(dest + 12 * 64); flush64b(dest + 13 * 64); flush64b(dest + 14 * 64); flush64b(dest + 15 * 64); } static force_inline void memset_mov8x64b(char *dest, __m512i zmm) { _mm512_store_si512((__m512i *)dest + 0, zmm); _mm512_store_si512((__m512i *)dest + 1, zmm); _mm512_store_si512((__m512i *)dest + 2, zmm); _mm512_store_si512((__m512i *)dest + 3, zmm); _mm512_store_si512((__m512i *)dest + 4, zmm); _mm512_store_si512((__m512i *)dest + 5, zmm); _mm512_store_si512((__m512i *)dest + 6, zmm); _mm512_store_si512((__m512i *)dest + 7, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); flush64b(dest + 4 * 64); flush64b(dest + 5 * 64); flush64b(dest + 6 * 64); flush64b(dest + 7 * 64); } static force_inline void memset_mov4x64b(char *dest, __m512i zmm) { _mm512_store_si512((__m512i *)dest + 0, zmm); _mm512_store_si512((__m512i *)dest + 1, zmm); _mm512_store_si512((__m512i *)dest + 2, zmm); _mm512_store_si512((__m512i *)dest + 3, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memset_mov2x64b(char *dest, __m512i zmm) { _mm512_store_si512((__m512i *)dest + 0, zmm); _mm512_store_si512((__m512i *)dest + 1, zmm); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memset_mov1x64b(char *dest, __m512i zmm) { _mm512_store_si512((__m512i *)dest + 0, zmm); flush64b(dest + 0 * 64); } void EXPORTED_SYMBOL(char *dest, int c, size_t len) { __m512i zmm = _mm512_set1_epi8((char)c); /* See comment in memset_movnt_avx512f */ __m256i ymm = _mm256_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_avx512f(dest, ymm, cnt); dest += cnt; len -= cnt; } while (len >= 32 * 64) { memset_mov32x64b(dest, zmm); dest += 32 * 64; len -= 32 * 64; } if (len >= 16 * 64) { memset_mov16x64b(dest, zmm); dest += 16 * 64; len -= 16 * 64; } if (len >= 8 * 64) { memset_mov8x64b(dest, zmm); dest += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memset_mov4x64b(dest, zmm); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_mov2x64b(dest, zmm); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_mov1x64b(dest, zmm); dest += 1 * 64; len -= 1 * 64; } if (len) memset_small_avx512f(dest, ymm, len); avx_zeroupper(); }
7,852
28.411985
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_sse2.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMEM_MEMSET_SSE2_H #define PMEM_MEMSET_SSE2_H #include <xmmintrin.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include "libpmem.h" #include "out.h" static force_inline void memset_small_sse2_noflush(char *dest, __m128i xmm, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; if (len > 48) { /* 49..64 */ _mm_storeu_si128((__m128i *)(dest + 0), xmm); _mm_storeu_si128((__m128i *)(dest + 16), xmm); _mm_storeu_si128((__m128i *)(dest + 32), xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; } /* 33..48 */ _mm_storeu_si128((__m128i *)(dest + 0), xmm); _mm_storeu_si128((__m128i *)(dest + 16), xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; le32: if (len > 16) { /* 17..32 */ _mm_storeu_si128((__m128i *)(dest + 0), xmm); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm); return; } /* 9..16 */ uint64_t d8 = (uint64_t)_mm_cvtsi128_si64(xmm); *(uint64_t *)dest = d8; *(uint64_t *)(dest + len - 8) = d8; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ uint32_t d4 = (uint32_t)_mm_cvtsi128_si32(xmm); *(uint32_t *)dest = d4; *(uint32_t *)(dest + len - 4) = d4; return; } /* 3..4 */ uint16_t d2 = (uint16_t)(uint32_t)_mm_cvtsi128_si32(xmm); *(uint16_t *)dest = d2; *(uint16_t *)(dest + len - 2) = d2; return; le2: if (len == 2) { uint16_t d2 = (uint16_t)(uint32_t)_mm_cvtsi128_si32(xmm); *(uint16_t *)dest = d2; return; } *(uint8_t *)dest = (uint8_t)_mm_cvtsi128_si32(xmm); } static force_inline void memset_small_sse2(char *dest, __m128i xmm, size_t len) { memset_small_sse2_noflush(dest, xmm, len); flush(dest, len); } #endif
3,327
26.056911
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memset/memset_nt_avx512f.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem.h" #include "avx.h" #include "flush.h" #include "libpmem.h" #include "memcpy_memset.h" #include "memset_avx512f.h" #include "out.h" #include "util.h" #include "valgrind_internal.h" static force_inline void memset_movnt32x64b(char *dest, __m512i zmm) { _mm512_stream_si512((__m512i *)dest + 0, zmm); _mm512_stream_si512((__m512i *)dest + 1, zmm); _mm512_stream_si512((__m512i *)dest + 2, zmm); _mm512_stream_si512((__m512i *)dest + 3, zmm); _mm512_stream_si512((__m512i *)dest + 4, zmm); _mm512_stream_si512((__m512i *)dest + 5, zmm); _mm512_stream_si512((__m512i *)dest + 6, zmm); _mm512_stream_si512((__m512i *)dest + 7, zmm); _mm512_stream_si512((__m512i *)dest + 8, zmm); _mm512_stream_si512((__m512i *)dest + 9, zmm); _mm512_stream_si512((__m512i *)dest + 10, zmm); _mm512_stream_si512((__m512i *)dest + 11, zmm); _mm512_stream_si512((__m512i *)dest + 12, zmm); _mm512_stream_si512((__m512i *)dest + 13, zmm); _mm512_stream_si512((__m512i *)dest + 14, zmm); _mm512_stream_si512((__m512i *)dest + 15, zmm); _mm512_stream_si512((__m512i *)dest + 16, zmm); _mm512_stream_si512((__m512i *)dest + 17, zmm); _mm512_stream_si512((__m512i *)dest + 18, zmm); _mm512_stream_si512((__m512i *)dest + 19, zmm); _mm512_stream_si512((__m512i *)dest + 20, zmm); _mm512_stream_si512((__m512i *)dest + 21, zmm); _mm512_stream_si512((__m512i *)dest + 22, zmm); _mm512_stream_si512((__m512i *)dest + 23, zmm); _mm512_stream_si512((__m512i *)dest + 24, zmm); _mm512_stream_si512((__m512i *)dest + 25, zmm); _mm512_stream_si512((__m512i *)dest + 26, zmm); _mm512_stream_si512((__m512i *)dest + 27, zmm); _mm512_stream_si512((__m512i *)dest + 28, zmm); _mm512_stream_si512((__m512i *)dest + 29, zmm); _mm512_stream_si512((__m512i *)dest + 30, zmm); _mm512_stream_si512((__m512i *)dest + 31, zmm); VALGRIND_DO_FLUSH(dest, 32 * 64); } static force_inline void memset_movnt16x64b(char *dest, __m512i zmm) { _mm512_stream_si512((__m512i *)dest + 0, zmm); _mm512_stream_si512((__m512i *)dest + 1, zmm); _mm512_stream_si512((__m512i *)dest + 2, zmm); _mm512_stream_si512((__m512i *)dest + 3, zmm); _mm512_stream_si512((__m512i *)dest + 4, zmm); _mm512_stream_si512((__m512i *)dest + 5, zmm); _mm512_stream_si512((__m512i *)dest + 6, zmm); _mm512_stream_si512((__m512i *)dest + 7, zmm); _mm512_stream_si512((__m512i *)dest + 8, zmm); _mm512_stream_si512((__m512i *)dest + 9, zmm); _mm512_stream_si512((__m512i *)dest + 10, zmm); _mm512_stream_si512((__m512i *)dest + 11, zmm); _mm512_stream_si512((__m512i *)dest + 12, zmm); _mm512_stream_si512((__m512i *)dest + 13, zmm); _mm512_stream_si512((__m512i *)dest + 14, zmm); _mm512_stream_si512((__m512i *)dest + 15, zmm); VALGRIND_DO_FLUSH(dest, 16 * 64); } static force_inline void memset_movnt8x64b(char *dest, __m512i zmm) { _mm512_stream_si512((__m512i *)dest + 0, zmm); _mm512_stream_si512((__m512i *)dest + 1, zmm); _mm512_stream_si512((__m512i *)dest + 2, zmm); _mm512_stream_si512((__m512i *)dest + 3, zmm); _mm512_stream_si512((__m512i *)dest + 4, zmm); _mm512_stream_si512((__m512i *)dest + 5, zmm); _mm512_stream_si512((__m512i *)dest + 6, zmm); _mm512_stream_si512((__m512i *)dest + 7, zmm); VALGRIND_DO_FLUSH(dest, 8 * 64); } static force_inline void memset_movnt4x64b(char *dest, __m512i zmm) { _mm512_stream_si512((__m512i *)dest + 0, zmm); _mm512_stream_si512((__m512i *)dest + 1, zmm); _mm512_stream_si512((__m512i *)dest + 2, zmm); _mm512_stream_si512((__m512i *)dest + 3, zmm); VALGRIND_DO_FLUSH(dest, 4 * 64); } static force_inline void memset_movnt2x64b(char *dest, __m512i zmm) { _mm512_stream_si512((__m512i *)dest + 0, zmm); _mm512_stream_si512((__m512i *)dest + 1, zmm); VALGRIND_DO_FLUSH(dest, 2 * 64); } static force_inline void memset_movnt1x64b(char *dest, __m512i zmm) { _mm512_stream_si512((__m512i *)dest + 0, zmm); VALGRIND_DO_FLUSH(dest, 64); } static force_inline void memset_movnt1x32b(char *dest, __m256i ymm) { _mm256_stream_si256((__m256i *)dest, ymm); VALGRIND_DO_FLUSH(dest, 32); } static force_inline void memset_movnt1x16b(char *dest, __m256i ymm) { __m128i xmm = _mm256_extracti128_si256(ymm, 0); _mm_stream_si128((__m128i *)dest, xmm); VALGRIND_DO_FLUSH(dest, 16); } static force_inline void memset_movnt1x8b(char *dest, __m256i ymm) { uint64_t x = m256_get8b(ymm); _mm_stream_si64((long long *)dest, (long long)x); VALGRIND_DO_FLUSH(dest, 8); } static force_inline void memset_movnt1x4b(char *dest, __m256i ymm) { uint32_t x = m256_get4b(ymm); _mm_stream_si32((int *)dest, (int)x); VALGRIND_DO_FLUSH(dest, 4); } void EXPORTED_SYMBOL(char *dest, int c, size_t len) { __m512i zmm = _mm512_set1_epi8((char)c); /* * Can't use _mm512_extracti64x4_epi64, because some versions of gcc * crash. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82887 */ __m256i ymm = _mm256_set1_epi8((char)c); size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memset_small_avx512f(dest, ymm, cnt); dest += cnt; len -= cnt; } while (len >= 32 * 64) { memset_movnt32x64b(dest, zmm); dest += 32 * 64; len -= 32 * 64; } if (len >= 16 * 64) { memset_movnt16x64b(dest, zmm); dest += 16 * 64; len -= 16 * 64; } if (len >= 8 * 64) { memset_movnt8x64b(dest, zmm); dest += 8 * 64; len -= 8 * 64; } if (len >= 4 * 64) { memset_movnt4x64b(dest, zmm); dest += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memset_movnt2x64b(dest, zmm); dest += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memset_movnt1x64b(dest, zmm); dest += 1 * 64; len -= 1 * 64; } if (len == 0) goto end; /* There's no point in using more than 1 nt store for 1 cache line. */ if (util_is_pow2(len)) { if (len == 32) memset_movnt1x32b(dest, ymm); else if (len == 16) memset_movnt1x16b(dest, ymm); else if (len == 8) memset_movnt1x8b(dest, ymm); else if (len == 4) memset_movnt1x4b(dest, ymm); else goto nonnt; goto end; } nonnt: memset_small_avx512f(dest, ymm, len); end: avx_zeroupper(); maybe_barrier(); }
7,756
27.105072
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memcpy/memcpy_avx.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMEM_MEMCPY_AVX_H #define PMEM_MEMCPY_AVX_H #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "libpmem.h" #include "out.h" static force_inline void memmove_small_avx_noflush(char *dest, const char *src, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; /* 33..64 */ __m256i ymm0 = _mm256_loadu_si256((__m256i *)src); __m256i ymm1 = _mm256_loadu_si256((__m256i *)(src + len - 32)); _mm256_storeu_si256((__m256i *)dest, ymm0); _mm256_storeu_si256((__m256i *)(dest + len - 32), ymm1); return; le32: if (len > 16) { /* 17..32 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm1); return; } /* 9..16 */ uint64_t d80 = *(uint64_t *)src; uint64_t d81 = *(uint64_t *)(src + len - 8); *(uint64_t *)dest = d80; *(uint64_t *)(dest + len - 8) = d81; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ uint32_t d40 = *(uint32_t *)src; uint32_t d41 = *(uint32_t *)(src + len - 4); *(uint32_t *)dest = d40; *(uint32_t *)(dest + len - 4) = d41; return; } /* 3..4 */ uint16_t d20 = *(uint16_t *)src; uint16_t d21 = *(uint16_t *)(src + len - 2); *(uint16_t *)dest = d20; *(uint16_t *)(dest + len - 2) = d21; return; le2: if (len == 2) { *(uint16_t *)dest = *(uint16_t *)src; return; } *(uint8_t *)dest = *(uint8_t *)src; } static force_inline void memmove_small_avx(char *dest, const char *src, size_t len) { memmove_small_avx_noflush(dest, src, len); flush(dest, len); } #endif
3,275
26.529412
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memcpy/memcpy_sse2.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMEM_MEMCPY_SSE2_H #define PMEM_MEMCPY_SSE2_H #include <xmmintrin.h> #include <stddef.h> #include <stdint.h> #include "libpmem.h" #include "out.h" static force_inline void memmove_small_sse2_noflush(char *dest, const char *src, size_t len) { ASSERT(len <= 64); if (len <= 8) goto le8; if (len <= 32) goto le32; if (len > 48) { /* 49..64 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + 16)); __m128i xmm2 = _mm_loadu_si128((__m128i *)(src + 32)); __m128i xmm3 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + 16), xmm1); _mm_storeu_si128((__m128i *)(dest + 32), xmm2); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm3); return; } /* 33..48 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + 16)); __m128i xmm2 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + 16), xmm1); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm2); return; le32: if (len > 16) { /* 17..32 */ __m128i xmm0 = _mm_loadu_si128((__m128i *)src); __m128i xmm1 = _mm_loadu_si128((__m128i *)(src + len - 16)); _mm_storeu_si128((__m128i *)dest, xmm0); _mm_storeu_si128((__m128i *)(dest + len - 16), xmm1); return; } /* 9..16 */ uint64_t d80 = *(uint64_t *)src; uint64_t d81 = *(uint64_t *)(src + len - 8); *(uint64_t *)dest = d80; *(uint64_t *)(dest + len - 8) = d81; return; le8: if (len <= 2) goto le2; if (len > 4) { /* 5..8 */ uint32_t d40 = *(uint32_t *)src; uint32_t d41 = *(uint32_t *)(src + len - 4); *(uint32_t *)dest = d40; *(uint32_t *)(dest + len - 4) = d41; return; } /* 3..4 */ uint16_t d20 = *(uint16_t *)src; uint16_t d21 = *(uint16_t *)(src + len - 2); *(uint16_t *)dest = d20; *(uint16_t *)(dest + len - 2) = d21; return; le2: if (len == 2) { *(uint16_t *)dest = *(uint16_t *)src; return; } *(uint8_t *)dest = *(uint8_t *)src; } static force_inline void memmove_small_sse2(char *dest, const char *src, size_t len) { memmove_small_sse2_noflush(dest, src, len); flush(dest, len); } #endif
3,846
27.496296
74
h
null
NearPMSW-main/nearpm/shadow/redis-NDP-sd/deps/pmdk/src/libpmem/x86_64/memcpy/memcpy_t_sse2.h
/* * Copyright 2017-2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <immintrin.h> #include <stddef.h> #include <stdint.h> #include "pmem.h" #include "flush.h" #include "memcpy_memset.h" #include "memcpy_sse2.h" static force_inline void memmove_mov4x64b(char *dest, const char *src) { __m128i xmm0 = _mm_loadu_si128((__m128i *)src + 0); __m128i xmm1 = _mm_loadu_si128((__m128i *)src + 1); __m128i xmm2 = _mm_loadu_si128((__m128i *)src + 2); __m128i xmm3 = _mm_loadu_si128((__m128i *)src + 3); __m128i xmm4 = _mm_loadu_si128((__m128i *)src + 4); __m128i xmm5 = _mm_loadu_si128((__m128i *)src + 5); __m128i xmm6 = _mm_loadu_si128((__m128i *)src + 6); __m128i xmm7 = _mm_loadu_si128((__m128i *)src + 7); __m128i xmm8 = _mm_loadu_si128((__m128i *)src + 8); __m128i xmm9 = _mm_loadu_si128((__m128i *)src + 9); __m128i xmm10 = _mm_loadu_si128((__m128i *)src + 10); __m128i xmm11 = _mm_loadu_si128((__m128i *)src + 11); __m128i xmm12 = _mm_loadu_si128((__m128i *)src + 12); __m128i xmm13 = _mm_loadu_si128((__m128i *)src + 13); __m128i xmm14 = _mm_loadu_si128((__m128i *)src + 14); __m128i xmm15 = _mm_loadu_si128((__m128i *)src + 15); _mm_store_si128((__m128i *)dest + 0, xmm0); _mm_store_si128((__m128i *)dest + 1, xmm1); _mm_store_si128((__m128i *)dest + 2, xmm2); _mm_store_si128((__m128i *)dest + 3, xmm3); _mm_store_si128((__m128i *)dest + 4, xmm4); _mm_store_si128((__m128i *)dest + 5, xmm5); _mm_store_si128((__m128i *)dest + 6, xmm6); _mm_store_si128((__m128i *)dest + 7, xmm7); _mm_store_si128((__m128i *)dest + 8, xmm8); _mm_store_si128((__m128i *)dest + 9, xmm9); _mm_store_si128((__m128i *)dest + 10, xmm10); _mm_store_si128((__m128i *)dest + 11, xmm11); _mm_store_si128((__m128i *)dest + 12, xmm12); _mm_store_si128((__m128i *)dest + 13, xmm13); _mm_store_si128((__m128i *)dest + 14, xmm14); _mm_store_si128((__m128i *)dest + 15, xmm15); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); flush64b(dest + 2 * 64); flush64b(dest + 3 * 64); } static force_inline void memmove_mov2x64b(char *dest, const char *src) { __m128i xmm0 = _mm_loadu_si128((__m128i *)src + 0); __m128i xmm1 = _mm_loadu_si128((__m128i *)src + 1); __m128i xmm2 = _mm_loadu_si128((__m128i *)src + 2); __m128i xmm3 = _mm_loadu_si128((__m128i *)src + 3); __m128i xmm4 = _mm_loadu_si128((__m128i *)src + 4); __m128i xmm5 = _mm_loadu_si128((__m128i *)src + 5); __m128i xmm6 = _mm_loadu_si128((__m128i *)src + 6); __m128i xmm7 = _mm_loadu_si128((__m128i *)src + 7); _mm_store_si128((__m128i *)dest + 0, xmm0); _mm_store_si128((__m128i *)dest + 1, xmm1); _mm_store_si128((__m128i *)dest + 2, xmm2); _mm_store_si128((__m128i *)dest + 3, xmm3); _mm_store_si128((__m128i *)dest + 4, xmm4); _mm_store_si128((__m128i *)dest + 5, xmm5); _mm_store_si128((__m128i *)dest + 6, xmm6); _mm_store_si128((__m128i *)dest + 7, xmm7); flush64b(dest + 0 * 64); flush64b(dest + 1 * 64); } static force_inline void memmove_mov1x64b(char *dest, const char *src) { __m128i xmm0 = _mm_loadu_si128((__m128i *)src + 0); __m128i xmm1 = _mm_loadu_si128((__m128i *)src + 1); __m128i xmm2 = _mm_loadu_si128((__m128i *)src + 2); __m128i xmm3 = _mm_loadu_si128((__m128i *)src + 3); _mm_store_si128((__m128i *)dest + 0, xmm0); _mm_store_si128((__m128i *)dest + 1, xmm1); _mm_store_si128((__m128i *)dest + 2, xmm2); _mm_store_si128((__m128i *)dest + 3, xmm3); flush64b(dest + 0 * 64); } static force_inline void memmove_mov_sse_fw(char *dest, const char *src, size_t len) { size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { cnt = 64 - cnt; if (cnt > len) cnt = len; memmove_small_sse2(dest, src, cnt); dest += cnt; src += cnt; len -= cnt; } while (len >= 4 * 64) { memmove_mov4x64b(dest, src); dest += 4 * 64; src += 4 * 64; len -= 4 * 64; } if (len >= 2 * 64) { memmove_mov2x64b(dest, src); dest += 2 * 64; src += 2 * 64; len -= 2 * 64; } if (len >= 1 * 64) { memmove_mov1x64b(dest, src); dest += 1 * 64; src += 1 * 64; len -= 1 * 64; } if (len) memmove_small_sse2(dest, src, len); } static force_inline void memmove_mov_sse_bw(char *dest, const char *src, size_t len) { dest += len; src += len; size_t cnt = (uint64_t)dest & 63; if (cnt > 0) { if (cnt > len) cnt = len; dest -= cnt; src -= cnt; len -= cnt; memmove_small_sse2(dest, src, cnt); } while (len >= 4 * 64) { dest -= 4 * 64; src -= 4 * 64; len -= 4 * 64; memmove_mov4x64b(dest, src); } if (len >= 2 * 64) { dest -= 2 * 64; src -= 2 * 64; len -= 2 * 64; memmove_mov2x64b(dest, src); } if (len >= 1 * 64) { dest -= 1 * 64; src -= 1 * 64; len -= 1 * 64; memmove_mov1x64b(dest, src); } if (len) memmove_small_sse2(dest - len, src - len, len); } void EXPORTED_SYMBOL(char *dest, const char *src, size_t len) { if ((uintptr_t)dest - (uintptr_t)src >= len) memmove_mov_sse_fw(dest, src, len); else memmove_mov_sse_bw(dest, src, len); }
6,467
28.534247
74
h