tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 5957ac6635a1a12d4aa2661bbf04d3085a73372a commit: ee4ed53c5eb62f49f23560cc2642353547e46c32 [4810/5850] bpf: Convert percpu hash map to per-cpu bpf_mem_alloc. config: nios2-randconfig-s052-20220906 (https://download.01.org/0day-ci/archive/20220907/202209072120.mpA19MLJ-lkp@xxxxxxxxx/config) compiler: nios2-linux-gcc (GCC) 12.1.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.4-39-gce1a6720-dirty # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=ee4ed53c5eb62f49f23560cc2642353547e46c32 git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git fetch --no-tags linux-next master git checkout ee4ed53c5eb62f49f23560cc2642353547e46c32 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash kernel/bpf/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@xxxxxxxxx> sparse warnings: (new ones prefixed by >>) >> kernel/bpf/hashtab.c:1059:30: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __percpu *[assigned] pptr @@ got void * @@ kernel/bpf/hashtab.c:1059:30: sparse: expected void [noderef] __percpu *[assigned] pptr kernel/bpf/hashtab.c:1059:30: sparse: got void * >> kernel/bpf/hashtab.c:1065:44: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *ptr_to_pptr @@ got void [noderef] __percpu *[assigned] pptr @@ kernel/bpf/hashtab.c:1065:44: sparse: expected void *ptr_to_pptr kernel/bpf/hashtab.c:1065:44: sparse: got void [noderef] __percpu *[assigned] pptr >> kernel/bpf/hashtab.c:1066:34: sparse: sparse: cast removes address space '__percpu' of expression kernel/bpf/hashtab.c:1066:30: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __percpu *[assigned] pptr @@ got void * @@ kernel/bpf/hashtab.c:1066:30: sparse: expected void [noderef] __percpu *[assigned] pptr kernel/bpf/hashtab.c:1066:30: sparse: got void * kernel/bpf/hashtab.c:208:17: sparse: sparse: context imbalance in 'htab_map_delete_elem' - unexpected unlock kernel/bpf/hashtab.c:208:17: sparse: sparse: context imbalance in 'htab_lru_map_delete_elem' - unexpected unlock kernel/bpf/hashtab.c:208:17: sparse: sparse: context imbalance in '__htab_map_lookup_and_delete_elem' - unexpected unlock kernel/bpf/hashtab.c: note: in included file (through include/linux/workqueue.h, include/linux/bpf.h): include/linux/rcupdate.h:737:9: sparse: sparse: context imbalance in '__htab_map_lookup_and_delete_batch' - unexpected unlock kernel/bpf/hashtab.c:2019:17: sparse: sparse: context imbalance in 'bpf_hash_map_seq_find_next' - unexpected unlock include/linux/rcupdate.h:737:9: sparse: sparse: context imbalance in 'bpf_hash_map_seq_stop' - unexpected unlock vim +1059 kernel/bpf/hashtab.c 1006 1007 static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key, 1008 void *value, u32 key_size, u32 hash, 1009 bool percpu, bool onallcpus, 1010 struct htab_elem *old_elem) 1011 { 1012 u32 size = htab->map.value_size; 1013 bool prealloc = htab_is_prealloc(htab); 1014 struct htab_elem *l_new, **pl_new; 1015 void __percpu *pptr; 1016 1017 if (prealloc) { 1018 if (old_elem) { 1019 /* if we're updating the existing element, 1020 * use per-cpu extra elems to avoid freelist_pop/push 1021 */ 1022 pl_new = this_cpu_ptr(htab->extra_elems); 1023 l_new = *pl_new; 1024 htab_put_fd_value(htab, old_elem); 1025 *pl_new = old_elem; 1026 } else { 1027 struct pcpu_freelist_node *l; 1028 1029 l = __pcpu_freelist_pop(&htab->freelist); 1030 if (!l) 1031 return ERR_PTR(-E2BIG); 1032 l_new = container_of(l, struct htab_elem, fnode); 1033 } 1034 } else { 1035 if (is_map_full(htab)) 1036 if (!old_elem) 1037 /* when map is full and update() is replacing 1038 * old element, it's ok to allocate, since 1039 * old element will be freed immediately. 1040 * Otherwise return an error 1041 */ 1042 return ERR_PTR(-E2BIG); 1043 inc_elem_count(htab); 1044 l_new = bpf_mem_cache_alloc(&htab->ma); 1045 if (!l_new) { 1046 l_new = ERR_PTR(-ENOMEM); 1047 goto dec_count; 1048 } 1049 check_and_init_map_value(&htab->map, 1050 l_new->key + round_up(key_size, 8)); 1051 } 1052 1053 memcpy(l_new->key, key, key_size); 1054 if (percpu) { 1055 if (prealloc) { 1056 pptr = htab_elem_get_ptr(l_new, key_size); 1057 } else { 1058 /* alloc_percpu zero-fills */ > 1059 pptr = bpf_mem_cache_alloc(&htab->pcpu_ma); 1060 if (!pptr) { 1061 bpf_mem_cache_free(&htab->ma, l_new); 1062 l_new = ERR_PTR(-ENOMEM); 1063 goto dec_count; 1064 } > 1065 l_new->ptr_to_pptr = pptr; > 1066 pptr = *(void **)pptr; 1067 } 1068 1069 pcpu_init_value(htab, pptr, value, onallcpus); 1070 1071 if (!prealloc) 1072 htab_elem_set_ptr(l_new, key_size, pptr); 1073 } else if (fd_htab_map_needs_adjust(htab)) { 1074 size = round_up(size, 8); 1075 memcpy(l_new->key + round_up(key_size, 8), value, size); 1076 } else { 1077 copy_map_value(&htab->map, 1078 l_new->key + round_up(key_size, 8), 1079 value); 1080 } 1081 1082 l_new->hash = hash; 1083 return l_new; 1084 dec_count: 1085 dec_elem_count(htab); 1086 return l_new; 1087 } 1088 -- 0-DAY CI Kernel Test Service https://01.org/lkp