From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2018 01:47:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,405,1515484800"; d="scan'208";a="178693526" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.237.220.78]) ([10.237.220.78]) by orsmga004.jf.intel.com with ESMTP; 28 Feb 2018 01:47:27 -0800 To: "Wiles, Keith" Cc: "dev@dpdk.org" , "Tan, Jianfeng" References: <31f6d9ef676fb1eb0a664c06d62d66f32876dcb6.1519672713.git.anatoly.burakov@intel.com> <3903de6f3824e5063d49936e743e22dd819bad09.1519740527.git.anatoly.burakov@intel.com> <54FDC65D-2E16-4F6B-8C1F-57863453FEA2@intel.com> From: "Burakov, Anatoly" Message-ID: Date: Wed, 28 Feb 2018 09:47:26 +0000 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: <54FDC65D-2E16-4F6B-8C1F-57863453FEA2@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v3 2/5] eal: don't process IPC messages before init finished 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: Wed, 28 Feb 2018 09:47:29 -0000 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