From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 721487CC2 for ; Mon, 26 Mar 2018 16:28:28 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2018 07:28:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,365,1517904000"; d="scan'208";a="28113739" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.237.220.112]) ([10.237.220.112]) by orsmga007.jf.intel.com with ESMTP; 26 Mar 2018 07:28:24 -0700 To: "Tan, Jianfeng" , dev@dpdk.org Cc: failed@ecsmtp.ir.intel.com, to@ecsmtp.ir.intel.com, remove@ecsmtp.ir.intel.com, Directory@ecsmtp.ir.intel.com, not@ecsmtp.ir.intel.com, empty@ecsmtp.ir.intel.com, konstantin.ananyev@intel.com References: <7f5496e8b5fd43dcbf10fe7059ed832107be0720.1520961844.git.anatoly.burakov@intel.com> From: "Burakov, Anatoly" Message-ID: Date: Mon, 26 Mar 2018 15:28:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v5 2/2] eal: add asynchronous request API to DPDK IPC X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2018 14:28:29 -0000 On 26-Mar-18 3:15 PM, Tan, Jianfeng wrote: > > > On 3/24/2018 8:46 PM, Anatoly Burakov wrote: >> This API is similar to the blocking API that is already present, >> but reply will be received in a separate callback by the caller >> (callback specified at the time of request, rather than registering >> for it in advance). >> >> Under the hood, we create a separate thread to deal with replies to >> asynchronous requests, that will just wait to be notified by the >> main thread, or woken up on a timer. >> >> Signed-off-by: Anatoly Burakov > > Generally, it looks great to me except some trivial nits, so > > Acked-by: Jianfeng Tan Thanks! >> +static void >> +trigger_async_action(struct pending_request *sr) >> +{ >> +    struct async_request_param *param; >> +    struct rte_mp_reply *reply; >> + >> +    param = sr->async.param; >> +    reply = ¶m->user_reply; >> + >> +    param->clb(sr->request, reply); >> + >> +    /* clean up */ >> +    free(sr->async.param->user_reply.msgs); > > How about simple "free(reply->msgs);"? > I would prefer leaving it as is, as it makes it clear that i'm freeing everything to do with sync request. >> + >> +    sync_req->type = REQUEST_TYPE_ASYNC; >> +    strcpy(sync_req->dst, dst); >> +    sync_req->request = req; >> +    sync_req->reply = reply_msg; >> +    sync_req->async.param = param; >> + >> +    /* queue already locked by caller */ >> + >> +    exist = find_sync_request(dst, req->name); >> +    if (!exist) >> +        TAILQ_INSERT_TAIL(&pending_requests.requests, sync_req, next); >> +    if (exist) { > > else? > Will fix in v6 >> @@ -744,9 +1027,155 @@ rte_mp_request(struct rte_mp_msg *req, struct >> rte_mp_reply *reply, >>   } >>   int __rte_experimental >> -rte_mp_reply(struct rte_mp_msg *msg, const char *peer) >> +rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts, >> +        rte_mp_async_reply_t clb) >>   { >> +    struct rte_mp_msg *copy; >> +    struct pending_request *dummy; >> +    struct async_request_param *param = NULL; > > No need to assign it to NULL. > Will fix in v6. >> +    /* we have to lock the request queue here, as we will be adding a >> bunch >> +     * of requests to the queue at once, and some of the replies may >> arrive >> +     * before we add all of the requests to the queue. >> +     */ >> +    pthread_mutex_lock(&pending_requests.lock); >> + >> +    /* we have to ensure that callback gets triggered even if we >> don't send >> +     * anything, therefore earlier we have allocated a dummy request. >> put it >> +     * on the queue and fill it. we will remove it once we know we sent >> +     * something. >> +     */ > > Or we can add this dummy at last if it's necessary, instead of adding > firstly and remove if not necessary? No strong option here. > Yep, sure, will fix in v6. -- Thanks, Anatoly