netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <tom@quantonium.net>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com,
	rohit@quantonium.net, Tom Herbert <tom@quantonium.net>
Subject: [PATCH v3 net-next 3/9] ila: Call library function alloc_bucket_locks
Date: Mon, 11 Dec 2017 12:38:31 -0800	[thread overview]
Message-ID: <20171211203837.2540-4-tom@quantonium.net> (raw)
In-Reply-To: <20171211203837.2540-1-tom@quantonium.net>

To allocate the array of bucket locks for the hash table we now
call library function alloc_bucket_spinlocks.

Signed-off-by: Tom Herbert <tom@quantonium.net>
---
 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,
-- 
2.11.0

  parent reply	other threads:[~2017-12-11 20:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-11 20:38 [PATCH v3 net-next 0/9] net: Generic network resolver backend and ILA resolver Tom Herbert
2017-12-11 20:38 ` [PATCH v3 net-next 1/9] lwt: Add net to build_state argument Tom Herbert
2017-12-11 20:38 ` [PATCH v3 net-next 2/9] ila: Fix use of rhashtable walk in ila_xlat.c Tom Herbert
2017-12-11 20:38 ` Tom Herbert [this message]
2017-12-11 20:38 ` [PATCH v3 net-next 4/9] ila: create main ila source file Tom Herbert
2017-12-11 20:38 ` [PATCH v3 net-next 5/9] ila: Flush netlink command to clear xlat table Tom Herbert
2017-12-11 20:38 ` [PATCH v3 net-next 6/9] net: Generic resolver backend Tom Herbert
2017-12-14  7:16   ` kbuild test robot
2017-12-11 20:38 ` [PATCH v3 net-next 7/9] ila: Resolver mechanism Tom Herbert
2017-12-14 11:00   ` [RFC PATCH] ila: ila_rslv_notify() can be static kbuild test robot
2017-12-14 11:00   ` [PATCH v3 net-next 7/9] ila: Resolver mechanism kbuild test robot
2017-12-11 20:38 ` [PATCH v3 net-next 8/9] resolver: add netlink control Tom Herbert
2017-12-11 20:38 ` [PATCH v3 net-next 9/9] ila: add netlink control ILA resolver Tom Herbert
2017-12-11 21:34 ` [PATCH v3 net-next 0/9] net: Generic network resolver backend and " David Miller
2017-12-11 22:16   ` Tom Herbert
2017-12-11 22:32     ` Tom Herbert
2017-12-12  2:16     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171211203837.2540-4-tom@quantonium.net \
    --to=tom@quantonium.net \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=rohit@quantonium.net \
    --cc=roopa@cumulusnetworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).