22 #include <sys/types.h> 25 #include <netinet/in.h> 53 int verbose = va_arg (*args,
int);
65 pthread_mutex_lock (&root_rp->
mutex);
82 pthread_mutex_unlock (&root_rp->
mutex);
84 for (i = 0; i <
vec_len (svm_names); i++)
87 a->
name = (
char *) svm_names[i];
91 pthread_mutex_lock (&rp->
mutex);
93 pthread_mutex_unlock (&rp->
mutex);
104 show (
char *chroot_path,
int verbose)
112 fformat (stdout,
"My pid is %d\n", getpid ());
134 svm_fd = shm_open ((
char *) shm_name, O_RDWR, 0777);
138 perror (
"svm_region_map(mmap open)");
143 rp = mmap (0,
MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, svm_fd, 0);
155 while (rp->
version == 0 && deadman++ < 5)
175 PROT_READ | PROT_WRITE,
176 MAP_SHARED | MAP_FIXED, svm_fd, 0);
188 if (pthread_mutex_trylock (&rp->
mutex))
190 clib_warning (
"rp->mutex LOCKED by pid %d, tag %d, cleared...",
198 pthread_mutex_unlock (&rp->
mutex);
201 return ((
void *) rp);
222 pthread_mutex_lock (&rp->
mutex);
236 pthread_mutex_unlock (&rp->
mutex);
273 trace (
char *chroot_path,
char *
name,
int enable_disable)
322 pthread_mutex_lock (&root_rp->
mutex);
337 pthread_mutex_unlock (&root_rp->
mutex);
339 for (i = 0; i <
vec_len (svm_names); i++)
343 a.
name = (
char *) svm_names[i];
344 fformat (stdout,
"Checking %s region...\n", a.
name);
356 repair (
char *chroot_path,
int crash_root_region)
364 fformat (stdout,
"our pid: %d\n", getpid ());
376 svm_fd = shm_open ((
char *) shm_name, O_RDWR, 0777);
380 perror (
"svm_region_map(mmap open)");
387 PROT_READ | PROT_WRITE, MAP_SHARED, svm_fd, 0);
404 PROT_READ | PROT_WRITE,
405 MAP_SHARED | MAP_FIXED, svm_fd, 0);
420 if (pthread_mutex_trylock (&root_rp->
mutex))
422 clib_warning (
"root_rp->mutex LOCKED by pid %d, tag %d, cleared...",
430 pthread_mutex_unlock (&root_rp->
mutex);
441 if (crash_root_region)
443 clib_warning (
"Leaving root region locked on purpose...");
444 pthread_mutex_lock (&root_rp->
mutex);
457 char *chroot_path = 0;
466 if (
unformat (&input,
"show-verbose"))
468 show (chroot_path, 1);
473 show (chroot_path, 0);
476 else if (
unformat (&input,
"client-scan"))
481 else if (
unformat (&input,
"repair"))
486 else if (
unformat (&input,
"crash"))
491 else if (
unformat (&input,
"trace-on %s", &name))
493 trace (chroot_path, name, 1);
496 else if (
unformat (&input,
"trace-off %s", &name))
498 trace (chroot_path, name, 0);
501 else if (
unformat (&input,
"chroot %s", &chroot_u8))
503 chroot_path = (
char *) chroot_u8;
516 "%s: show | show-verbose | client-scan | trace-on <region-name>\n",
518 fformat (stdout,
" trace-off <region-name>\n");
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void mheap_trace(clib_mem_heap_t *v, int enable)
svm_region_t * svm_get_root_rp(void)
#define SVM_GLOBAL_REGION_NAME
static void svm_pop_heap(void *oldheap)
void * svm_map_region(svm_map_region_args_t *a)
#define pool_foreach(VAR, POOL)
Iterate through pool.
Optimized string handling code, including c11-compliant "safe C library" variants.
Fixed length block allocator.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void svm_client_scan(const char *root_path)
#define SVM_PVT_MHEAP_SIZE
void svm_region_exit(void)
static void * svm_push_data_heap(svm_region_t *rp)
void * svm_region_find_or_create(svm_map_region_args_t *a)
description fragment has unexpected format
u8 * format_svm_region(u8 *s, va_list *args)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
svm_subregion_t * subregions
#define SVM_GLOBAL_REGION_SIZE
static void * svm_push_pvt_heap(svm_region_t *rp)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
u8 * shm_name_from_svm_map_region_args(svm_map_region_args_t *a)
#define uword_to_pointer(u, type)
u64 svm_get_global_region_base_va()
Bitmaps built as vectors of machine words.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define clib_unix_warning(format, args...)
void svm_region_unmap(void *rp_arg)
#define hash_get_mem(h, key)
void * clib_mem_init_thread_safe(void *memory, uword memory_size)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static svm_region_t * root_rp
int svm_region_init_chroot(const char *root_path)