cache line locking on AMD x86_64 utilising L3 CAT pseudo-locking
1#ifndef ICEPICK_H
2#define ICEPICK_H
3
4#include <stddef.h>
5#include <stdint.h>
6#include <stdbool.h>
7
8#define ICEPICK_E_NO_CAT (-1)
9#define ICEPICK_E_PERMISSION (-2)
10#define ICEPICK_E_NO_CLOS (-3)
11#define ICEPICK_E_TOO_LARGE (-4)
12#define ICEPICK_E_NUMA (-5)
13#define ICEPICK_E_HUGEPAGE (-6)
14#define ICEPICK_E_VERIFY (-7)
15#define ICEPICK_E_INVALID (-8)
16#define ICEPICK_E_ALLOC (-9)
17#define ICEPICK_E_MSR (-10)
18
19typedef struct icepick_topology icepick_topology_t;
20typedef struct icepick_region icepick_region_t;
21
22typedef struct {
23 size_t size;
24 unsigned clos_id;
25 int numa_node;
26 bool huge_pages;
27 bool verify;
28} icepick_config_t;
29
30typedef struct {
31 uint64_t mean_ns;
32 uint64_t stddev_ns;
33 uint64_t p50_ns;
34 uint64_t p99_ns;
35 uint64_t p999_ns;
36 uint64_t min_ns;
37 uint64_t max_ns;
38} icepick_latency_stats_t;
39
40int icepick_discover_topology(icepick_topology_t **topo);
41void icepick_free_topology(icepick_topology_t *topo);
42
43unsigned icepick_topology_l3_ways(const icepick_topology_t *topo);
44size_t icepick_topology_l3_size(const icepick_topology_t *topo);
45size_t icepick_topology_way_size(const icepick_topology_t *topo);
46unsigned icepick_topology_max_clos(const icepick_topology_t *topo);
47unsigned icepick_topology_ccx_count(const icepick_topology_t *topo);
48bool icepick_topology_cat_supported(const icepick_topology_t *topo);
49
50int icepick_lock(icepick_topology_t *topo, const icepick_config_t *cfg, icepick_region_t **region);
51int icepick_unlock(icepick_region_t *region);
52
53void *icepick_region_ptr(const icepick_region_t *region);
54size_t icepick_region_size(const icepick_region_t *region);
55unsigned icepick_region_clos(const icepick_region_t *region);
56
57int icepick_verify(const icepick_region_t *region, icepick_latency_stats_t *stats);
58
59int icepick_bench(void *ptr, size_t size, size_t iterations,
60 icepick_latency_stats_t *stats);
61
62const char *icepick_strerror(int err);
63
64#endif