From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier MATZ Subject: Re: [PATCH v2] mempool: replace c memcpy code semantics with optimized rte_memcpy Date: Tue, 31 May 2016 23:05:30 +0200 Message-ID: <574DFC9A.2050304@6wind.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, thomas.monjalon@6wind.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com To: Jerin Jacob Return-path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 067F02BB9 for ; Tue, 31 May 2016 23:05:32 +0200 (CEST) Received: by mail-wm0-f44.google.com with SMTP id a20so1453251wma.1 for ; Tue, 31 May 2016 14:05:32 -0700 (PDT) In-Reply-To: <20160531125822.GA10995@localhost.localdomain> 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" Hi Jerin, >>> /* 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. 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