Skip to contentSkip to conversation

mld: convert ip6_sf_list to RCU

PATCH Superseded Taehee Yoo 2 participants 2 messages Feb 13, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Taehee Yoo

author
#0 lore raw

PATCH v2 6/7 mld: convert ip6_sf_list to RCU

The ip6_sf_list has been protected by mca_lock(spin_lock) so that the critical section is atomic context. In order to switch this context, changing locking is needed. The ip6_sf_list actually already protected by RTNL So if it's converted to use RCU, its control path context can be switched to sleepable.
But It doesn't remove mca_lock yet because ifmcaddr6 isn't converted to RCU yet. So, It's not fully converted to the sleepable context.

---
v1 -> v2:
- Separated from previous big one patch.

 include/net/if_inet6.h |   5 +-
 net/ipv6/mcast.c       | 150 +++++++++++++++++++++++++----------------
 2 files changed, 95 insertions(+), 60 deletions(-)
include/net/if_inet6.h +3 -2
index d8507bef0a0c..b26fecb669e3 100644
@@ -97,12 +97,13 @@ struct ipv6_mc_socklist {
 };
 
 struct ip6_sf_list {
-	struct ip6_sf_list	*sf_next;
+	struct ip6_sf_list	__rcu *sf_next;
 	struct in6_addr		sf_addr;
 	unsigned long		sf_count[2];	/* include/exclude counts */
 	unsigned char		sf_gsresp;	/* include in g & s response? */
 	unsigned char		sf_oldin;	/* change state */
 	unsigned char		sf_crcount;	/* retrans. left to send */
+	struct rcu_head		rcu;
 };
 
 #define MAF_TIMER_RUNNING	0x01
@@ -113,7 +114,7 @@ struct ifmcaddr6 {
 	struct in6_addr		mca_addr;
 	struct inet6_dev	*idev;
 	struct ifmcaddr6	*next;
-	struct ip6_sf_list	*mca_sources;
+	struct ip6_sf_list	__rcu *mca_sources;
 	struct ip6_sf_list	*mca_tomb;
 	unsigned int		mca_sfmode;
 	unsigned char		mca_crcount;
net/ipv6/mcast.c +92 -58

341 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Taehee,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Taehee-Yoo/mld-change-context-from-atomic-to-sleepable/20210214-015930
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 3c5a2fd042d0bfac71a2dfb99515723d318df47b
config: x86_64-randconfig-s022-20210214 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-215-g0fb77bb6-dirty
        # https://github.com/0day-ci/linux/commit/50d689e601cc17c3b2bf668b2e5be766e9dbc7b3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Taehee-Yoo/mld-change-context-from-atomic-to-sleepable/20210214-015930
        git checkout 50d689e601cc17c3b2bf668b2e5be766e9dbc7b3
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

"sparse warnings: (new ones prefixed by >>)"
net/ipv6/mcast.c:754:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
net/ipv6/mcast.c:754:9: sparse: struct ifmcaddr6 [noderef] __rcu *
net/ipv6/mcast.c:754:9: sparse: struct ifmcaddr6 *

>> net/ipv6/mcast.c:783:35: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected struct ip6_sf_list [noderef] __rcu *__tmp @@     got struct ip6_sf_list * @@
>> net/ipv6/mcast.c:783:33: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list *sources @@     got struct ip6_sf_list [noderef] __rcu *__tmp @@
>> net/ipv6/mcast.c:2322:43: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list *[assigned] dpsf @@     got struct ip6_sf_list [noderef] __rcu *sf_next @@
>> net/ipv6/mcast.c:2332:63: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list *mca_tomb @@     got struct ip6_sf_list [noderef] __rcu *sf_next @@
   net/ipv6/mcast.c:2344:63: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list *[assigned] dpsf @@     got struct ip6_sf_list [noderef] __rcu *sf_next @@
>> net/ipv6/mcast.c:2353:47: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list [noderef] __rcu *sf_next @@     got struct ip6_sf_list *mca_tomb @@
>> net/ipv6/mcast.c:2432:25: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list *nextpsf @@     got struct ip6_sf_list [noderef] __rcu *sf_next @@
   net/ipv6/mcast.c:440:17: sparse: sparse: incompatible types in comparison expression (different address spaces):
   net/ipv6/mcast.c:440:17: sparse:    struct ip6_sf_socklist [noderef] __rcu *
   net/ipv6/mcast.c:440:17: sparse:    struct ip6_sf_socklist *
   net/ipv6/mcast.c: note: in included file:
   include/net/mld.h:32:43: sparse: sparse: array of flexible structures
>> net/ipv6/mcast.c:1791:27: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list [noderef] __rcu * @@     got struct ip6_sf_list * @@
   net/ipv6/mcast.c:1841:51: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ip6_sf_list [noderef] __rcu * @@     got struct ip6_sf_list * @@
   net/ipv6/mcast.c:1911:20: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> net/ipv6/mcast.c:1911:20: sparse:    struct ip6_sf_list [noderef] __rcu *
>> net/ipv6/mcast.c:1911:20: sparse:    struct ip6_sf_list *
>> net/ipv6/mcast.c:1952:50: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct ip6_sf_list **ppsf @@     got struct ip6_sf_list [noderef] __rcu ** @@

net/ipv6/mcast.c:1952:50: sparse: expected struct ip6_sf_list **ppsf
net/ipv6/mcast.c:1952:50: sparse: got struct ip6_sf_list [noderef] __rcu **
net/ipv6/mcast.c:267:25: sparse: sparse: context imbalance in 'ip6_mc_find_dev_rcu' - different lock contexts for basic block net/ipv6/mcast.c:457:9: sparse: sparse: context imbalance in 'ip6_mc_source' - unexpected unlock net/ipv6/mcast.c:546:9: sparse: sparse: context imbalance in 'ip6_mc_msfilter' - unexpected unlock net/ipv6/mcast.c:593:21: sparse: sparse: context imbalance in 'ip6_mc_msfget' - unexpected unlock net/ipv6/mcast.c:2758:25: sparse: sparse: context imbalance in 'igmp6_mc_get_next' - unexpected unlock net/ipv6/mcast.c:2780:9: sparse: sparse: context imbalance in 'igmp6_mc_get_idx' - wrong count at exit net/ipv6/mcast.c:2807:9: sparse: sparse: context imbalance in 'igmp6_mc_seq_stop' - unexpected unlock net/ipv6/mcast.c:2879:31: sparse: sparse: context imbalance in 'igmp6_mcf_get_next' - unexpected unlock net/ipv6/mcast.c:2911:9: sparse: sparse: context imbalance in 'igmp6_mcf_get_idx' - wrong count at exit net/ipv6/mcast.c:2928:9: sparse: sparse: context imbalance in 'igmp6_mcf_seq_next' - wrong count at exit net/ipv6/mcast.c:2941:17: sparse: sparse: context imbalance in 'igmp6_mcf_seq_stop' - unexpected unlock

vim +783 net/ipv6/mcast.c

757
758 static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
759 {
760 struct in6_addr *pmca = &im->mca_addr;
761 struct ip6_sf_list *psf, *sources;
762 struct ifmcaddr6 *pmc, *pmc_prev;
763
764 pmc_prev = NULL;
765 for (pmc = idev->mc_tomb; pmc; pmc = pmc->next) {
766 if (ipv6_addr_equal(&pmc->mca_addr, pmca))
767 break;
768 pmc_prev = pmc;
769 }
770 if (pmc) {
771 if (pmc_prev)
772 pmc_prev->next = pmc->next;
773 else
774 idev->mc_tomb = pmc->next;
775 }
776
777 spin_lock_bh(&im->mca_lock);
778 if (pmc) {
779 im->idev = pmc->idev;
780 if (im->mca_sfmode == MCAST_INCLUDE) {
781 swap(im->mca_tomb, pmc->mca_tomb);
782

 > 783				sources = rcu_replace_pointer(im->mca_sources,

784 pmc->mca_sources,
785 lockdep_rtnl_is_held());
786 rcu_assign_pointer(pmc->mca_sources, sources);
787 for_each_psf_rtnl(im, psf)
788 psf->sf_crcount = idev->mc_qrv;
789 } else {
790 im->mca_crcount = idev->mc_qrv;
791 }
792 in6_dev_put(pmc->idev);
793 ip6_mc_clear_src(pmc);
794 kfree(pmc);
795 }
796 spin_unlock_bh(&im->mca_lock);
797 }
798

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org