From patchwork Sun Oct 1 07:57:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 820238 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y4dGP2lnqz9sRq for ; Sun, 1 Oct 2017 19:08:29 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5E84C723; Sun, 1 Oct 2017 08:07:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 63A7D82 for ; Sun, 1 Oct 2017 08:07:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 21175CE for ; Sun, 1 Oct 2017 08:07:43 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 01 Oct 2017 01:07:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,463,1500966000"; d="scan'208"; a="1020308548" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by orsmga003.jf.intel.com with ESMTP; 01 Oct 2017 01:07:41 -0700 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Sun, 1 Oct 2017 08:57:35 +0100 Message-Id: <1506844660-4902-2-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1506844660-4902-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1506844660-4902-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/7] cmap: Use PADDED_MEMBERS_CACHELINE_MARKER in cmap_impl. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Instead of explicitly adding the pad bytes to force the structure an exact multiple of cacheline size, let the macro do the job. This way the pad bytes will be auto adjusted when the new members get introduced in to the structure. Signed-off-by: Bhanuprakash Bodireddy --- lib/cmap.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/cmap.c b/lib/cmap.c index 8c7312d..35decea 100644 --- a/lib/cmap.c +++ b/lib/cmap.c @@ -165,13 +165,18 @@ BUILD_ASSERT_DECL(sizeof(struct cmap_bucket) == CACHE_LINE_SIZE); /* The implementation of a concurrent hash map. */ struct cmap_impl { - unsigned int n; /* Number of in-use elements. */ - unsigned int max_n; /* Max elements before enlarging. */ - unsigned int min_n; /* Min elements before shrinking. */ - uint32_t mask; /* Number of 'buckets', minus one. */ - uint32_t basis; /* Basis for rehashing client's hash values. */ - uint8_t pad[CACHE_LINE_SIZE - 4 * 5]; /* Pad to end of cache line. */ - struct cmap_bucket buckets[1]; + PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline0, + unsigned int n; /* Number of in-use elements. */ + unsigned int max_n; /* Max elements before enlarging. */ + unsigned int min_n; /* Min elements before shrinking. */ + uint32_t mask; /* Number of 'buckets', minus one. */ + uint32_t basis; /* Basis for rehashing client's + hash values. */ + ); + + PADDED_MEMBERS_CACHELINE_MARKER(CACHE_LINE_SIZE, cacheline1, + struct cmap_bucket buckets[1]; + ); }; BUILD_ASSERT_DECL(sizeof(struct cmap_impl) == CACHE_LINE_SIZE * 2);