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 v5 net-next 4/7] ila: Call library function alloc_bucket_locks
Date: Thu, 21 Dec 2017 11:33:29 -0800 [thread overview]
Message-ID: <20171221193332.15303-5-tom@quantonium.net> (raw)
In-Reply-To: <20171221193332.15303-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 887dd5b785b5..9cc8beedc2ca 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->locks, &ilan->locks_mask,
+ MAX_LOCKS, LOCKS_PER_CPU,
+ GFP_KERNEL);
}
static u32 hashrnd __read_mostly;
@@ -639,7 +627,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->locks);
if (ilan->hooks_registered)
nf_unregister_net_hooks(net, ila_nf_hook_ops,
--
2.11.0
next prev parent reply other threads:[~2017-12-21 19:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 19:33 [PATCH v5 net-next 0/7] net: ILA notification mechanism and fixes Tom Herbert
2017-12-21 19:33 ` [PATCH v5 net-next 1/7] lwt: Add net to build_state argument Tom Herbert
2017-12-21 19:33 ` [PATCH v5 net-next 2/7] rtnetlink: Add notify route message types Tom Herbert
2017-12-21 19:33 ` [PATCH v5 net-next 3/7] ila: Fix use of rhashtable walk in ila_xlat.c Tom Herbert
2017-12-21 19:33 ` Tom Herbert [this message]
2017-12-21 19:33 ` [PATCH v5 net-next 5/7] ila: Create main ila source file Tom Herbert
2017-12-21 19:33 ` [PATCH v5 net-next 6/7] ila: Flush netlink command to clear xlat table Tom Herbert
2017-12-21 19:33 ` [PATCH v5 net-next 7/7] ila: Route notify Tom Herbert
2017-12-26 22:29 ` [PATCH v5 net-next 0/7] net: ILA notification mechanism and fixes David Miller
2017-12-26 23:50 ` Tom Herbert
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=20171221193332.15303-5-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