CC: kbuild-all(a)lists.01.org In-Reply-To: <20210726222919.5659-1-fw@strlen.de> References: <20210726222919.5659-1-fw@strlen.de> TO: Florian Westphal TO: netfilter-devel(a)vger.kernel.org CC: Florian Westphal CC: Michal Kubecek Hi Florian, I love your patch! Perhaps something to improve: [auto build test WARNING on nf/master] url: https://github.com/0day-ci/linux/commits/Florian-Westphal/netfilter-conntrack-collect-all-entries-in-one-cycle/20210727-063110 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master :::::: branch date: 4 hours ago :::::: commit date: 4 hours ago config: mips-randconfig-s031-20210726 (attached as .config) compiler: mips-linux-gcc (GCC) 10.3.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.3-341-g8af24329-dirty # https://github.com/0day-ci/linux/commit/874bdb31d990217da8f9db6350f4bec782ea2146 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Florian-Westphal/netfilter-conntrack-collect-all-entries-in-one-cycle/20210727-063110 git checkout 874bdb31d990217da8f9db6350f4bec782ea2146 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=mips SHELL=/bin/bash net/netfilter/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) command-line: note: in included file: builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQUIRE redefined builtin:0:0: sparse: this was the original definition builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_SEQ_CST redefined builtin:0:0: sparse: this was the original definition builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_ACQ_REL redefined builtin:0:0: sparse: this was the original definition builtin:1:9: sparse: sparse: preprocessor token __ATOMIC_RELEASE redefined builtin:0:0: sparse: this was the original definition net/netfilter/nf_conntrack_core.c:2384:9: sparse: sparse: incompatible types in comparison expression (different address spaces): net/netfilter/nf_conntrack_core.c:2384:9: sparse: void ( [noderef] __rcu * )( ... ) net/netfilter/nf_conntrack_core.c:2384:9: sparse: void ( * )( ... ) net/netfilter/nf_conntrack_core.c:2703:9: sparse: sparse: incompatible types in comparison expression (different address spaces): net/netfilter/nf_conntrack_core.c:2703:9: sparse: void ( [noderef] __rcu * )( ... ) net/netfilter/nf_conntrack_core.c:2703:9: sparse: void ( * )( ... ) net/netfilter/nf_conntrack_core.c:108:13: sparse: sparse: context imbalance in 'nf_conntrack_double_unlock' - unexpected unlock net/netfilter/nf_conntrack_core.c:118:13: sparse: sparse: context imbalance in 'nf_conntrack_double_lock' - wrong count at exit >> net/netfilter/nf_conntrack_core.c:1359:13: sparse: sparse: context imbalance in 'gc_worker' - wrong count at exit net/netfilter/nf_conntrack_core.c:2216:28: sparse: sparse: context imbalance in 'get_next_corpse' - unexpected unlock vim +/gc_worker +1359 net/netfilter/nf_conntrack_core.c c6dd940b1f747b Florian Westphal 2017-04-16 1358 b87a2f9199ea82 Florian Westphal 2016-08-25 @1359 static void gc_worker(struct work_struct *work) b87a2f9199ea82 Florian Westphal 2016-08-25 1360 { 874bdb31d99021 Florian Westphal 2021-07-27 1361 unsigned long end_time = jiffies + GC_SCAN_MAX_DURATION; 874bdb31d99021 Florian Westphal 2021-07-27 1362 unsigned int i, hashsz, nf_conntrack_max95 = 0; 874bdb31d99021 Florian Westphal 2021-07-27 1363 unsigned long next_run = GC_SCAN_INTERVAL; b87a2f9199ea82 Florian Westphal 2016-08-25 1364 struct conntrack_gc_work *gc_work; b87a2f9199ea82 Florian Westphal 2016-08-25 1365 gc_work = container_of(work, struct conntrack_gc_work, dwork.work); b87a2f9199ea82 Florian Westphal 2016-08-25 1366 874bdb31d99021 Florian Westphal 2021-07-27 1367 i = gc_work->next_bucket; c6dd940b1f747b Florian Westphal 2017-04-16 1368 if (gc_work->early_drop) c6dd940b1f747b Florian Westphal 2017-04-16 1369 nf_conntrack_max95 = nf_conntrack_max / 100u * 95u; b87a2f9199ea82 Florian Westphal 2016-08-25 1370 b87a2f9199ea82 Florian Westphal 2016-08-25 1371 do { b87a2f9199ea82 Florian Westphal 2016-08-25 1372 struct nf_conntrack_tuple_hash *h; b87a2f9199ea82 Florian Westphal 2016-08-25 1373 struct hlist_nulls_head *ct_hash; b87a2f9199ea82 Florian Westphal 2016-08-25 1374 struct hlist_nulls_node *n; b87a2f9199ea82 Florian Westphal 2016-08-25 1375 struct nf_conn *tmp; b87a2f9199ea82 Florian Westphal 2016-08-25 1376 b87a2f9199ea82 Florian Westphal 2016-08-25 1377 rcu_read_lock(); b87a2f9199ea82 Florian Westphal 2016-08-25 1378 b87a2f9199ea82 Florian Westphal 2016-08-25 1379 nf_conntrack_get_ht(&ct_hash, &hashsz); b87a2f9199ea82 Florian Westphal 2016-08-25 1380 if (i >= hashsz) 874bdb31d99021 Florian Westphal 2021-07-27 1381 break; b87a2f9199ea82 Florian Westphal 2016-08-25 1382 b87a2f9199ea82 Florian Westphal 2016-08-25 1383 hlist_nulls_for_each_entry_rcu(h, n, &ct_hash[i], hnnode) { c53bd0e96662c2 Florian Westphal 2021-04-12 1384 struct nf_conntrack_net *cnet; c6dd940b1f747b Florian Westphal 2017-04-16 1385 struct net *net; c6dd940b1f747b Florian Westphal 2017-04-16 1386 b87a2f9199ea82 Florian Westphal 2016-08-25 1387 tmp = nf_ct_tuplehash_to_ctrack(h); b87a2f9199ea82 Florian Westphal 2016-08-25 1388 90964016e5d347 Pablo Neira Ayuso 2018-01-07 1389 if (test_bit(IPS_OFFLOAD_BIT, &tmp->status)) { 90964016e5d347 Pablo Neira Ayuso 2018-01-07 1390 nf_ct_offload_timeout(tmp); 90964016e5d347 Pablo Neira Ayuso 2018-01-07 1391 continue; 90964016e5d347 Pablo Neira Ayuso 2018-01-07 1392 } 90964016e5d347 Pablo Neira Ayuso 2018-01-07 1393 b87a2f9199ea82 Florian Westphal 2016-08-25 1394 if (nf_ct_is_expired(tmp)) { b87a2f9199ea82 Florian Westphal 2016-08-25 1395 nf_ct_gc_expired(tmp); b87a2f9199ea82 Florian Westphal 2016-08-25 1396 continue; b87a2f9199ea82 Florian Westphal 2016-08-25 1397 } c6dd940b1f747b Florian Westphal 2017-04-16 1398 c6dd940b1f747b Florian Westphal 2017-04-16 1399 if (nf_conntrack_max95 == 0 || gc_worker_skip_ct(tmp)) c6dd940b1f747b Florian Westphal 2017-04-16 1400 continue; c6dd940b1f747b Florian Westphal 2017-04-16 1401 c6dd940b1f747b Florian Westphal 2017-04-16 1402 net = nf_ct_net(tmp); 0418b989a46788 Pablo Neira Ayuso 2021-06-02 1403 cnet = nf_ct_pernet(net); c53bd0e96662c2 Florian Westphal 2021-04-12 1404 if (atomic_read(&cnet->count) < nf_conntrack_max95) c6dd940b1f747b Florian Westphal 2017-04-16 1405 continue; c6dd940b1f747b Florian Westphal 2017-04-16 1406 c6dd940b1f747b Florian Westphal 2017-04-16 1407 /* need to take reference to avoid possible races */ c6dd940b1f747b Florian Westphal 2017-04-16 1408 if (!atomic_inc_not_zero(&tmp->ct_general.use)) c6dd940b1f747b Florian Westphal 2017-04-16 1409 continue; c6dd940b1f747b Florian Westphal 2017-04-16 1410 c6dd940b1f747b Florian Westphal 2017-04-16 1411 if (gc_worker_skip_ct(tmp)) { c6dd940b1f747b Florian Westphal 2017-04-16 1412 nf_ct_put(tmp); c6dd940b1f747b Florian Westphal 2017-04-16 1413 continue; c6dd940b1f747b Florian Westphal 2017-04-16 1414 } c6dd940b1f747b Florian Westphal 2017-04-16 1415 c6dd940b1f747b Florian Westphal 2017-04-16 1416 if (gc_worker_can_early_drop(tmp)) c6dd940b1f747b Florian Westphal 2017-04-16 1417 nf_ct_kill(tmp); c6dd940b1f747b Florian Westphal 2017-04-16 1418 c6dd940b1f747b Florian Westphal 2017-04-16 1419 nf_ct_put(tmp); b87a2f9199ea82 Florian Westphal 2016-08-25 1420 } b87a2f9199ea82 Florian Westphal 2016-08-25 1421 b87a2f9199ea82 Florian Westphal 2016-08-25 1422 /* could check get_nulls_value() here and restart if ct b87a2f9199ea82 Florian Westphal 2016-08-25 1423 * was moved to another chain. But given gc is best-effort b87a2f9199ea82 Florian Westphal 2016-08-25 1424 * we will just continue with next hash slot. b87a2f9199ea82 Florian Westphal 2016-08-25 1425 */ b87a2f9199ea82 Florian Westphal 2016-08-25 1426 rcu_read_unlock(); ffa53c5863ddb2 Paul E. McKenney 2017-10-24 1427 cond_resched(); 874bdb31d99021 Florian Westphal 2021-07-27 1428 i++; 874bdb31d99021 Florian Westphal 2021-07-27 1429 874bdb31d99021 Florian Westphal 2021-07-27 1430 if (time_after(jiffies, end_time) && i < hashsz) { 874bdb31d99021 Florian Westphal 2021-07-27 1431 gc_work->next_bucket = i; 874bdb31d99021 Florian Westphal 2021-07-27 1432 next_run = 0; 874bdb31d99021 Florian Westphal 2021-07-27 1433 break; 874bdb31d99021 Florian Westphal 2021-07-27 1434 } 874bdb31d99021 Florian Westphal 2021-07-27 1435 } while (i < hashsz); b87a2f9199ea82 Florian Westphal 2016-08-25 1436 b87a2f9199ea82 Florian Westphal 2016-08-25 1437 if (gc_work->exiting) b87a2f9199ea82 Florian Westphal 2016-08-25 1438 return; b87a2f9199ea82 Florian Westphal 2016-08-25 1439 e0df8cae6c16b9 Florian Westphal 2016-11-04 1440 /* e0df8cae6c16b9 Florian Westphal 2016-11-04 1441 * Eviction will normally happen from the packet path, and not e0df8cae6c16b9 Florian Westphal 2016-11-04 1442 * from this gc worker. e0df8cae6c16b9 Florian Westphal 2016-11-04 1443 * e0df8cae6c16b9 Florian Westphal 2016-11-04 1444 * This worker is only here to reap expired entries when system went e0df8cae6c16b9 Florian Westphal 2016-11-04 1445 * idle after a busy period. e0df8cae6c16b9 Florian Westphal 2016-11-04 1446 */ 874bdb31d99021 Florian Westphal 2021-07-27 1447 if (next_run) { c6dd940b1f747b Florian Westphal 2017-04-16 1448 gc_work->early_drop = false; 874bdb31d99021 Florian Westphal 2021-07-27 1449 gc_work->next_bucket = 0; 874bdb31d99021 Florian Westphal 2021-07-27 1450 } 0984d427c1d3cb Vincent Guittot 2017-11-02 1451 queue_delayed_work(system_power_efficient_wq, &gc_work->dwork, next_run); b87a2f9199ea82 Florian Westphal 2016-08-25 1452 } b87a2f9199ea82 Florian Westphal 2016-08-25 1453 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org