From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerin Jacob Subject: Re: [PATCH v2] mempool: replace c memcpy code semantics with optimized rte_memcpy Date: Wed, 1 Jun 2016 12:30:23 +0530 Message-ID: <20160601070018.GA26922@localhost.localdomain> References: <1464101442-10501-1-git-send-email-jerin.jacob@caviumnetworks.com> <1464250025-9191-1-git-send-email-jerin.jacob@caviumnetworks.com> <574BFD97.2010505@6wind.com> <20160531125822.GA10995@localhost.localdomain> <574DFC9A.2050304@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: , , , To: Olivier MATZ Return-path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0090.outbound.protection.outlook.com [157.56.111.90]) by dpdk.org (Postfix) with ESMTP id 3ABF447CE for ; Wed, 1 Jun 2016 09:00:51 +0200 (CEST) Content-Disposition: inline In-Reply-To: <574DFC9A.2050304@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, May 31, 2016 at 11:05:30PM +0200, Olivier MATZ wrote: > Hi Jerin, Hi Olivier, > > >>> /* Add elements back into the cache */ > >>> - for (index = 0; index < n; ++index, obj_table++) > >>> - cache_objs[index] = *obj_table; > >>> + rte_memcpy(&cache_objs[0], obj_table, sizeof(void *) * n); > >>> > >>> cache->len += n; > >>> > >>> > >> > >> I also checked in the get_bulk() function, which looks like that: > >> > >> /* Now fill in the response ... */ > >> for (index = 0, len = cache->len - 1; > >> index < n; > >> ++index, len--, obj_table++) > >> *obj_table = cache_objs[len]; > >> > >> I think we could replace it by something like: > >> > >> rte_memcpy(obj_table, &cache_objs[len - n], sizeof(void *) * n); > >> > >> The only difference is that it won't reverse the pointers in the > >> table, but I don't see any problem with that. > >> > >> What do you think? > > > > In true sense, it will _not_ be LIFO. Not sure about cache usage implications > > on the specific use cases. > > Today, the objects pointers are reversed only in the get(). It means > that this code: > > rte_mempool_get_bulk(mp, table, 4); > for (i = 0; i < 4; i++) > printf("obj = %p\n", t[i]); > rte_mempool_put_bulk(mp, table, 4); > > > printf("-----\n"); > rte_mempool_get_bulk(mp, table, 4); > for (i = 0; i < 4; i++) > printf("obj = %p\n", t[i]); > rte_mempool_put_bulk(mp, table, 4); > > prints: > > addr1 > addr2 > addr3 > addr4 > ----- > addr4 > addr3 > addr2 > addr1 > > Which is quite strange. IMO, It is the expected LIFO behavior. Right ? What is not expected is the following, which is the case after change. Or Am I missing something here? addr1 addr2 addr3 addr4 ----- addr1 addr2 addr3 addr4 > > I don't think it would be an issue to replace the loop by a > rte_memcpy(), it may increase the copy speed and it will be > more coherent with the put(). > > > Olivier