From patchwork Sun Oct 1 07:57:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 820237 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 3y4dFg4wCTz9sRq for ; Sun, 1 Oct 2017 19:07:49 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5C12C49F; Sun, 1 Oct 2017 08:07:44 +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 1CE3F82 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 33139CE for ; Sun, 1 Oct 2017 08:07:42 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 01 Oct 2017 01:07:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,463,1500966000"; d="scan'208"; a="1020308545" 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:40 -0700 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Sun, 1 Oct 2017 08:57:34 +0100 Message-Id: <1506844660-4902-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 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 1/7] ccmap: Use PADDED_MEMBERS macro in ccmap_impl structure. 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 PADDED_MEMBERS macro do the job. Signed-off-by: Bhanuprakash Bodireddy --- lib/ccmap.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/ccmap.c b/lib/ccmap.c index 08359b5..a460833 100644 --- a/lib/ccmap.c +++ b/lib/ccmap.c @@ -102,16 +102,15 @@ BUILD_ASSERT_DECL(sizeof(struct ccmap_bucket) == CACHE_LINE_SIZE); /* The implementation of a concurrent hash map. */ struct ccmap_impl { - unsigned int n_unique; /* Number of in-use nodes. */ - unsigned int n; /* Number of hashes inserted. */ - unsigned int max_n; /* Max nodes before enlarging. */ - unsigned int min_n; /* Min nodes before shrinking. */ - uint32_t mask; /* Number of 'buckets', minus one. */ - uint32_t basis; /* Basis for rehashing client's hash values. */ - - /* Padding to make ccmap_impl exactly one cache line long. */ - uint8_t pad[CACHE_LINE_SIZE - sizeof(unsigned int) * 6]; - + PADDED_MEMBERS(CACHE_LINE_SIZE, + unsigned int n_unique; /* Number of in-use nodes. */ + unsigned int n; /* Number of hashes inserted. */ + unsigned int max_n; /* Max nodes before enlarging. */ + unsigned int min_n; /* Min nodes before shrinking. */ + uint32_t mask; /* Number of 'buckets', minus one. */ + uint32_t basis; /* Basis for rehashing client's + hash values. */ + ); struct ccmap_bucket buckets[]; }; BUILD_ASSERT_DECL(sizeof(struct ccmap_impl) == CACHE_LINE_SIZE);