From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=CCmZOrEudAnNUJjkshM0JVahT0Iab+vSGQ4jz9BEuJY=; b=Wx7N+arZllQ3QdhFMePqTIN1qNz2MjIRVdG6p43JY7J+wpJSgFS/hZDROjbvOlR84+ YOul9YixFxF0lkVR8XTVbvuoo0l/tH6OxiPPJ/mIwSF4r3YSjZPlQzy95MV3mo5OmUcM RmnPq1iS6C3XTbaXLEMozCMEouaq/kymDTd4yMhQb31uatVYB860WiBrbBOlzfqS6FIo LMU/QBMQi0rGnMdUT67JZE8TGosPXsj623XbNUHk238S3WNNGzGt3HFdJfe3B8cv2DRc 4VX+/eaNr9r8Fp+1hmphIDr6hMr2Wozg1K9QbdN+nMp7Rt/EZwmNCj2sfrjkySaWy25d cqOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=CCmZOrEudAnNUJjkshM0JVahT0Iab+vSGQ4jz9BEuJY=; b=Vi+ehodkjGBltD5lZNfarUYg7SNclaVAAlXP1nteXO6eWrX7tgTKO1OvLI/udYpVUw kF41n9wK1SEZZ0SZWUmt5263QytCRoyZiQ7Duif3bAXAZGsG+uiJg0mwVjdJzeMw0MsB 4nJvqcy9DkIaZFmHTvYCqF1c2XfUkWFwZiS4rKAPy5I4Pw8pwxqNMxDvAUc8OkAtxei4 lLIv3xZbndhC/kpBoojnFjaSTiUkrTvSUTUOZzWd6sV0+svigQ5UEck0mBqGhdbPTcqK OuCSSLPuUYzbOaeh88ddW5duVf/GkdTkSue7M57kl9LNtUWQnrWX1IPPM+54iCt7QxCl LOmg== X-Gm-Message-State: ALyK8tKGO99XtQp4E4JLkENCqtoJi1WUsSKd4Wl1Dixw0g7wdMoSSMxpG2QUI+fckoFiUAVm X-Received: by 10.28.158.85 with SMTP id h82mr17214526wme.60.1464728731769; Tue, 31 May 2016 14:05:31 -0700 (PDT) Received: from [192.168.0.16] (85-171-34-230.rev.numericable.fr. [85.171.34.230]) by smtp.gmail.com with ESMTPSA id jq1sm41668035wjc.28.2016.05.31.14.05.30 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 May 2016 14:05:30 -0700 (PDT) To: Jerin Jacob 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> Cc: dev@dpdk.org, thomas.monjalon@6wind.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com From: Olivier MATZ Message-ID: <574DFC9A.2050304@6wind.com> Date: Tue, 31 May 2016 23:05:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160531125822.GA10995@localhost.localdomain> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] mempool: replace c memcpy code semantics with optimized rte_memcpy 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, 31 May 2016 21:05:32 -0000 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