public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Kees Cook <keescook@chromium.org>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: [kees:devel/overflow/enable-unsigned-sanitizer 26/100] fs/bcachefs/btree_locking.c:374:9: error: use of undeclared identifier 'sub_wrap'
Date: Mon, 29 Jan 2024 00:40:39 +0800	[thread overview]
Message-ID: <202401290037.HTRCJohQ-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git devel/overflow/enable-unsigned-sanitizer
head:   a7e79409b1cc59a7f181e2b04e0cb4835b620b81
commit: 41236ed2b6bd8c9f9fdd235e7a44b7729c36e38a [26/100] [WIP] include/linux/jiffies.h: wrapping jiffies: use sub_wrap()
config: i386-buildonly-randconfig-003-20240128 (https://download.01.org/0day-ci/archive/20240129/202401290037.HTRCJohQ-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240129/202401290037.HTRCJohQ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401290037.HTRCJohQ-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/bcachefs/btree_locking.c:374:9: error: too few arguments provided to function-like macro invocation
     374 |                                     time_after_eq64(top->lock_start_time, trans->locking_wait.start_time))
         |                                     ^
   include/linux/jiffies.h:225:42: note: expanded from macro 'time_after_eq64'
     225 |          ((__s64)sub_wrap(__u64, ((a), (b)) >= 0))
         |                                                 ^
   include/linux/overflow.h:177:9: note: macro 'sub_wrap' defined here
     177 | #define sub_wrap(type, a, b)                            \
         |         ^
>> fs/bcachefs/btree_locking.c:374:9: error: use of undeclared identifier 'sub_wrap'
     374 |                                     time_after_eq64(top->lock_start_time, trans->locking_wait.start_time))
         |                                     ^
   include/linux/jiffies.h:225:11: note: expanded from macro 'time_after_eq64'
     225 |          ((__s64)sub_wrap(__u64, ((a), (b)) >= 0))
         |                  ^
   2 errors generated.
--
>> fs/bcachefs/six.c:439:8: error: too few arguments provided to function-like macro invocation
     439 |                         if (time_before_eq64(wait->start_time, last->start_time))
         |                             ^
   include/linux/jiffies.h:236:31: note: expanded from macro 'time_before_eq64'
     236 | #define time_before_eq64(a,b)   time_after_eq64(b,a)
         |                                 ^
   include/linux/jiffies.h:225:42: note: expanded from macro 'time_after_eq64'
     225 |          ((__s64)sub_wrap(__u64, ((a), (b)) >= 0))
         |                                                 ^
   include/linux/overflow.h:177:9: note: macro 'sub_wrap' defined here
     177 | #define sub_wrap(type, a, b)                            \
         |         ^
>> fs/bcachefs/six.c:439:8: error: use of undeclared identifier 'sub_wrap'
     439 |                         if (time_before_eq64(wait->start_time, last->start_time))
         |                             ^
   include/linux/jiffies.h:236:31: note: expanded from macro 'time_before_eq64'
     236 | #define time_before_eq64(a,b)   time_after_eq64(b,a)
         |                                 ^
   include/linux/jiffies.h:225:11: note: expanded from macro 'time_after_eq64'
     225 |          ((__s64)sub_wrap(__u64, ((a), (b)) >= 0))
         |                  ^
   2 errors generated.


vim +/sub_wrap +374 fs/bcachefs/btree_locking.c

33bd5d068603f9 Kent Overstreet 2022-08-22  284  
96d994b37cfcf4 Kent Overstreet 2022-08-22  285  int bch2_check_for_deadlock(struct btree_trans *trans, struct printbuf *cycle)
33bd5d068603f9 Kent Overstreet 2022-08-22  286  {
33bd5d068603f9 Kent Overstreet 2022-08-22  287  	struct lock_graph g;
33bd5d068603f9 Kent Overstreet 2022-08-22  288  	struct trans_waiting_for_lock *top;
33bd5d068603f9 Kent Overstreet 2022-08-22  289  	struct btree_bkey_cached_common *b;
fea153a84557c9 Kent Overstreet 2023-12-12  290  	btree_path_idx_t path_idx;
fea153a84557c9 Kent Overstreet 2023-12-12  291  	int ret = 0;
33bd5d068603f9 Kent Overstreet 2022-08-22  292  
3398124444b900 Kent Overstreet 2023-05-26  293  	g.nr = 0;
3398124444b900 Kent Overstreet 2023-05-26  294  
0d7009d7ca99ad Kent Overstreet 2022-08-22  295  	if (trans->lock_must_abort) {
40405557b92dfe Kent Overstreet 2023-01-20  296  		if (cycle)
40405557b92dfe Kent Overstreet 2023-01-20  297  			return -1;
40405557b92dfe Kent Overstreet 2023-01-20  298  
c13fbb7de2fc4f Kent Overstreet 2024-01-04  299  		trace_would_deadlock(&g, trans);
33bd5d068603f9 Kent Overstreet 2022-08-22  300  		return btree_trans_restart(trans, BCH_ERR_transaction_restart_would_deadlock);
0d7009d7ca99ad Kent Overstreet 2022-08-22  301  	}
33bd5d068603f9 Kent Overstreet 2022-08-22  302  
896f1b316f8e8f Kent Overstreet 2022-10-12  303  	lock_graph_down(&g, trans);
fea153a84557c9 Kent Overstreet 2023-12-12  304  
fea153a84557c9 Kent Overstreet 2023-12-12  305  	/* trans->paths is rcu protected vs. freeing */
fea153a84557c9 Kent Overstreet 2023-12-12  306  	rcu_read_lock();
fea153a84557c9 Kent Overstreet 2023-12-12  307  	if (cycle)
fea153a84557c9 Kent Overstreet 2023-12-12  308  		cycle->atomic++;
33bd5d068603f9 Kent Overstreet 2022-08-22  309  next:
33bd5d068603f9 Kent Overstreet 2022-08-22  310  	if (!g.nr)
fea153a84557c9 Kent Overstreet 2023-12-12  311  		goto out;
33bd5d068603f9 Kent Overstreet 2022-08-22  312  
33bd5d068603f9 Kent Overstreet 2022-08-22  313  	top = &g.g[g.nr - 1];
33bd5d068603f9 Kent Overstreet 2022-08-22  314  
fea153a84557c9 Kent Overstreet 2023-12-12  315  	struct btree_path *paths = rcu_dereference(top->trans->paths);
fea153a84557c9 Kent Overstreet 2023-12-12  316  	if (!paths)
fea153a84557c9 Kent Overstreet 2023-12-12  317  		goto up;
fea153a84557c9 Kent Overstreet 2023-12-12  318  
fea153a84557c9 Kent Overstreet 2023-12-12  319  	unsigned long *paths_allocated = trans_paths_allocated(paths);
fea153a84557c9 Kent Overstreet 2023-12-12  320  
fea153a84557c9 Kent Overstreet 2023-12-12  321  	trans_for_each_path_idx_from(paths_allocated, *trans_paths_nr(paths),
fea153a84557c9 Kent Overstreet 2023-12-12  322  				     path_idx, top->path_idx) {
fea153a84557c9 Kent Overstreet 2023-12-12  323  		struct btree_path *path = paths + path_idx;
33bd5d068603f9 Kent Overstreet 2022-08-22  324  		if (!path->nodes_locked)
33bd5d068603f9 Kent Overstreet 2022-08-22  325  			continue;
33bd5d068603f9 Kent Overstreet 2022-08-22  326  
f154c3eb429a34 Kent Overstreet 2023-05-27  327  		if (path_idx != top->path_idx) {
f154c3eb429a34 Kent Overstreet 2023-05-27  328  			top->path_idx		= path_idx;
33bd5d068603f9 Kent Overstreet 2022-08-22  329  			top->level		= 0;
33bd5d068603f9 Kent Overstreet 2022-08-22  330  			top->lock_start_time	= 0;
33bd5d068603f9 Kent Overstreet 2022-08-22  331  		}
33bd5d068603f9 Kent Overstreet 2022-08-22  332  
33bd5d068603f9 Kent Overstreet 2022-08-22  333  		for (;
33bd5d068603f9 Kent Overstreet 2022-08-22  334  		     top->level < BTREE_MAX_DEPTH;
33bd5d068603f9 Kent Overstreet 2022-08-22  335  		     top->level++, top->lock_start_time = 0) {
33bd5d068603f9 Kent Overstreet 2022-08-22  336  			int lock_held = btree_node_locked_type(path, top->level);
33bd5d068603f9 Kent Overstreet 2022-08-22  337  
33bd5d068603f9 Kent Overstreet 2022-08-22  338  			if (lock_held == BTREE_NODE_UNLOCKED)
33bd5d068603f9 Kent Overstreet 2022-08-22  339  				continue;
33bd5d068603f9 Kent Overstreet 2022-08-22  340  
33bd5d068603f9 Kent Overstreet 2022-08-22  341  			b = &READ_ONCE(path->l[top->level].b)->c;
33bd5d068603f9 Kent Overstreet 2022-08-22  342  
80df5b8cacceb2 Kent Overstreet 2023-01-20  343  			if (IS_ERR_OR_NULL(b)) {
80df5b8cacceb2 Kent Overstreet 2023-01-20  344  				/*
80df5b8cacceb2 Kent Overstreet 2023-01-20  345  				 * If we get here, it means we raced with the
80df5b8cacceb2 Kent Overstreet 2023-01-20  346  				 * other thread updating its btree_path
80df5b8cacceb2 Kent Overstreet 2023-01-20  347  				 * structures - which means it can't be blocked
80df5b8cacceb2 Kent Overstreet 2023-01-20  348  				 * waiting on a lock:
80df5b8cacceb2 Kent Overstreet 2023-01-20  349  				 */
80df5b8cacceb2 Kent Overstreet 2023-01-20  350  				if (!lock_graph_remove_non_waiters(&g)) {
80df5b8cacceb2 Kent Overstreet 2023-01-20  351  					/*
80df5b8cacceb2 Kent Overstreet 2023-01-20  352  					 * If lock_graph_remove_non_waiters()
80df5b8cacceb2 Kent Overstreet 2023-01-20  353  					 * didn't do anything, it must be
80df5b8cacceb2 Kent Overstreet 2023-01-20  354  					 * because we're being called by debugfs
80df5b8cacceb2 Kent Overstreet 2023-01-20  355  					 * checking for lock cycles, which
80df5b8cacceb2 Kent Overstreet 2023-01-20  356  					 * invokes us on btree_transactions that
80df5b8cacceb2 Kent Overstreet 2023-01-20  357  					 * aren't actually waiting on anything.
80df5b8cacceb2 Kent Overstreet 2023-01-20  358  					 * Just bail out:
80df5b8cacceb2 Kent Overstreet 2023-01-20  359  					 */
80df5b8cacceb2 Kent Overstreet 2023-01-20  360  					lock_graph_pop_all(&g);
80df5b8cacceb2 Kent Overstreet 2023-01-20  361  				}
80df5b8cacceb2 Kent Overstreet 2023-01-20  362  
33bd5d068603f9 Kent Overstreet 2022-08-22  363  				goto next;
33bd5d068603f9 Kent Overstreet 2022-08-22  364  			}
33bd5d068603f9 Kent Overstreet 2022-08-22  365  
33bd5d068603f9 Kent Overstreet 2022-08-22  366  			if (list_empty_careful(&b->lock.wait_list))
33bd5d068603f9 Kent Overstreet 2022-08-22  367  				continue;
33bd5d068603f9 Kent Overstreet 2022-08-22  368  
33bd5d068603f9 Kent Overstreet 2022-08-22  369  			raw_spin_lock(&b->lock.wait_lock);
33bd5d068603f9 Kent Overstreet 2022-08-22  370  			list_for_each_entry(trans, &b->lock.wait_list, locking_wait.list) {
33bd5d068603f9 Kent Overstreet 2022-08-22  371  				BUG_ON(b != trans->locking);
33bd5d068603f9 Kent Overstreet 2022-08-22  372  
33bd5d068603f9 Kent Overstreet 2022-08-22  373  				if (top->lock_start_time &&
33bd5d068603f9 Kent Overstreet 2022-08-22 @374  				    time_after_eq64(top->lock_start_time, trans->locking_wait.start_time))
33bd5d068603f9 Kent Overstreet 2022-08-22  375  					continue;
33bd5d068603f9 Kent Overstreet 2022-08-22  376  
33bd5d068603f9 Kent Overstreet 2022-08-22  377  				top->lock_start_time = trans->locking_wait.start_time;
33bd5d068603f9 Kent Overstreet 2022-08-22  378  
33bd5d068603f9 Kent Overstreet 2022-08-22  379  				/* Don't check for self deadlock: */
33bd5d068603f9 Kent Overstreet 2022-08-22  380  				if (trans == top->trans ||
33bd5d068603f9 Kent Overstreet 2022-08-22  381  				    !lock_type_conflicts(lock_held, trans->locking_wait.lock_want))
33bd5d068603f9 Kent Overstreet 2022-08-22  382  					continue;
33bd5d068603f9 Kent Overstreet 2022-08-22  383  
6547ebabdaac44 Kent Overstreet 2023-06-19  384  				closure_get(&trans->ref);
33bd5d068603f9 Kent Overstreet 2022-08-22  385  				raw_spin_unlock(&b->lock.wait_lock);
33bd5d068603f9 Kent Overstreet 2022-08-22  386  
6547ebabdaac44 Kent Overstreet 2023-06-19  387  				ret = lock_graph_descend(&g, trans, cycle);
33bd5d068603f9 Kent Overstreet 2022-08-22  388  				if (ret)
fea153a84557c9 Kent Overstreet 2023-12-12  389  					goto out;
33bd5d068603f9 Kent Overstreet 2022-08-22  390  				goto next;
33bd5d068603f9 Kent Overstreet 2022-08-22  391  
33bd5d068603f9 Kent Overstreet 2022-08-22  392  			}
33bd5d068603f9 Kent Overstreet 2022-08-22  393  			raw_spin_unlock(&b->lock.wait_lock);
33bd5d068603f9 Kent Overstreet 2022-08-22  394  		}
33bd5d068603f9 Kent Overstreet 2022-08-22  395  	}
fea153a84557c9 Kent Overstreet 2023-12-12  396  up:
40a44873a5ca98 Kent Overstreet 2022-10-02  397  	if (g.nr > 1 && cycle)
40a44873a5ca98 Kent Overstreet 2022-10-02  398  		print_chain(cycle, &g);
896f1b316f8e8f Kent Overstreet 2022-10-12  399  	lock_graph_up(&g);
33bd5d068603f9 Kent Overstreet 2022-08-22  400  	goto next;
fea153a84557c9 Kent Overstreet 2023-12-12  401  out:
fea153a84557c9 Kent Overstreet 2023-12-12  402  	if (cycle)
fea153a84557c9 Kent Overstreet 2023-12-12  403  		--cycle->atomic;
fea153a84557c9 Kent Overstreet 2023-12-12  404  	rcu_read_unlock();
fea153a84557c9 Kent Overstreet 2023-12-12  405  	return ret;
33bd5d068603f9 Kent Overstreet 2022-08-22  406  }
33bd5d068603f9 Kent Overstreet 2022-08-22  407  

:::::: The code at line 374 was first introduced by commit
:::::: 33bd5d068603f9e81e0b73dbe50e9b88b2e56d0d bcachefs: Deadlock cycle detector

:::::: TO: Kent Overstreet <kent.overstreet@gmail.com>
:::::: CC: Kent Overstreet <kent.overstreet@linux.dev>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2024-01-28 16:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202401290037.HTRCJohQ-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=keescook@chromium.org \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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