From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id C813D8D9E for ; Tue, 22 Sep 2015 11:07:46 +0200 (CEST) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1ZeJYN-0007DZ-Ek; Tue, 22 Sep 2015 11:07:59 +0200 Message-ID: <56011A5B.5080704@6wind.com> Date: Tue, 22 Sep 2015 11:07:39 +0200 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Vithal Mohare , "dev@dpdk.org" References: <98DB008FA2AC6644B40AD8C766FAB271020CB4B3FE@BOREAL.arubanetworks.com> In-Reply-To: <98DB008FA2AC6644B40AD8C766FAB271020CB4B3FE@BOREAL.arubanetworks.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] mbuf pool and ring size... X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 09:07:47 -0000 Hi Vithal, On 09/22/2015 07:10 AM, Vithal Mohare wrote: > Hi, > > While creating mbuf pool, suppose if mbuf-pool size passed to DPDK API is already pow-of-2 [ rte_mempool_create()-->rte_mempool_xmem_create()]. Then, noticed that, corresponding size of the ring created for this pool will be double the size of mbuf-pool. This is because of below code snippet: > rte_mempool_xmem_create(...) { > .... > r = rte_ring_create(rg_name, rte_align32pow2(n+1), socket_id, rg_flags); <<<<<<<< Notice that its 'n+1' here, rte_align32pow2(n+1) > .... > } > Question: why is this 'n+1'? Shouldn't this be just 'n'? >>From rte_ring_init() documentation: The ring size is set to *count*, which must be a power of two. The real usable ring size is *count-1* instead of *count* to differentiate a free ring from an empty ring. Therefore, if the user asks for a mempool with 2048 elements, the ring size has to be 4096. >>From mempool documentation: The optimum size (in terms of memory usage) for a mempool is when n is a power of two minus 1: n = (2^q - 1). Regards, Olivier