From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53231A0517; Tue, 9 Jun 2020 15:49:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AEA911BE97; Tue, 9 Jun 2020 15:49:05 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id D05D71BE91 for ; Tue, 9 Jun 2020 15:49:03 +0200 (CEST) IronPort-SDR: /nY9iUGc4FkdGKyig16cNTasqmC6LmLWY4ZnRBc84Vlqi0zSmm4NmCso9FPsWfoUiIJb1N5xKF g7OE0PyOsdlA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2020 06:49:02 -0700 IronPort-SDR: 0FOVYw1UVzlL5NqVaXn9eDN7vOw05IK+isy4acG51yv23b51oA2iP+inH6tm5AfGpzJn8ugATv lMneRPkjI2/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,492,1583222400"; d="scan'208";a="288836247" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.235.42]) ([10.213.235.42]) by orsmga002.jf.intel.com with ESMTP; 09 Jun 2020 06:49:00 -0700 To: Tal Shnaiderman , Dmitry Kozlyuk , "dev@dpdk.org" Cc: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Bruce Richardson References: <20200602230329.17838-1-dmitry.kozliuk@gmail.com> <20200608074153.29611-1-dmitry.kozliuk@gmail.com> <20200608074153.29611-5-dmitry.kozliuk@gmail.com> From: "Burakov, Anatoly" Message-ID: <41543c17-4e0c-fc48-8f80-1bd0018be9ac@intel.com> Date: Tue, 9 Jun 2020 14:49:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v7 04/11] eal/mem: extract common code for memseg list initialization 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 09-Jun-20 12:14 PM, Tal Shnaiderman wrote: >> Subject: [PATCH v7 04/11] eal/mem: extract common code for memseg list >> initialization >> >> All supported OS create memory segment lists (MSL) and reserve VA space >> for them in a nearly identical way. Move common code into EAL private >> functions to reduce duplication. >> >> Signed-off-by: Dmitry Kozlyuk >> --- >> lib/librte_eal/common/eal_common_memory.c | 97 >> ++++++++++++++++++ >> lib/librte_eal/common/eal_private.h | 62 ++++++++++++ >> lib/librte_eal/freebsd/eal_memory.c | 94 ++++-------------- >> lib/librte_eal/linux/eal_memory.c | 115 +++++----------------- >> 4 files changed, 200 insertions(+), 168 deletions(-) >> >> diff --git a/lib/librte_eal/common/eal_common_memory.c >> b/lib/librte_eal/common/eal_common_memory.c >> index f9fbd3e4e..3325d8c35 100644 >> --- a/lib/librte_eal/common/eal_common_memory.c >> +++ b/lib/librte_eal/common/eal_common_memory.c > > [snip] > >> +void >> +eal_memseg_list_populate(struct rte_memseg_list *msl, void *addr, int >> +n_segs) { >> + size_t page_sz = msl->page_sz; >> + int i; >> + >> + for (i = 0; i < n_segs; i++) { >> + struct rte_fbarray *arr = &msl->memseg_arr; >> + struct rte_memseg *ms = rte_fbarray_get(arr, i); > > Since rte_fbarray_get() can return NULL you should verify *ms isn't dereferenced. I don't think it's necessary in this case, since this fbarray was just initialized with the n_segs value in the calling code. > >> + >> + if (rte_eal_iova_mode() == RTE_IOVA_VA) >> + ms->iova = (uintptr_t)addr; >> + else >> + ms->iova = RTE_BAD_IOVA; >> + ms->addr = addr; >> + ms->hugepage_sz = page_sz; >> + ms->socket_id = 0; >> + ms->len = page_sz; >> + >> + rte_fbarray_set_used(arr, i); >> + >> + addr = RTE_PTR_ADD(addr, page_sz); >> + } >> +} > > [snip] > >> -- >> 2.25.4 > -- Thanks, Anatoly