| 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 | |
| 31 | typedef 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 | |
| 38 | typedef uint16_t cf_topo_os_cpu_index; |
| 39 | |
| 40 | typedef uint16_t cf_topo_numa_node_index; |
| 41 | typedef uint16_t cf_topo_core_index; |
| 42 | typedef uint16_t cf_topo_cpu_index; |
| 43 | typedef uint32_t cf_topo_napi_id; |
| 44 | |
| 45 | #define CF_TOPO_INVALID_INDEX ((cf_topo_numa_node_index)-1) |
| 46 | |
| 47 | void cf_topo_config(cf_topo_auto_pin auto_pin, cf_topo_numa_node_index a_numa_node, |
| 48 | const cf_addr_list *addrs); |
| 49 | void cf_topo_force_map_memory(const uint8_t *from, size_t size); |
| 50 | void cf_topo_migrate_memory(void); |
| 51 | void cf_topo_info(void); |
| 52 | |
| 53 | uint16_t cf_topo_count_cores(void); |
| 54 | uint16_t cf_topo_count_cpus(void); |
| 55 | |
| 56 | cf_topo_cpu_index cf_topo_current_cpu(void); |
| 57 | cf_topo_cpu_index cf_topo_socket_cpu(const cf_socket *sock); |
| 58 | cf_topo_napi_id cf_topo_socket_napi_id(const cf_socket *sock); |
| 59 | |
| 60 | void cf_topo_pin_to_core(cf_topo_core_index i_core); |
| 61 | void cf_topo_pin_to_cpu(cf_topo_cpu_index i_cpu); |
| 62 | |
| 63 | #define CF_STORAGE_MAX_PHYS 100 |
| 64 | |
| 65 | typedef 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 | |
| 76 | cf_storage_device_info *cf_storage_get_device_info(const char *path); |
| 77 | void cf_storage_set_scheduler(const char *path, const char *sched); |
| 78 | int64_t cf_storage_file_system_size(const char *path); |
| 79 | bool cf_storage_is_root_fs(const char *path); |
| 80 | |
| 81 | void cf_page_cache_dirty_limits(void); |
| 82 | |
| 83 | bool cf_mount_is_local(const char *path); |
| 84 | |