diff mbox series

[v4,net-next,3/6] ila: Call library function alloc_bucket_locks

Message ID 20171215182800.10248-4-tom@quantonium.net
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series net: ILA notification mechanism and fixes | expand

Commit Message

Tom Herbert Dec. 15, 2017, 6:27 p.m. UTC
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(-)

Comments

kernel test robot Dec. 16, 2017, 8:47 p.m. UTC | #1
Hi Tom,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Tom-Herbert/net-ILA-notification-mechanism-and-fixes/20171217-041013
config: x86_64-randconfig-x019-201751 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: the linux-review/Tom-Herbert/net-ILA-notification-mechanism-and-fixes/20171217-041013 HEAD bdefe11e33bb3662a60476ea17663189974227a0 builds fine.
      It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

   net/ipv6/ila/ila_xlat.c: In function 'alloc_ila_locks':
>> net/ipv6/ila/ila_xlat.c:39:37: error: 'struct ila_net' has no member named 'xlat'
     return alloc_bucket_spinlocks(&ilan->xlat.locks, &ilan->xlat.locks_mask,
                                        ^~
   net/ipv6/ila/ila_xlat.c:39:56: error: 'struct ila_net' has no member named 'xlat'
     return alloc_bucket_spinlocks(&ilan->xlat.locks, &ilan->xlat.locks_mask,
                                                           ^~
   net/ipv6/ila/ila_xlat.c: In function 'ila_exit_net':
   net/ipv6/ila/ila_xlat.c:630:28: error: 'struct ila_net' has no member named 'xlat'
     free_bucket_spinlocks(ilan->xlat.locks);
                               ^~
   net/ipv6/ila/ila_xlat.c: In function 'alloc_ila_locks':
>> net/ipv6/ila/ila_xlat.c:42:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +39 net/ipv6/ila/ila_xlat.c

    36	
    37	static int alloc_ila_locks(struct ila_net *ilan)
    38	{
  > 39		return alloc_bucket_spinlocks(&ilan->xlat.locks, &ilan->xlat.locks_mask,
    40					      MAX_LOCKS, LOCKS_PER_CPU,
    41					      GFP_KERNEL);
  > 42	}
    43	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c
index 887dd5b785b5..3ef8869ac508 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;
@@ -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->xlat.locks);
 
 	if (ilan->hooks_registered)
 		nf_unregister_net_hooks(net, ila_nf_hook_ops,