From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id A8C61B3DC for ; Thu, 25 Sep 2014 12:15:41 +0200 (CEST) Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1XX6BQ-0003Ph-0C; Thu, 25 Sep 2014 06:21:57 -0400 Date: Thu, 25 Sep 2014 06:21:55 -0400 From: Neil Horman To: "Saha, Avik (AWS)" Message-ID: <20140925102155.GB32725@hmsreliant.think-freely.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Score: -2.9 (--) X-Spam-Status: No Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] Fix for LRU corrupted returns 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: Thu, 25 Sep 2014 10:15:41 -0000 On Thu, Sep 25, 2014 at 07:46:16AM +0000, Saha, Avik (AWS) wrote: > This is a patch to a problem that I have faced (described in the thread) and this works for me. > > 1) Since the data_size_shl was getting its value from the key_size, the table data entries were being corrupted when the calculation to shift the number of bits was being made based on the key_size (according to the document the key_size and entry_size are independently configurable) - With this fix, we get the MSB that is set in entry_size (also removes the constraint of this having to be a power of 2 - not entirely sure if this was the reason the constraint was kept though) > 2) The document does not say that the entry_size needs to be a power of 2 and this was failing silently when I was trying to bring my application up. > > diff --git a/DPDK/lib/librte_table/rte_table_hash_lru.c b/DPDK/lib/librte_table/rte_table_hash_lru.c > index d1a4984..4ec9aa4 100644 > --- a/DPDK/lib/librte_table/rte_table_hash_lru.c > +++ b/DPDK/lib/librte_table/rte_table_hash_lru.c > @@ -153,8 +153,10 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size) > uint32_t i; > > /* Check input parameters */ > - if ((check_params_create(p) != 0) || > - (!rte_is_power_of_2(entry_size)) || > + // Commenting out the power of 2 check on the entry_size since the > + // Programmers Guide does not call this out and we are going to handle > + // the data_size_shl of the table later on (Line 197) Please remove the reference to Line 197 here. Thats not going to remain accurate for very long. > + if ((check_params_create(p) != 0) || > ((sizeof(struct rte_table_hash) % CACHE_LINE_SIZE) != 0) || > (sizeof(struct bucket) != (CACHE_LINE_SIZE / 2))) { > return NULL; > @@ -192,7 +194,7 @@ rte_table_hash_lru_create(void *params, int socket_id, uint32_t entry_size) > /* Internal */ > t->bucket_mask = t->n_buckets - 1; > t->key_size_shl = __builtin_ctzl(p->key_size); > - t->data_size_shl = __builtin_ctzl(p->key_size); > + t->data_size_shl = 32 - (__builtin_clz(entry_size)); I presume the 32 value here is a cache line size? That should be replaced with CACHE_LINE_SIZE...Though looking at it, that doesn't seem sufficient. Seems like we need a eal abstraction to dynamically tell us what the cache line size is (we can read it from /proc/cpuinfo in linux, not sure about bsd). Neil