| 1 | // SPDX-License-Identifier: GPL-2.0-or-latercxx . . $ `<file>/src/cyclictest/rt_numa.h`/ |
| 2 | /* |
| 3 | * A numa library for cyclictest. |
| 4 | * |
| 5 | * (C) 2010 John Kacur <[email protected]> |
| 6 | * (C) 2010 Clark Williams <[email protected]> |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef _RT_NUMA_H |
| 11 | #define _RT_NUMA_Hcxx . . $ `src/cyclictest/rt_numa.h:11:9`! |
| 12 | |
| 13 | #include "rt-utils.h"cxx . . $ `<file>/src/include/rt-utils.h`/ |
| 14 | #include "rt-error.h"cxx . . $ `<file>/src/include/rt-error.h`/ |
| 15 | |
| 16 | static int numacxx . . $ numa. = 0; |
| 17 | |
| 18 | #include <numa.h> |
| 19 | |
| 20 | static void * |
| 21 | threadalloccxx . . $ threadalloc(18cbab4a1db6709c).(size_t size, int node) |
| 22 | { |
| 23 | if (node == -1) |
| 24 | return malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(size); |
| 25 | return numa_alloc_onnodecxx . . $ numa_alloc_onnode(18cbab4a1db6709c).(size, node); |
| 26 | } |
| 27 | |
| 28 | static void |
| 29 | threadfreecxx . . $ threadfree(936bb941186e2394).(void *ptr, size_t size, int node) |
| 30 | { |
| 31 | if (node == -1) |
| 32 | freecxx . . $ free(5d22bdacc48458e8).(ptr); |
| 33 | else |
| 34 | numa_freecxx . . $ numa_free(5500c4293b1bbef0).(ptr, size); |
| 35 | } |
| 36 | |
| 37 | static void rt_numa_set_numa_run_on_nodecxx . . $ rt_numa_set_numa_run_on_node(3e454b8ccf442868).(int node, int cpu) |
| 38 | { |
| 39 | int res; |
| 40 | res = numa_run_on_nodecxx . . $ numa_run_on_node(7864480464b09eea).(node); |
| 41 | if (res) |
| 42 | warncxx . . $ warn(d5d9ff45db7b5d36).("Could not set NUMA node %d for thread %d: %s\n", |
| 43 | node, cpu, strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | static void *rt_numa_numa_alloc_onnodecxx . . $ rt_numa_numa_alloc_onnode(dfdaf3847145fa8e).(size_t size, int node, int cpu) |
| 48 | { |
| 49 | void *stack; |
| 50 | stack = numa_alloc_onnodecxx . . $ numa_alloc_onnode(18cbab4a1db6709c).(size, node); |
| 51 | if (stack == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 52 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("failed to allocate %d bytes on node %d for cpu %d\n", |
| 53 | size, node, cpu); |
| 54 | return stack; |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | * Use new bit mask CPU affinity behavior |
| 59 | */ |
| 60 | static int rt_numa_numa_node_of_cpucxx . . $ rt_numa_numa_node_of_cpu(7864480464b09eea).(int cpu) |
| 61 | { |
| 62 | int node; |
| 63 | node = numa_node_of_cpucxx . . $ numa_node_of_cpu(7864480464b09eea).(cpu); |
| 64 | if (node == -1) |
| 65 | fatalcxx . . $ fatal(5313ecf19fd40d4d).("invalid cpu passed to numa_node_of_cpu(%d)\n", cpu); |
| 66 | return node; |
| 67 | } |
| 68 | |
| 69 | static inline unsigned int rt_numa_bitmask_isbitsetcxx . . $ rt_numa_bitmask_isbitset(a59af0d7cbbb5af3).( const struct bitmaskcxx . . $ bitmask# *mask, |
| 70 | unsigned long i) |
| 71 | { |
| 72 | return numa_bitmask_isbitsetcxx . . $ numa_bitmask_isbitset(9048e51cedd65d8e).(mask,i); |
| 73 | } |
| 74 | |
| 75 | static inline struct bitmaskcxx . . $ bitmask#* rt_numa_parse_cpustringcxx . . $ rt_numa_parse_cpustring(62218a8025ffedd2).(const char* s) |
| 76 | { |
| 77 | return numa_parse_cpustring_allcxx . . $ numa_parse_cpustring_all(62218a8025ffedd2).(s); |
| 78 | } |
| 79 | |
| 80 | static inline void rt_bitmask_freecxx . . $ rt_bitmask_free(d7c6455decaee94d).(struct bitmaskcxx . . $ bitmask# *mask) |
| 81 | { |
| 82 | numa_bitmask_freecxx . . $ numa_bitmask_free(d7c6455decaee94d).(mask); |
| 83 | } |
| 84 | |
| 85 | #endif /* _RT_NUMA_H */ |