MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sync_memory

Function sync_memory

dpdk/lib/eal/common/rte_malloc.c:499–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499static int
500sync_memory(const char *heap_name, void *va_addr, size_t len, bool attach)
501{
502 struct malloc_heap *heap = NULL;
503 struct rte_memseg_list *msl;
504 int ret;
505
506 if (heap_name == NULL || va_addr == NULL || len == 0 ||
507 strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == 0 ||
508 strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) ==
509 RTE_HEAP_NAME_MAX_LEN) {
510 rte_errno = EINVAL;
511 return -1;
512 }
513 rte_mcfg_mem_read_lock();
514
515 /* find our heap */
516 heap = find_named_heap(heap_name);
517 if (heap == NULL) {
518 rte_errno = ENOENT;
519 ret = -1;
520 goto unlock;
521 }
522 /* we shouldn't be able to sync to internal heaps */
523 if (heap->socket_id < RTE_MAX_NUMA_NODES) {
524 rte_errno = EPERM;
525 ret = -1;
526 goto unlock;
527 }
528
529 /* find corresponding memseg list to sync to */
530 msl = malloc_heap_find_external_seg(va_addr, len);
531 if (msl == NULL) {
532 ret = -1;
533 goto unlock;
534 }
535
536 if (attach) {
537 ret = rte_fbarray_attach(&msl->memseg_arr);
538 if (ret == 0) {
539 /* notify all subscribers that a new memory area was
540 * added.
541 */
542 eal_memalloc_mem_event_notify(RTE_MEM_EVENT_ALLOC,
543 va_addr, len);
544 } else {
545 ret = -1;
546 goto unlock;
547 }
548 } else {
549 /* notify all subscribers that a memory area is about to
550 * be removed.
551 */
552 eal_memalloc_mem_event_notify(RTE_MEM_EVENT_FREE,
553 msl->base_va, msl->len);
554 ret = rte_fbarray_detach(&msl->memseg_arr);
555 if (ret < 0) {
556 ret = -1;

Callers 2

Calls 8

strnlenFunction · 0.85
rte_mcfg_mem_read_lockFunction · 0.85
find_named_heapFunction · 0.85
rte_fbarray_attachFunction · 0.85
rte_fbarray_detachFunction · 0.85
rte_mcfg_mem_read_unlockFunction · 0.85

Tested by

no test coverage detected