From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 77E06688E for ; Tue, 5 Nov 2013 18:53:42 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 05 Nov 2013 09:54:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.93,640,1378882800"; d="scan'208";a="428315127" Received: from cccressen-mobl4.ger.corp.intel.com (HELO debian) ([10.237.220.107]) by fmsmga002.fm.intel.com with ESMTP; 05 Nov 2013 09:54:13 -0800 Date: Tue, 5 Nov 2013 17:54:13 +0000 From: Cyril Cressent To: Jose Gavine Cueto Message-ID: <20131105175413.GB26311@debian> Mail-Followup-To: Jose Gavine Cueto , Thomas Monjalon , "dev@dpdk.org" References: <20131105103325.GA25808@debian> <201311051218.27016.thomas.monjalon@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Shannon, Dromore House, East Park, Shannon, Ireland User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue 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, 05 Nov 2013 17:53:42 -0000 On Wed, Nov 06, 2013 at 12:47:13AM +0800, Jose Gavine Cueto wrote: > Your'e welcome, and by the way the multiprocess example of simple_mp seems > confusing here: > > static int > lcore_recv(__attribute__((unused)) void *arg) > { > unsigned lcore_id = rte_lcore_id(); > > printf("Starting core %u\n", lcore_id); > while (!quit){ > void *msg; > if (rte_ring_dequeue(recv_ring, &msg) < 0){ > usleep(5); > continue; > } > printf("core %u: Received '%s'\n", lcore_id, (char *)msg); > rte_mempool_put(message_pool, msg); > } > > return 0; > } > > It seems that it isn't allocating msg here, or maybe I'm just missing something I understand your question better now, and in that light I think my previous answer was confusing. Let me try to clarify: A ring only holds *pointers* to objects. You enqueue pointers, and dequeue those pointers later, somewhere else, usually in another thread. The allocation/deallocation of the actual objects is none the concern of the ring and its enqueue/dequeue operations. If we take the simple_mp example, the msg dequeued by the lcore_recv() thread is created in mp_command.c and a pointer to that message is enqueued on "send_ring". If you read carefully how the rings are created you'll understand how "send_ring" and "recv_ring" relate to each other. I hope this is a bit clearer, Cyril