From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 49936A052B for ; Wed, 29 Jul 2020 14:01:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2EC7A1BFD6; Wed, 29 Jul 2020 14:01:46 +0200 (CEST) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by dpdk.org (Postfix) with ESMTP id 801BF37B7 for ; Wed, 29 Jul 2020 14:01:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596024099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0YnJE4NCOywxh+DDxKj8SiVH1TYiCtyyNf5MwyubIfo=; b=Mb6IancmwK/2Bm7Ke/0p2/beBfKX/BfyT50H5ZJaYCU8HWLYAvGvdF4TINmKQvsqBCpyJG 9guj748V/ClS3ZdZ1PJhLnjpQZjuNxVxqb8O1BTFkwCnPpPml3kr4mxYXDFXkNKVyzBc2t PpaO06kuOw3uu6HF7DPRUjmyzCtE/Ho= Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-5cxja5_7OrStlyDT8xESBg-1; Wed, 29 Jul 2020 08:01:38 -0400 X-MC-Unique: 5cxja5_7OrStlyDT8xESBg-1 Received: by mail-ua1-f70.google.com with SMTP id s1so2119859uaq.2 for ; Wed, 29 Jul 2020 05:01:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0YnJE4NCOywxh+DDxKj8SiVH1TYiCtyyNf5MwyubIfo=; b=U+vsPXlteUVgdSyc51+QHrtkeWn17NZ/lOWbkyjOF4QBmYQdprxc37cY8kiE+4EY5b oXvX5zB3n8FWcZ9hdx5EzSjt+0t7DvlbpCxvscewVUAMPdmC/aBtJs0q2BQBDYRlcNGa Ow2PPttDK7gDNoPJ8IMvUg6KEHP36ejnwbL66bH+JbFRKBEdbPyWkpNHvRJDRU371gMY GDDhHWfgWB3QcnQGnCTfPqVGil4fYsl8izGuSigIf/YlMmt43Iy1OB0aVJN1K7eDabWH JO8GB1FrQQVRKViSm+ZJYdUAuL69C8df99X58K7kphRsF44f8jgOeDqKG9qWj1TECQQU D3aA== X-Gm-Message-State: AOAM532bKLg1JCM4i9/aiK53oUw5RyyjZZIh9HrcHcYU8lCqxZG1qMQ0 cY0vKMIh0lXuOvv+alAbsVvXOyZvIFw4erukouAtHiSogN1jWdsshqoceO4mMS8+0jB8VM4RxfN qHizyH7OvhrcTv6wyyeGsi3A= X-Received: by 2002:a9f:2b8d:: with SMTP id y13mr23075612uai.126.1596024096447; Wed, 29 Jul 2020 05:01:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu6SWvRyQl5Ii78jTOk6Az9XGKl3T7h3C53KVFHa8Mryff5AGJbvZIl1lXxvIVVKE7T9vzoXC1rdK01MB8aCs= X-Received: by 2002:a9f:2b8d:: with SMTP id y13mr23075579uai.126.1596024096108; Wed, 29 Jul 2020 05:01:36 -0700 (PDT) MIME-Version: 1.0 References: <20200616162705.83575-1-ting.xu@intel.com> <20200722021628.17194-1-ting.xu@intel.com> In-Reply-To: <20200722021628.17194-1-ting.xu@intel.com> From: David Marchand Date: Wed, 29 Jul 2020 14:01:25 +0200 Message-ID: To: Ting Xu , Cristian Dumitrescu Cc: dev , dpdk stable X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v4] lib/table: fix cache alignment issue X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Wed, Jul 22, 2020 at 4:13 AM Ting Xu wrote: > > When create softnic hash table with 16 keys, it failed on 32-bit > environment, because the pointer field in structure rte_bucket_4_16 > is only 32 bits. Add a padding field in 32-bit environment to keep > the structure to a multiple of 64 bytes. Apply this to 8-byte and > 32-byte key hash function as well. Please correct me if I am wrong, but it simply means this part of the table library never worked for 32-bit. It seems more adding 32-bit support rather than a fix and then I wonder if it has its place in rc3. Now, looking at the details: For 64-bit on my x86, we have: struct rte_bucket_4_8 { uint64_t signature; /* 0 8 */ uint64_t lru_list; /* 8 8 */ struct rte_bucket_4_8 * next; /* 16 8 */ uint64_t next_valid; /* 24 8 */ uint64_t key[4]; /* 32 32 */ /* --- cacheline 1 boundary (64 bytes) --- */ uint8_t data[]; /* 64 0 */ /* size: 64, cachelines: 1, members: 6 */ }; For 32-bit, we have: struct rte_bucket_4_8 { uint64_t signature; /* 0 8 */ uint64_t lru_list; /* 8 8 */ struct rte_bucket_4_8 * next; /* 16 4 */ uint64_t next_valid; /* 20 8 */ uint64_t key[4]; /* 28 32 */ uint8_t data[]; /* 60 0 */ /* size: 60, cachelines: 1, members: 6 */ /* last cacheline: 60 bytes */ } __attribute__((__packed__)); ^^ it is interesting that a packed attribute ends up here. I saw no such attribute in the library code. Compiler black magic at work I guess... > > Fixes: 8aa327214c ("table: hash") > Cc: stable@dpdk.org > > Signed-off-by: Ting Xu > > --- > v3->v4: Change design based on comment > v2->v3: Rebase > v1->v2: Correct patch time > --- > lib/librte_table/rte_table_hash_key16.c | 17 +++++++++++++++++ > lib/librte_table/rte_table_hash_key32.c | 17 +++++++++++++++++ > lib/librte_table/rte_table_hash_key8.c | 16 ++++++++++++++++ > 3 files changed, 50 insertions(+) > > diff --git a/lib/librte_table/rte_table_hash_key16.c b/lib/librte_table/rte_table_hash_key16.c > index 2cca1c924..c4384b114 100644 > --- a/lib/librte_table/rte_table_hash_key16.c > +++ b/lib/librte_table/rte_table_hash_key16.c > @@ -33,6 +33,7 @@ > > #endif > > +#ifdef RTE_ARCH_64 > struct rte_bucket_4_16 { > /* Cache line 0 */ > uint64_t signature[4 + 1]; > @@ -46,6 +47,22 @@ struct rte_bucket_4_16 { > /* Cache line 2 */ > uint8_t data[0]; > }; > +#else > +struct rte_bucket_4_16 { > + /* Cache line 0 */ > + uint64_t signature[4 + 1]; > + uint64_t lru_list; > + struct rte_bucket_4_16 *next; > + uint32_t pad; > + uint64_t next_valid; > + > + /* Cache line 1 */ > + uint64_t key[4][2]; > + > + /* Cache line 2 */ > + uint8_t data[0]; > +}; > +#endif The change could simply be: @@ -38,6 +38,9 @@ struct rte_bucket_4_16 { uint64_t signature[4 + 1]; uint64_t lru_list; struct rte_bucket_4_16 *next; +#ifndef RTE_ARCH_64 + uint32_t pad; +#endif uint64_t next_valid; /* Cache line 1 */ It avoids duplicating the whole structure definition (we could miss updating one side of the #ifdef later). Idem for the other "8" and "32" structures. -- David Marchand