From patchwork Wed Oct 24 01:32:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 149474 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1400952ljp; Tue, 23 Oct 2018 18:33:12 -0700 (PDT) X-Google-Smtp-Source: AJdET5f0/j/V4TkdBce64qH2NbbBhBppT1bxB/9i8xo+dawLiuGiBl24pT3Bfi0PvyVz2bxIbFk7 X-Received: by 2002:a1c:4b15:: with SMTP id y21-v6mr432830wma.122.1540344792928; Tue, 23 Oct 2018 18:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540344792; cv=none; d=google.com; s=arc-20160816; b=XOEcHPDau4yf9IA/nMOlVIfWLC7M2l+gczFJ50dUzSWJe/1RX+2/vOWurFMAoDO+RD 2xXESkSpUCObeGIcZ78jUI8BHXqGYXIBtKqKkVe5OcKtzl/TQaIEt0IZvOG+HvuOJqM+ gGTgU5BIh4bo7bce/+dIxBOEdsoKuHpQEd5K4jii9IeKd/qD9JaU2B0qB3yEChOqN6AW iXDEcueRCBLqLJ3KDnNjU5bOQzkrqolTPWwkWVQ8Fj3+NWeR/t4FOiWU9PTXBVtJ7S16 g93V3DEnNNXVQEJuRu5GdY7C8FoyUuQH/dJwDfTe4cNzEBsJs4MW/BWhUFC/xclavDol Ul9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=IAphX1og5+W4NSW3gCbu/4xBqDGsFu/xCwPs0cpCb/Y=; b=nhkcX5J7QU99czfSrfmGaPE3kSs/Hd9uZ2wd+f2VY2pCgOQzHGY7YCxLo5tHTWvsCO dWEKYDHet+N/TIuPjR/wONZ5ZfCQWpoxcl6wGuGRGh5YO2cpM7u2InM6TNLE7z7//1JT mfP78RAoe7LXi1ZiwpvUTe7B0QXeGPKRLG+54zPo4FgptM0xD8BKCjlqoQojiAQQWAjd n6A75lZiaZC9JoEBQJ8U6WdDGRFv6z5G7YLceyVjJMG97dossgQWk6V0Ri+MY8WTR4R0 3yfERcnVX0ewLJ+UBYMwSSHpY2AS1+Fh5LG/n67uc6w7F0AMTert8o6UtGJZiT7b8yaC O96w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id j18-v6si2282289wrn.354.2018.10.23.18.33.12; Tue, 23 Oct 2018 18:33:12 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 57D0C1B0FB; Wed, 24 Oct 2018 03:32:46 +0200 (CEST) Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id EB4AE5F3B for ; Wed, 24 Oct 2018 03:32:39 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1B67815BE; Tue, 23 Oct 2018 18:32:39 -0700 (PDT) Received: from 2p2660v4-1.austin.arm.com (2p2660v4-1.austin.arm.com [10.118.14.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AA0F83F627; Tue, 23 Oct 2018 18:32:38 -0700 (PDT) From: Honnappa Nagarahalli To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, yipeng1.wang@intel.com, honnappa.nagarahalli@arm.com, dharmik.thakkar@arm.com, gavin.hu@arm.com, nd@arm.com Date: Tue, 23 Oct 2018 20:32:24 -0500 Message-Id: <1540344746-29045-4-git-send-email-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1540344746-29045-1-git-send-email-honnappa.nagarahalli@arm.com> References: <1540344746-29045-1-git-send-email-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v6 3/5] hash: fix key store element alignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fix the key store array element alignment such that every array element is aligned on KEY_ALIGNMENT boundary. This is required to make 'pdata' in 'struct rte_hash_key' align on its natural boundary for atomic load/store. Fixes: 473d1bebce43 ("hash: allow to store data in hash table") Cc: Pablo de Lara Signed-off-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu Reviewed-by: Ola Liljedahl Reviewed-by: Steve Capper Reviewed-by: Yipeng Wang Acked-by: Bruce Richardson --- lib/librte_hash/rte_cuckoo_hash.c | 4 +++- lib/librte_hash/rte_cuckoo_hash.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index e087393..d79ba68 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -279,7 +279,9 @@ rte_hash_create(const struct rte_hash_parameters *params) rte_ring_sp_enqueue(r_ext, (void *)((uintptr_t) i)); } - const uint32_t key_entry_size = sizeof(struct rte_hash_key) + params->key_len; + const uint32_t key_entry_size = + RTE_ALIGN(sizeof(struct rte_hash_key) + params->key_len, + KEY_ALIGNMENT); const uint64_t key_tbl_size = (uint64_t) key_entry_size * num_key_slots; k = rte_zmalloc_socket(NULL, key_tbl_size, diff --git a/lib/librte_hash/rte_cuckoo_hash.h b/lib/librte_hash/rte_cuckoo_hash.h index ff95181..601b2ce 100644 --- a/lib/librte_hash/rte_cuckoo_hash.h +++ b/lib/librte_hash/rte_cuckoo_hash.h @@ -123,7 +123,7 @@ struct rte_hash_key { }; /* Variable key size */ char key[0]; -} __attribute__((aligned(KEY_ALIGNMENT))); +}; /* All different signature compare functions */ enum rte_hash_sig_compare_function {