From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Burakov, Anatoly" Subject: Re: [PATCH v3 2/5] eal: don't process IPC messages before init finished Date: Wed, 28 Feb 2018 09:47:26 +0000 Message-ID: References: <31f6d9ef676fb1eb0a664c06d62d66f32876dcb6.1519672713.git.anatoly.burakov@intel.com> <3903de6f3824e5063d49936e743e22dd819bad09.1519740527.git.anatoly.burakov@intel.com> <54FDC65D-2E16-4F6B-8C1F-57863453FEA2@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: "dev@dpdk.org" , "Tan, Jianfeng" To: "Wiles, Keith" Return-path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 77148201 for ; Wed, 28 Feb 2018 10:47:29 +0100 (CET) In-Reply-To: <54FDC65D-2E16-4F6B-8C1F-57863453FEA2@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 28-Feb-18 4:00 AM, Wiles, Keith wrote: > > >> >> + struct message_queue_entry *cur_msg, *next_msg, *new_msg = NULL; >> while (1) { >> - if (read_msg(&msg, &sa) == 0) >> - process_msg(&msg, &sa); >> + /* we want to process all messages in order of their arrival, >> + * but status of init_complete may change while we're iterating >> + * the tailq. so, store it here and check once every iteration. >> + */ >> + int init_complete; > > Do we allow variables to be defined in the middle of a block, I thought we only allowed them after a ‘{‘ or open block. Apologies, will fix. > >> + >> + if (new_msg == NULL) >> + new_msg = malloc(sizeof(*new_msg)); > > I am very concerned about allocating memory with no limit. If the process never completes then we could receive messages and consume a lot of memory. I would want to see a limit to the number of messages we can consume in the queue just to be sure. Sure, will do. > >> + if (read_msg(&new_msg->msg, &new_msg->sa) == 0) { >> + /* we successfully read the message, so enqueue it */ >> + TAILQ_INSERT_TAIL(&message_queue, new_msg, next); >> + new_msg = NULL; >> + } /* reuse new_msg for next message if we couldn't read_msg */ >> + >> + init_complete = internal_config.init_complete; > > Does the internal_config.init_complete need to be a volatile to make sure it is reread each time thru the loop? Will fix. > >> + >> + /* tailq only accessed here, so no locking needed */ >> + TAILQ_FOREACH_SAFE(cur_msg, &message_queue, next, next_msg) { >> + /* secondary process should not process any incoming >> + * requests until its initialization is complete, but >> + * it is allowed to process replies to its own queries. >> + */ >> + if (rte_eal_process_type() == RTE_PROC_SECONDARY && >> + !init_complete && >> + cur_msg->msg.type != MP_REP) >> + continue; >> + >> + TAILQ_REMOVE(&message_queue, cur_msg, next); >> + >> + process_msg(&cur_msg->msg, &cur_msg->sa); >> + >> + free(cur_msg); >> + } >> } >> >> return NULL; >> -- >> 2.7.4 > > Regards, > Keith > -- Thanks, Anatoly