Hi Florian, I love your patch! Perhaps something to improve:
[auto build test WARNING on ipsec-next/master] url: https://github.com/0day-ci/linux/commits/Florian-Westphal/xfrm-remove-xfrm_mode-indirections/20190329-041949 base: https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' sparse warnings: (new ones prefixed by >>) net/xfrm/xfrm_state.c:928:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:928:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:928:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:928:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:928:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:945:9: sparse: cast removes address space of expression net/xfrm/xfrm_state.c:1003:77: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1003:77: expected struct hlist_head *h net/xfrm/xfrm_state.c:1003:77: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1005:77: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1005:77: expected struct hlist_head *h net/xfrm/xfrm_state.c:1005:77: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1008:85: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1008:85: expected struct hlist_head *h net/xfrm/xfrm_state.c:1008:85: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1024:42: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct xfrm_state [noderef] <asn:4>*x @@ got xfrm_state [noderef] <asn:4>*x @@ net/xfrm/xfrm_state.c:1024:42: expected struct xfrm_state [noderef] <asn:4>*x net/xfrm/xfrm_state.c:1024:42: got struct xfrm_state *[assigned] x net/xfrm/xfrm_state.c:52:39: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct refcount_struct [usertype] *r @@ got structstruct refcount_struct [usertype] *r @@ net/xfrm/xfrm_state.c:52:39: expected struct refcount_struct [usertype] *r net/xfrm/xfrm_state.c:52:39: got struct refcount_struct [noderef] <asn:4>*<noident> net/xfrm/xfrm_state.c:1111:61: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1111:61: expected struct hlist_head *h net/xfrm/xfrm_state.c:1111:61: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1114:61: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1114:61: expected struct hlist_head *h net/xfrm/xfrm_state.c:1114:61: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1120:69: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1120:69: expected struct hlist_head *h net/xfrm/xfrm_state.c:1120:69: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1232:69: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1232:69: expected struct hlist_head *h net/xfrm/xfrm_state.c:1232:69: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1234:69: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1234:69: expected struct hlist_head *h net/xfrm/xfrm_state.c:1234:69: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:1789:69: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct hlist_head *h @@ got struct hlist_headstruct hlist_head *h @@ net/xfrm/xfrm_state.c:1789:69: expected struct hlist_head *h net/xfrm/xfrm_state.c:1789:69: got struct hlist_head [noderef] <asn:4>* net/xfrm/xfrm_state.c:2314:31: sparse: incorrect type in assignment (different address spaces) @@ expected struct hlist_head [noderef] <asn:4>*state_bydst @@ got [noderef] <asn:4>*state_bydst @@ net/xfrm/xfrm_state.c:2314:31: expected struct hlist_head [noderef] <asn:4>*state_bydst net/xfrm/xfrm_state.c:2314:31: got struct hlist_head * net/xfrm/xfrm_state.c:2317:31: sparse: incorrect type in assignment (different address spaces) @@ expected struct hlist_head [noderef] <asn:4>*state_bysrc @@ got [noderef] <asn:4>*state_bysrc @@ net/xfrm/xfrm_state.c:2317:31: expected struct hlist_head [noderef] <asn:4>*state_bysrc net/xfrm/xfrm_state.c:2317:31: got struct hlist_head * net/xfrm/xfrm_state.c:2320:31: sparse: incorrect type in assignment (different address spaces) @@ expected struct hlist_head [noderef] <asn:4>*state_byspi @@ got [noderef] <asn:4>*state_byspi @@ net/xfrm/xfrm_state.c:2320:31: expected struct hlist_head [noderef] <asn:4>*state_byspi net/xfrm/xfrm_state.c:2320:31: got struct hlist_head * net/xfrm/xfrm_state.c:2331:33: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head *n @@ got struct hlist_headstruct hlist_head *n @@ net/xfrm/xfrm_state.c:2331:33: expected struct hlist_head *n net/xfrm/xfrm_state.c:2331:33: got struct hlist_head [noderef] <asn:4>*state_bysrc net/xfrm/xfrm_state.c:2333:33: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head *n @@ got struct hlist_headstruct hlist_head *n @@ net/xfrm/xfrm_state.c:2333:33: expected struct hlist_head *n net/xfrm/xfrm_state.c:2333:33: got struct hlist_head [noderef] <asn:4>*state_bydst net/xfrm/xfrm_state.c:2349:9: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head const *h @@ got struct hlisstruct hlist_head const *h @@ net/xfrm/xfrm_state.c:2349:9: expected struct hlist_head const *h net/xfrm/xfrm_state.c:2349:9: got struct hlist_head [noderef] <asn:4>*state_byspi net/xfrm/xfrm_state.c:2350:33: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head *n @@ got struct hlist_headstruct hlist_head *n @@ net/xfrm/xfrm_state.c:2350:33: expected struct hlist_head *n net/xfrm/xfrm_state.c:2350:33: got struct hlist_head [noderef] <asn:4>*state_byspi net/xfrm/xfrm_state.c:2351:9: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head const *h @@ got struct hlisstruct hlist_head const *h @@ net/xfrm/xfrm_state.c:2351:9: expected struct hlist_head const *h net/xfrm/xfrm_state.c:2351:9: got struct hlist_head [noderef] <asn:4>*state_bysrc net/xfrm/xfrm_state.c:2352:33: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head *n @@ got struct hlist_headstruct hlist_head *n @@ net/xfrm/xfrm_state.c:2352:33: expected struct hlist_head *n net/xfrm/xfrm_state.c:2352:33: got struct hlist_head [noderef] <asn:4>*state_bysrc net/xfrm/xfrm_state.c:2353:9: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head const *h @@ got struct hlisstruct hlist_head const *h @@ net/xfrm/xfrm_state.c:2353:9: expected struct hlist_head const *h net/xfrm/xfrm_state.c:2353:9: got struct hlist_head [noderef] <asn:4>*state_bydst net/xfrm/xfrm_state.c:2354:33: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct hlist_head *n @@ got struct hlist_headstruct hlist_head *n @@ net/xfrm/xfrm_state.c:2354:33: expected struct hlist_head *n net/xfrm/xfrm_state.c:2354:33: got struct hlist_head [noderef] <asn:4>*state_bydst include/linux/rcupdate.h:647:9: sparse: context imbalance in 'xfrm_register_type' - unexpected unlock include/linux/rcupdate.h:647:9: sparse: context imbalance in 'xfrm_unregister_type' - unexpected unlock include/linux/rcupdate.h:647:9: sparse: context imbalance in 'xfrm_get_type' - unexpected unlock include/linux/rcupdate.h:647:9: sparse: context imbalance in 'xfrm_register_type_offload' - unexpected unlock include/linux/rcupdate.h:647:9: sparse: context imbalance in 'xfrm_unregister_type_offload' - unexpected unlock include/linux/rcupdate.h:647:9: sparse: context imbalance in 'xfrm_get_type_offload' - unexpected unlock net/xfrm/xfrm_state.c:629:17: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:690:17: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:650:17: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:734:17: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:1056:9: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:1144:9: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:1179:9: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:1407:17: sparse: dereference of noderef expression net/xfrm/xfrm_state.c:1424:17: sparse: dereference of noderef expression >> include/linux/rcupdate.h:647:9: sparse: context imbalance in >> 'xfrm_tmpl_sort' - unexpected unlock >> include/linux/rcupdate.h:647:9: sparse: context imbalance in >> 'xfrm_state_sort' - unexpected unlock net/xfrm/xfrm_state.c:1687:17: sparse: too many warnings vim +/xfrm_tmpl_sort +647 include/linux/rcupdate.h ^1da177e4 Linus Torvalds 2005-04-16 599 ^1da177e4 Linus Torvalds 2005-04-16 600 /* ^1da177e4 Linus Torvalds 2005-04-16 601 * So where is rcu_write_lock()? It does not exist, as there is no ^1da177e4 Linus Torvalds 2005-04-16 602 * way for writers to lock out RCU readers. This is a feature, not ^1da177e4 Linus Torvalds 2005-04-16 603 * a bug -- this property is what provides RCU's performance benefits. ^1da177e4 Linus Torvalds 2005-04-16 604 * Of course, writers must coordinate with each other. The normal ^1da177e4 Linus Torvalds 2005-04-16 605 * spinlock primitives work well for this, but any other technique may be ^1da177e4 Linus Torvalds 2005-04-16 606 * used as well. RCU does not care how the writers keep out of each ^1da177e4 Linus Torvalds 2005-04-16 607 * others' way, as long as they do so. ^1da177e4 Linus Torvalds 2005-04-16 608 */ 3d76c0829 Paul E. McKenney 2009-09-28 609 3d76c0829 Paul E. McKenney 2009-09-28 610 /** ca5ecddfa Paul E. McKenney 2010-04-28 611 * rcu_read_unlock() - marks the end of an RCU read-side critical section. 3d76c0829 Paul E. McKenney 2009-09-28 612 * f27bc4873 Paul E. McKenney 2014-05-04 613 * In most situations, rcu_read_unlock() is immune from deadlock. f27bc4873 Paul E. McKenney 2014-05-04 614 * However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock() f27bc4873 Paul E. McKenney 2014-05-04 615 * is responsible for deboosting, which it does via rt_mutex_unlock(). f27bc4873 Paul E. McKenney 2014-05-04 616 * Unfortunately, this function acquires the scheduler's runqueue and f27bc4873 Paul E. McKenney 2014-05-04 617 * priority-inheritance spinlocks. This means that deadlock could result f27bc4873 Paul E. McKenney 2014-05-04 618 * if the caller of rcu_read_unlock() already holds one of these locks or ec84b27f9 Anna-Maria Gleixner 2018-05-25 619 * any lock that is ever acquired while holding them. f27bc4873 Paul E. McKenney 2014-05-04 620 * f27bc4873 Paul E. McKenney 2014-05-04 621 * That said, RCU readers are never priority boosted unless they were f27bc4873 Paul E. McKenney 2014-05-04 622 * preempted. Therefore, one way to avoid deadlock is to make sure f27bc4873 Paul E. McKenney 2014-05-04 623 * that preemption never happens within any RCU read-side critical f27bc4873 Paul E. McKenney 2014-05-04 624 * section whose outermost rcu_read_unlock() is called with one of f27bc4873 Paul E. McKenney 2014-05-04 625 * rt_mutex_unlock()'s locks held. Such preemption can be avoided in f27bc4873 Paul E. McKenney 2014-05-04 626 * a number of ways, for example, by invoking preempt_disable() before f27bc4873 Paul E. McKenney 2014-05-04 627 * critical section's outermost rcu_read_lock(). f27bc4873 Paul E. McKenney 2014-05-04 628 * f27bc4873 Paul E. McKenney 2014-05-04 629 * Given that the set of locks acquired by rt_mutex_unlock() might change f27bc4873 Paul E. McKenney 2014-05-04 630 * at any time, a somewhat more future-proofed approach is to make sure f27bc4873 Paul E. McKenney 2014-05-04 631 * that that preemption never happens within any RCU read-side critical f27bc4873 Paul E. McKenney 2014-05-04 632 * section whose outermost rcu_read_unlock() is called with irqs disabled. f27bc4873 Paul E. McKenney 2014-05-04 633 * This approach relies on the fact that rt_mutex_unlock() currently only f27bc4873 Paul E. McKenney 2014-05-04 634 * acquires irq-disabled locks. f27bc4873 Paul E. McKenney 2014-05-04 635 * f27bc4873 Paul E. McKenney 2014-05-04 636 * The second of these two approaches is best in most situations, f27bc4873 Paul E. McKenney 2014-05-04 637 * however, the first approach can also be useful, at least to those f27bc4873 Paul E. McKenney 2014-05-04 638 * developers willing to keep abreast of the set of locks acquired by f27bc4873 Paul E. McKenney 2014-05-04 639 * rt_mutex_unlock(). f27bc4873 Paul E. McKenney 2014-05-04 640 * 3d76c0829 Paul E. McKenney 2009-09-28 641 * See rcu_read_lock() for more information. 3d76c0829 Paul E. McKenney 2009-09-28 642 */ bc33f24bd Paul E. McKenney 2009-08-22 643 static inline void rcu_read_unlock(void) bc33f24bd Paul E. McKenney 2009-08-22 644 { f78f5b90c Paul E. McKenney 2015-06-18 645 RCU_LOCKDEP_WARN(!rcu_is_watching(), bde23c689 Heiko Carstens 2012-02-01 646 "rcu_read_unlock() used illegally while idle"); bc33f24bd Paul E. McKenney 2009-08-22 @647 __release(RCU); bc33f24bd Paul E. McKenney 2009-08-22 648 __rcu_read_unlock(); d24209bb6 Paul E. McKenney 2015-01-21 649 rcu_lock_release(&rcu_lock_map); /* Keep acq info for rls diags. */ bc33f24bd Paul E. McKenney 2009-08-22 650 } ^1da177e4 Linus Torvalds 2005-04-16 651 :::::: The code at line 647 was first introduced by commit :::::: bc33f24bdca8b6e97376e3a182ab69e6cdefa989 rcu: Consolidate sparse and lockdep declarations in include/linux/rcupdate.h :::::: TO: Paul E. McKenney <paul...@linux.vnet.ibm.com> :::::: CC: Ingo Molnar <mi...@elte.hu> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation