Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | /* |
| 16 | * physmem.c: Unix physical memory |
| 17 | * |
| 18 | * Copyright (c) 2008 Eliot Dresselhaus |
| 19 | * |
| 20 | * Permission is hereby granted, free of charge, to any person obtaining |
| 21 | * a copy of this software and associated documentation files (the |
| 22 | * "Software"), to deal in the Software without restriction, including |
| 23 | * without limitation the rights to use, copy, modify, merge, publish, |
| 24 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 25 | * permit persons to whom the Software is furnished to do so, subject to |
| 26 | * the following conditions: |
| 27 | * |
| 28 | * The above copyright notice and this permission notice shall be |
| 29 | * included in all copies or substantial portions of the Software. |
| 30 | * |
| 31 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 32 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 33 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 34 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 35 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 36 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 37 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 38 | */ |
| 39 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 40 | #include <unistd.h> |
| 41 | #include <sys/types.h> |
| 42 | #include <sys/mount.h> |
| 43 | #include <sys/mman.h> |
| 44 | #include <sys/fcntl.h> |
| 45 | #include <sys/stat.h> |
Damjan Marion | 2ca8ced | 2017-10-30 22:38:47 +0100 | [diff] [blame] | 46 | #include <unistd.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 47 | |
Damjan Marion | 01914ce | 2017-09-14 19:04:50 +0200 | [diff] [blame] | 48 | #include <vppinfra/linux/syscall.h> |
| 49 | #include <vppinfra/linux/sysfs.h> |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 50 | #include <vlib/vlib.h> |
| 51 | #include <vlib/physmem.h> |
| 52 | #include <vlib/unix/unix.h> |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 53 | #include <vlib/pci/pci.h> |
| 54 | #include <vlib/linux/vfio.h> |
Damjan Marion | 2ca8ced | 2017-10-30 22:38:47 +0100 | [diff] [blame] | 55 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 56 | static void * |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 57 | unix_physmem_alloc_aligned (vlib_main_t * vm, vlib_physmem_region_index_t idx, |
| 58 | uword n_bytes, uword alignment) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 59 | { |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 60 | vlib_physmem_region_t *pr = vlib_physmem_get_region (vm, idx); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 61 | uword lo_offset, hi_offset; |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 62 | uword *to_free = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 63 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 64 | if (pr->heap == 0) |
| 65 | return 0; |
| 66 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 67 | /* IO memory is always at least cache aligned. */ |
| 68 | alignment = clib_max (alignment, CLIB_CACHE_LINE_BYTES); |
| 69 | |
| 70 | while (1) |
| 71 | { |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame^] | 72 | #if USE_DLMALLOC == 0 |
| 73 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 74 | mheap_get_aligned (pr->heap, n_bytes, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 75 | /* align */ alignment, |
| 76 | /* align offset */ 0, |
| 77 | &lo_offset); |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame^] | 78 | #else |
| 79 | lo_offset = (uword) mspace_get_aligned (pr->heap, n_bytes, |
| 80 | alignment, ~0ULL /* offset */ ); |
| 81 | if (lo_offset == 0) |
| 82 | lo_offset = ~0ULL; |
| 83 | #endif |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 84 | |
| 85 | /* Allocation failed? */ |
| 86 | if (lo_offset == ~0) |
| 87 | break; |
| 88 | |
| 89 | /* Make sure allocation does not span DMA physical chunk boundary. */ |
| 90 | hi_offset = lo_offset + n_bytes - 1; |
| 91 | |
Damjan Marion | 52014c6 | 2017-12-13 13:51:13 +0100 | [diff] [blame] | 92 | if (((pointer_to_uword (pr->heap) + lo_offset) >> pr->log2_page_size) == |
| 93 | ((pointer_to_uword (pr->heap) + hi_offset) >> pr->log2_page_size)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 94 | break; |
| 95 | |
| 96 | /* Allocation would span chunk boundary, queue it to be freed as soon as |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 97 | we find suitable chunk. */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 98 | vec_add1 (to_free, lo_offset); |
| 99 | } |
| 100 | |
| 101 | if (to_free != 0) |
| 102 | { |
| 103 | uword i; |
| 104 | for (i = 0; i < vec_len (to_free); i++) |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame^] | 105 | { |
| 106 | #if USE_DLMALLOC == 0 |
| 107 | mheap_put (pr->heap, to_free[i]); |
| 108 | #else |
| 109 | mspace_put_no_offset (pr->heap, (void *) to_free[i]); |
| 110 | #endif |
| 111 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 112 | vec_free (to_free); |
| 113 | } |
| 114 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 115 | return lo_offset != ~0 ? pr->heap + lo_offset : 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 118 | static void |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 119 | unix_physmem_free (vlib_main_t * vm, vlib_physmem_region_index_t idx, void *x) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 120 | { |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 121 | vlib_physmem_region_t *pr = vlib_physmem_get_region (vm, idx); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 122 | /* Return object to region's heap. */ |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame^] | 123 | #if USE_DLMALLOC == 0 |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 124 | mheap_put (pr->heap, x - pr->heap); |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame^] | 125 | #else |
| 126 | mspace_put_no_offset (pr->heap, x); |
| 127 | #endif |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 130 | static clib_error_t * |
| 131 | unix_physmem_region_alloc (vlib_main_t * vm, char *name, u32 size, |
| 132 | u8 numa_node, u32 flags, |
| 133 | vlib_physmem_region_index_t * idx) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 134 | { |
Damjan Marion | 88c0621 | 2018-03-05 20:08:28 +0100 | [diff] [blame] | 135 | vlib_physmem_main_t *vpm = &physmem_main; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 136 | vlib_physmem_region_t *pr; |
| 137 | clib_error_t *error = 0; |
Damjan Marion | 01914ce | 2017-09-14 19:04:50 +0200 | [diff] [blame] | 138 | clib_mem_vm_alloc_t alloc = { 0 }; |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 139 | int i; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 140 | |
| 141 | pool_get (vpm->regions, pr); |
| 142 | |
| 143 | if ((pr - vpm->regions) >= 256) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 144 | { |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 145 | error = clib_error_return (0, "maximum number of regions reached"); |
| 146 | goto error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Damjan Marion | 01914ce | 2017-09-14 19:04:50 +0200 | [diff] [blame] | 149 | alloc.name = name; |
| 150 | alloc.size = size; |
| 151 | alloc.numa_node = numa_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 152 | |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 153 | alloc.flags = (flags & VLIB_PHYSMEM_F_SHARED) ? |
| 154 | CLIB_MEM_VM_F_SHARED : CLIB_MEM_VM_F_LOCKED; |
| 155 | |
| 156 | if ((flags & VLIB_PHYSMEM_F_HUGETLB)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 157 | { |
Damjan Marion | 01914ce | 2017-09-14 19:04:50 +0200 | [diff] [blame] | 158 | alloc.flags |= CLIB_MEM_VM_F_HUGETLB; |
| 159 | alloc.flags |= CLIB_MEM_VM_F_HUGETLB_PREALLOC; |
| 160 | alloc.flags |= CLIB_MEM_VM_F_NUMA_FORCE; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 161 | } |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 162 | else |
| 163 | { |
Damjan Marion | 01914ce | 2017-09-14 19:04:50 +0200 | [diff] [blame] | 164 | alloc.flags |= CLIB_MEM_VM_F_NUMA_PREFER; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 165 | } |
| 166 | |
Damjan Marion | 01914ce | 2017-09-14 19:04:50 +0200 | [diff] [blame] | 167 | error = clib_mem_vm_ext_alloc (&alloc); |
| 168 | if (error) |
| 169 | goto error; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 170 | |
Damjan Marion | 01914ce | 2017-09-14 19:04:50 +0200 | [diff] [blame] | 171 | pr->index = pr - vpm->regions; |
| 172 | pr->flags = flags; |
| 173 | pr->fd = alloc.fd; |
| 174 | pr->mem = alloc.addr; |
| 175 | pr->log2_page_size = alloc.log2_page_size; |
| 176 | pr->n_pages = alloc.n_pages; |
Chris Luke | b2bcad6 | 2017-09-18 08:51:22 -0400 | [diff] [blame] | 177 | pr->size = (u64) pr->n_pages << (u64) pr->log2_page_size; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 178 | pr->page_mask = (1 << pr->log2_page_size) - 1; |
| 179 | pr->numa_node = numa_node; |
lollita liu | eaba934 | 2018-06-13 05:14:02 -0400 | [diff] [blame] | 180 | pr->name = format (0, "%s%c", name, 0); |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 181 | |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 182 | for (i = 0; i < pr->n_pages; i++) |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 183 | { |
Lee Roberts | 45a0946 | 2018-03-07 19:47:00 -0700 | [diff] [blame] | 184 | void *ptr = pr->mem + ((u64) i << pr->log2_page_size); |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 185 | int node; |
| 186 | if ((move_pages (0, 1, &ptr, 0, &node, 0) == 0) && (numa_node != node)) |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 187 | { |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 188 | clib_warning ("physmem page for region \'%s\' allocated on the" |
| 189 | " wrong numa node (requested %u actual %u)", |
| 190 | pr->name, pr->numa_node, node, i); |
| 191 | break; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 192 | } |
| 193 | } |
| 194 | |
Damjan Marion | 51c52c0 | 2018-03-09 16:05:56 +0100 | [diff] [blame] | 195 | pr->page_table = clib_mem_vm_get_paddr (pr->mem, pr->log2_page_size, |
| 196 | pr->n_pages); |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 197 | |
| 198 | linux_vfio_dma_map_regions (vm); |
| 199 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 200 | if (flags & VLIB_PHYSMEM_F_INIT_MHEAP) |
| 201 | { |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame^] | 202 | #if USE_DLMALLOC == 0 |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 203 | pr->heap = mheap_alloc_with_flags (pr->mem, pr->size, |
| 204 | /* Don't want mheap mmap/munmap with IO memory. */ |
| 205 | MHEAP_FLAG_DISABLE_VM | |
| 206 | MHEAP_FLAG_THREAD_SAFE); |
Dave Barach | 6a5adc3 | 2018-07-04 10:56:23 -0400 | [diff] [blame^] | 207 | #else |
| 208 | pr->heap = create_mspace_with_base (pr->mem, pr->size, 1 /* locked */ ); |
| 209 | mspace_disable_expand (pr->heap); |
| 210 | #endif |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 211 | } |
| 212 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 213 | *idx = pr->index; |
| 214 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 215 | goto done; |
| 216 | |
| 217 | error: |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 218 | memset (pr, 0, sizeof (*pr)); |
| 219 | pool_put (vpm->regions, pr); |
| 220 | |
| 221 | done: |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 222 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 225 | static void |
| 226 | unix_physmem_region_free (vlib_main_t * vm, vlib_physmem_region_index_t idx) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 227 | { |
Damjan Marion | 88c0621 | 2018-03-05 20:08:28 +0100 | [diff] [blame] | 228 | vlib_physmem_main_t *vpm = &physmem_main; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 229 | vlib_physmem_region_t *pr = vlib_physmem_get_region (vm, idx); |
| 230 | |
| 231 | if (pr->fd > 0) |
| 232 | close (pr->fd); |
| 233 | munmap (pr->mem, pr->size); |
| 234 | vec_free (pr->name); |
| 235 | pool_put (vpm->regions, pr); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 238 | clib_error_t * |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 239 | unix_physmem_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 240 | { |
Damjan Marion | 88c0621 | 2018-03-05 20:08:28 +0100 | [diff] [blame] | 241 | vlib_physmem_main_t *vpm = &physmem_main; |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 242 | clib_error_t *error = 0; |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 243 | u64 *pt = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 244 | |
| 245 | /* Avoid multiple calls. */ |
| 246 | if (vm->os_physmem_alloc_aligned) |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 247 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 248 | |
Damjan Marion | 1ba0fa4 | 2018-03-04 17:19:08 +0100 | [diff] [blame] | 249 | /* check if pagemap is accessible */ |
| 250 | pt = clib_mem_vm_get_paddr (&pt, min_log2 (sysconf (_SC_PAGESIZE)), 1); |
| 251 | if (pt[0]) |
| 252 | vpm->flags |= VLIB_PHYSMEM_MAIN_F_HAVE_PAGEMAP; |
| 253 | vec_free (pt); |
| 254 | |
| 255 | if ((error = linux_vfio_init (vm))) |
| 256 | return error; |
| 257 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 258 | vm->os_physmem_alloc_aligned = unix_physmem_alloc_aligned; |
| 259 | vm->os_physmem_free = unix_physmem_free; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 260 | vm->os_physmem_region_alloc = unix_physmem_region_alloc; |
| 261 | vm->os_physmem_region_free = unix_physmem_region_free; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 262 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 263 | return error; |
| 264 | } |
| 265 | |
| 266 | static clib_error_t * |
| 267 | show_physmem (vlib_main_t * vm, |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 268 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 269 | { |
Damjan Marion | 88c0621 | 2018-03-05 20:08:28 +0100 | [diff] [blame] | 270 | vlib_physmem_main_t *vpm = &physmem_main; |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 271 | vlib_physmem_region_t *pr; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 272 | |
Damjan Marion | 49d66f1 | 2017-07-20 18:10:35 +0200 | [diff] [blame] | 273 | /* *INDENT-OFF* */ |
| 274 | pool_foreach (pr, vpm->regions, ( |
| 275 | { |
| 276 | vlib_cli_output (vm, "index %u name '%s' page-size %uKB num-pages %d " |
| 277 | "numa-node %u fd %d\n", |
| 278 | pr->index, pr->name, (1 << (pr->log2_page_size -10)), |
| 279 | pr->n_pages, pr->numa_node, pr->fd); |
| 280 | if (pr->heap) |
| 281 | vlib_cli_output (vm, " %U", format_mheap, pr->heap, /* verbose */ 1); |
| 282 | else |
| 283 | vlib_cli_output (vm, " no heap\n"); |
| 284 | })); |
| 285 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 286 | return 0; |
| 287 | } |
| 288 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 289 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 290 | VLIB_CLI_COMMAND (show_physmem_command, static) = { |
| 291 | .path = "show physmem", |
| 292 | .short_help = "Show physical memory allocation", |
| 293 | .function = show_physmem, |
| 294 | }; |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 295 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 296 | |
Dave Barach | 9b8ffd9 | 2016-07-08 08:13:45 -0400 | [diff] [blame] | 297 | /* |
| 298 | * fd.io coding-style-patch-verification: ON |
| 299 | * |
| 300 | * Local Variables: |
| 301 | * eval: (c-set-style "gnu") |
| 302 | * End: |
| 303 | */ |