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

Function request_to_primary

dpdk/lib/eal/common/malloc_mp.c:697–778  ·  view source on GitHub ↗

this is a synchronous wrapper around a bunch of asynchronous requests to * primary process. this will initiate a request and wait until responses come. */

Source from the content-addressed store, hash-verified

695 * primary process. this will initiate a request and wait until responses come.
696 */
697int
698request_to_primary(struct malloc_mp_req *user_req)
699{
700 struct rte_mp_msg msg;
701 struct malloc_mp_req *msg_req = (struct malloc_mp_req *)msg.param;
702 struct mp_request *entry;
703 struct timespec ts;
704 struct timeval now;
705 int ret;
706
707 memset(&msg, 0, sizeof(msg));
708 memset(&ts, 0, sizeof(ts));
709
710 pthread_mutex_lock(&mp_request_list.lock);
711
712 entry = malloc(sizeof(*entry));
713 if (entry == NULL) {
714 RTE_LOG(ERR, EAL, "Cannot allocate memory for request\n");
715 goto fail;
716 }
717
718 memset(entry, 0, sizeof(*entry));
719
720 if (gettimeofday(&now, NULL) < 0) {
721 RTE_LOG(ERR, EAL, "Cannot get current time\n");
722 goto fail;
723 }
724
725 ts.tv_nsec = (now.tv_usec * 1000) % 1000000000;
726 ts.tv_sec = now.tv_sec + MP_TIMEOUT_S +
727 (now.tv_usec * 1000) / 1000000000;
728
729 /* initialize the request */
730 pthread_cond_init(&entry->cond, NULL);
731
732 msg.num_fds = 0;
733 msg.len_param = sizeof(*msg_req);
734 strlcpy(msg.name, MP_ACTION_REQUEST, sizeof(msg.name));
735
736 /* (attempt to) get a unique id */
737 user_req->id = get_unique_id();
738
739 /* copy contents of user request into the message */
740 memcpy(msg_req, user_req, sizeof(*msg_req));
741
742 if (rte_mp_sendmsg(&msg)) {
743 RTE_LOG(ERR, EAL, "Cannot send message to primary\n");
744 goto fail;
745 }
746
747 /* copy contents of user request into active request */
748 memcpy(&entry->user_req, user_req, sizeof(*user_req));
749
750 /* mark request as in progress */
751 entry->state = REQ_STATE_ACTIVE;
752
753 TAILQ_INSERT_TAIL(&mp_request_list.list, entry, next);
754

Callers 2

malloc_heap_freeFunction · 0.70

Calls 9

memsetFunction · 0.85
pthread_mutex_lockFunction · 0.85
mallocFunction · 0.85
get_unique_idFunction · 0.85
pthread_mutex_unlockFunction · 0.85
rte_mp_sendmsgFunction · 0.70
strlcpyFunction · 0.50
memcpyFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected