1/*
2 * hardware.h
3 *
4 * Copyright (C) 2016-2017 Aerospike, Inc.
5 *
6 * Portions may be licensed to Aerospike, Inc. under one or more contributor
7 * license agreements.
8 *
9 * This program is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU Affero General Public License as published by the Free
11 * Software Foundation, either version 3 of the License, or (at your option) any
12 * later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see http://www.gnu.org/licenses/
21 */
22
23#pragma once
24
25#include <stdbool.h>
26#include <stddef.h>
27#include <stdint.h>
28
29#include <socket.h>
30
31typedef enum {
32 CF_TOPO_AUTO_PIN_NONE,
33 CF_TOPO_AUTO_PIN_CPU,
34 CF_TOPO_AUTO_PIN_NUMA,
35 CF_TOPO_AUTO_PIN_ADQ
36} cf_topo_auto_pin;
37
38typedef uint16_t cf_topo_os_cpu_index;
39
40typedef uint16_t cf_topo_numa_node_index;
41typedef uint16_t cf_topo_core_index;
42typedef uint16_t cf_topo_cpu_index;
43typedef uint32_t cf_topo_napi_id;
44
45#define CF_TOPO_INVALID_INDEX ((cf_topo_numa_node_index)-1)
46
47void cf_topo_config(cf_topo_auto_pin auto_pin, cf_topo_numa_node_index a_numa_node,
48 const cf_addr_list *addrs);
49void cf_topo_force_map_memory(const uint8_t *from, size_t size);
50void cf_topo_migrate_memory(void);
51void cf_topo_info(void);
52
53uint16_t cf_topo_count_cores(void);
54uint16_t cf_topo_count_cpus(void);
55
56cf_topo_cpu_index cf_topo_current_cpu(void);
57cf_topo_cpu_index cf_topo_socket_cpu(const cf_socket *sock);
58cf_topo_napi_id cf_topo_socket_napi_id(const cf_socket *sock);
59
60void cf_topo_pin_to_core(cf_topo_core_index i_core);
61void cf_topo_pin_to_cpu(cf_topo_cpu_index i_cpu);
62
63#define CF_STORAGE_MAX_PHYS 100
64
65typedef struct cf_storage_device_s {
66 char *dev_path;
67 uint32_t n_phys;
68
69 struct {
70 char *dev_path;
71 cf_topo_numa_node_index numa_node;
72 int32_t nvme_age;
73 } phys[CF_STORAGE_MAX_PHYS];
74} cf_storage_device_info;
75
76cf_storage_device_info *cf_storage_get_device_info(const char *path);
77void cf_storage_set_scheduler(const char *path, const char *sched);
78int64_t cf_storage_file_system_size(const char *path);
79bool cf_storage_is_root_fs(const char *path);
80
81void cf_page_cache_dirty_limits(void);
82
83bool cf_mount_is_local(const char *path);
84