Re: [PATCH v3 02/36] crypto_pool: Add crypto_pool_reserve_scratch()
From: kernel test robot <hidden>
Date: 2022-10-28 07:07:39
Also in:
linux-crypto, lkml, oe-kbuild-all
Hi Dmitry, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on 4dc12f37a8e98e1dca5521c14625c869537b50b6] url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Safonov/net-tcp-Add-TCP-AO-support/20221028-045452 base: 4dc12f37a8e98e1dca5521c14625c869537b50b6 patch link: https://lore.kernel.org/r/20221027204347.529913-3-dima%40arista.com patch subject: [PATCH v3 02/36] crypto_pool: Add crypto_pool_reserve_scratch() config: sparc-allyesconfig compiler: sparc64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/77f338ef8d76766e86b5b0b722a2a54fd2973c93 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Dmitry-Safonov/net-tcp-Add-TCP-AO-support/20221028-045452 git checkout 77f338ef8d76766e86b5b0b722a2a54fd2973c93 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot [off-list ref] All warnings (new ones prefixed by >>):
quoted
crypto/crypto_pool.c:31: warning: expecting prototype for crypto_pool_reserve_scratch(). Prototype was for FREE_BATCH_SIZE() instead
vim +31 crypto/crypto_pool.c
25
26 /* Slow-path */
27 /**
28 * crypto_pool_reserve_scratch - re-allocates scratch buffer, slow-path
29 * @size: request size for the scratch/temp buffer
30 */
> 31 #define FREE_BATCH_SIZE 64
32 int crypto_pool_reserve_scratch(unsigned long size)
33 {
34 void *free_batch[FREE_BATCH_SIZE];
35 int cpu, err = 0;
36 unsigned int i = 0;
37
38 mutex_lock(&cpool_mutex);
39 if (size == scratch_size) {
40 for_each_possible_cpu(cpu) {
41 if (per_cpu(crypto_pool_scratch, cpu))
42 continue;
43 goto allocate_scratch;
44 }
45 mutex_unlock(&cpool_mutex);
46 return 0;
47 }
48 allocate_scratch:
49 size = max(size, scratch_size);
50 cpus_read_lock();
51 for_each_possible_cpu(cpu) {
52 void *scratch, *old_scratch;
53
54 scratch = kmalloc_node(size, GFP_KERNEL, cpu_to_node(cpu));
55 if (!scratch) {
56 err = -ENOMEM;
57 break;
58 }
59
60 old_scratch = per_cpu(crypto_pool_scratch, cpu);
61 /* Pairs with crypto_pool_get() */
62 WRITE_ONCE(*per_cpu_ptr(&crypto_pool_scratch, cpu), scratch);
63 if (!cpu_online(cpu)) {
64 kfree(old_scratch);
65 continue;
66 }
67 free_batch[i++] = old_scratch;
68 if (i == FREE_BATCH_SIZE) {
69 cpus_read_unlock();
70 synchronize_rcu();
71 while (i > 0)
72 kfree(free_batch[--i]);
73 cpus_read_lock();
74 }
75 }
76 cpus_read_unlock();
77 if (!err)
78 scratch_size = size;
79 mutex_unlock(&cpool_mutex);
80
81 if (i > 0) {
82 synchronize_rcu();
83 while (i > 0)
84 kfree(free_batch[--i]);
85 }
86 return err;
87 }
88 EXPORT_SYMBOL_GPL(crypto_pool_reserve_scratch);
89
--
0-DAY CI Kernel Test Service
https://01.org/lkp