Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mld: get rid of inet6_dev->mc_lock

The purpose of mc_lock is to protect inet6_dev->mc_tomb.
But mc_tomb is already protected by RTNL and all functions,
which manipulate mc_tomb are called under RTNL.
So, mc_lock is not needed.
Furthermore, it is spinlock so the critical section is atomic.
In order to reduce atomic context, it should be removed.

Suggested-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Taehee Yoo and committed by
David S. Miller
cf2ce339 2d9a93b4

-10
-1
include/net/if_inet6.h
··· 167 167 168 168 struct ifmcaddr6 *mc_list; 169 169 struct ifmcaddr6 *mc_tomb; 170 - spinlock_t mc_lock; 171 170 172 171 unsigned char mc_qrv; /* Query Robustness Variable */ 173 172 unsigned char mc_gq_running;
-9
net/ipv6/mcast.c
··· 752 752 } 753 753 spin_unlock_bh(&im->mca_lock); 754 754 755 - spin_lock_bh(&idev->mc_lock); 756 755 pmc->next = idev->mc_tomb; 757 756 idev->mc_tomb = pmc; 758 - spin_unlock_bh(&idev->mc_lock); 759 757 } 760 758 761 759 static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im) ··· 762 764 struct ip6_sf_list *psf; 763 765 struct in6_addr *pmca = &im->mca_addr; 764 766 765 - spin_lock_bh(&idev->mc_lock); 766 767 pmc_prev = NULL; 767 768 for (pmc = idev->mc_tomb; pmc; pmc = pmc->next) { 768 769 if (ipv6_addr_equal(&pmc->mca_addr, pmca)) ··· 774 777 else 775 778 idev->mc_tomb = pmc->next; 776 779 } 777 - spin_unlock_bh(&idev->mc_lock); 778 780 779 781 spin_lock_bh(&im->mca_lock); 780 782 if (pmc) { ··· 797 801 { 798 802 struct ifmcaddr6 *pmc, *nextpmc; 799 803 800 - spin_lock_bh(&idev->mc_lock); 801 804 pmc = idev->mc_tomb; 802 805 idev->mc_tomb = NULL; 803 - spin_unlock_bh(&idev->mc_lock); 804 806 805 807 for (; pmc; pmc = nextpmc) { 806 808 nextpmc = pmc->next; ··· 1901 1907 int type, dtype; 1902 1908 1903 1909 read_lock_bh(&idev->lock); 1904 - spin_lock(&idev->mc_lock); 1905 1910 1906 1911 /* deleted MCA's */ 1907 1912 pmc_prev = NULL; ··· 1934 1941 } else 1935 1942 pmc_prev = pmc; 1936 1943 } 1937 - spin_unlock(&idev->mc_lock); 1938 1944 1939 1945 /* change recs */ 1940 1946 for (pmc = idev->mc_list; pmc; pmc = pmc->next) { ··· 2574 2582 void ipv6_mc_init_dev(struct inet6_dev *idev) 2575 2583 { 2576 2584 write_lock_bh(&idev->lock); 2577 - spin_lock_init(&idev->mc_lock); 2578 2585 idev->mc_gq_running = 0; 2579 2586 INIT_DELAYED_WORK(&idev->mc_gq_work, mld_gq_work); 2580 2587 idev->mc_tomb = NULL;