From patchwork Mon Dec 11 20:38:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 847215 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quantonium-net.20150623.gappssmtp.com header.i=@quantonium-net.20150623.gappssmtp.com header.b="DyzRYf+C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ywZZ50Y0dz9sRm for ; Tue, 12 Dec 2017 07:39:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752570AbdLKUjW (ORCPT ); Mon, 11 Dec 2017 15:39:22 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:44913 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752498AbdLKUjI (ORCPT ); Mon, 11 Dec 2017 15:39:08 -0500 Received: by mail-pf0-f193.google.com with SMTP id m26so12429880pfj.11 for ; Mon, 11 Dec 2017 12:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantonium-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e489jEXl2Z+OVxmDmqVJoJykEDqddOfNQJRN+jzQIJU=; b=DyzRYf+CRvR2nVa5dNf1cFh45MzL1179nZV++m6940AQjDitzcdVug2bFApCe/PtJk h36oJotdqXLxI9viImTQc+pSbnUU3z/QxOH5Bu14iL4ZmaRfiSKfL23uyB3mQESBr7et vtWWRfIRKFb3ImA2ySXBks7haYvnTO/LRaoNp7Yk9yf6gad+FJPxErKzKOsrxqN3dmSU vIFhLgiyxCBC2ShmcmEi5lKThD70yUafd4V/W9GXCFCDTYOFnWVD89O0YFOZ3Tnu2U5B rZ+Q0lIePkCmX+JlN841dfJwfWok3V4A2M5g/XFnA7/JjLoWtfJoDJmz+Y/SE6SWcSHh gJUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e489jEXl2Z+OVxmDmqVJoJykEDqddOfNQJRN+jzQIJU=; b=ENSrndaaT7BJKWAuiBB51WiSSJ7xL2YOEJat3ReRyyxT2ud4CfBT88Ti+dNVDgx+PL gyV56Y3uFM1OPTiGA2fQFZSl05/VGF7IIXQ4ehCIcqJpoUdF6ulODJYrliuMgHqXfTG8 7+z80wTXmVe5mQ6y/oTfxj5w0wMSXj5Gh8ywFdusW96BcfvBaWT8xDGDjrq/Dbe6zBy+ 8PcHfRDcAATXsBuTO/qvfGKAYOb/shD1ou53nWSh5iE0e/M+Dw0m465kzWS1UdRnZA6+ soNmR3ZiouVHJ83eIwxsxw5KcgEebJ4OJGoDAIW9WMRDy0bVzPZazAT4nxuQAPtoZbyz JEpg== X-Gm-Message-State: AKGB3mJ+UcJXEsnDN9rdek0q48cjdHdbIDiBVu+EVg2+p0t7pteXuVLE mzjyLl4JrTYdL6tBCe8zpanZ9/2D X-Google-Smtp-Source: ACJfBov6AvqPg95mvKCGY/5/SBbx3zymnftYjTIf9zHR7v5gRMLBTdj+x2W0pco3iQwzBJFVdXDWKw== X-Received: by 10.159.214.137 with SMTP id n9mr1563642plp.126.1513024748182; Mon, 11 Dec 2017 12:39:08 -0800 (PST) Received: from localhost.localdomain (67-207-98-108.static.wiline.com. [67.207.98.108]) by smtp.gmail.com with ESMTPSA id t6sm26426790pfl.76.2017.12.11.12.39.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 12:39:07 -0800 (PST) From: Tom Herbert To: davem@davemloft.net Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com, rohit@quantonium.net, Tom Herbert Subject: [PATCH v3 net-next 3/9] ila: Call library function alloc_bucket_locks Date: Mon, 11 Dec 2017 12:38:31 -0800 Message-Id: <20171211203837.2540-4-tom@quantonium.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171211203837.2540-1-tom@quantonium.net> References: <20171211203837.2540-1-tom@quantonium.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org To allocate the array of bucket locks for the hash table we now call library function alloc_bucket_spinlocks. Signed-off-by: Tom Herbert --- net/ipv6/ila/ila_xlat.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c index 9fca75b9cab3..402193ef74c2 100644 --- a/net/ipv6/ila/ila_xlat.c +++ b/net/ipv6/ila/ila_xlat.c @@ -31,26 +31,14 @@ struct ila_net { bool hooks_registered; }; +#define MAX_LOCKS 1024 #define LOCKS_PER_CPU 10 static int alloc_ila_locks(struct ila_net *ilan) { - unsigned int i, size; - unsigned int nr_pcpus = num_possible_cpus(); - - nr_pcpus = min_t(unsigned int, nr_pcpus, 32UL); - size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU); - - if (sizeof(spinlock_t) != 0) { - ilan->locks = kvmalloc(size * sizeof(spinlock_t), GFP_KERNEL); - if (!ilan->locks) - return -ENOMEM; - for (i = 0; i < size; i++) - spin_lock_init(&ilan->locks[i]); - } - ilan->locks_mask = size - 1; - - return 0; + return alloc_bucket_spinlocks(&ilan->xlat.locks, &ilan->xlat.locks_mask, + MAX_LOCKS, LOCKS_PER_CPU, + GFP_KERNEL); } static u32 hashrnd __read_mostly; @@ -629,7 +617,7 @@ static __net_exit void ila_exit_net(struct net *net) rhashtable_free_and_destroy(&ilan->rhash_table, ila_free_cb, NULL); - kvfree(ilan->locks); + free_bucket_spinlocks(ilan->xlat.locks); if (ilan->hooks_registered) nf_unregister_net_hooks(net, ila_nf_hook_ops,