Skip to contentSkip to conversation

mld: convert ip6_sf_socklist to list macros

PATCH Superseded Taehee Yoo 5 participants 8 messages Feb 8, 2021 – Feb 9, 2021

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Taehee Yoo

author
#0 lore raw

PATCH 7/8 mld: convert ip6_sf_socklist to list macros

Currently, struct ip6_sf_socklist doesn't use list API so that code shape is a little bit different from others.
So it converts ip6_sf_socklist to use list API so it would improve readability.

---
 include/net/if_inet6.h  |  19 +-
 include/uapi/linux/in.h |   4 +-
 net/ipv6/mcast.c        | 387 +++++++++++++++++++++++++---------------
 3 files changed, 256 insertions(+), 154 deletions(-)
include/net/if_inet6.h +8 -11
index babf19c27b29..6885ab8ec2e9 100644
@@ -13,6 +13,7 @@
 #include <net/snmp.h>
 #include <linux/ipv6.h>
 #include <linux/refcount.h>
+#include <linux/types.h>
 
 /* inet6_dev.if_flags */
 
@@ -76,23 +77,19 @@ struct inet6_ifaddr {
 };
 
 struct ip6_sf_socklist {
-	unsigned int		sl_max;
-	unsigned int		sl_count;
-	struct in6_addr		sl_addr[];
+	struct list_head	list;
+	struct in6_addr		sl_addr;
+	struct rcu_head		rcu;
 };
 
-#define IP6_SFLSIZE(count)	(sizeof(struct ip6_sf_socklist) + \
-	(count) * sizeof(struct in6_addr))
-
-#define IP6_SFBLOCK	10	/* allocate this many at once */
-
 struct ipv6_mc_socklist {
 	struct in6_addr		addr;
 	int			ifindex;
-	unsigned int		sfmode;		/* MCAST_{INCLUDE,EXCLUDE} */
+	bool			sfmode;		/* MCAST_{INCLUDE,EXCLUDE} */
 	struct list_head	list;
+	struct list_head	sflist;
 	rwlock_t		sflock;
-	struct ip6_sf_socklist	*sflist;
+	atomic_t		sl_count;
 	struct rcu_head		rcu;
 };
 
@@ -101,7 +98,7 @@ struct ip6_sf_list {
 	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 */
+	bool			sf_oldin;	/* change state */
 	unsigned char		sf_crcount;	/* retrans. left to send */
 };
 
include/uapi/linux/in.h +2 -2
index 7d6687618d80..97024873afd0 100644
@@ -160,8 +160,8 @@ struct in_addr {
 #define IP_MULTICAST_ALL		49
 #define IP_UNICAST_IF			50
 
-#define MCAST_EXCLUDE	0
-#define MCAST_INCLUDE	1
+#define MCAST_EXCLUDE	false
+#define MCAST_INCLUDE	true
 
 /* These need to appear somewhere around here */
 #define IP_DEFAULT_MULTICAST_TTL        1
net/ipv6/mcast.c +246 -141

588 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
Quoted 26 lines · Taehee Yoo

Currently, struct ip6_sf_socklist doesn't use list API so that code shape is a little bit different from others.
So it converts ip6_sf_socklist to use list API so it would improve readability.

---
 include/net/if_inet6.h  |  19 +-
 include/uapi/linux/in.h |   4 +-
 net/ipv6/mcast.c        | 387 +++++++++++++++++++++++++---------------
 3 files changed, 256 insertions(+), 154 deletions(-)
include/net/if_inet6.h +1 -0
index babf19c27b29..6885ab8ec2e9 100644
@@ -13,6 +13,7 @@
 #include <net/snmp.h>
 #include <linux/ipv6.h>
 #include <linux/refcount.h>
+#include <linux/types.h>
 
 /* inet6_dev.if_flags */
 
@@ -76,23 +77,19 @@ struct inet6_ifaddr {
 };

include/net/if_inet6.h struct inet6_ifaddr { · line 84

Quoted 10 lines
include/net/if_inet6.h +3 -3
 
 struct ip6_sf_socklist {
-	unsigned int		sl_max;
-	unsigned int		sl_count;
-	struct in6_addr		sl_addr[];
+	struct list_head	list;
+	struct in6_addr		sl_addr;
+	struct rcu_head		rcu;
 };
 

I dunno about readability, but :

Your patches adds/delete more than 1000 lines, who is really going to review this ?

You replace dense arrays by lists, so the performance will likely be hurt, as cpu caches will be poorly used.

author
#2 lore raw
Quoted 1 line · Eric Dumazet

Hi Eric,
Thank you for the review!

Quoted 42 lines · Taehee Yoo
Quoted 26 lines

Currently, struct ip6_sf_socklist doesn't use list API so that code shape is a little bit different from others.
So it converts ip6_sf_socklist to use list API so it would improve readability.

---
 include/net/if_inet6.h  |  19 +-
 include/uapi/linux/in.h |   4 +-
 net/ipv6/mcast.c        | 387 +++++++++++++++++++++++++---------------
 3 files changed, 256 insertions(+), 154 deletions(-)
include/net/if_inet6.h +1 -0
index babf19c27b29..6885ab8ec2e9 100644
@@ -13,6 +13,7 @@
 #include <net/snmp.h>
 #include <linux/ipv6.h>
 #include <linux/refcount.h>
+#include <linux/types.h>
 
 /* inet6_dev.if_flags */
 
@@ -76,23 +77,19 @@ struct inet6_ifaddr {
 };

include/net/if_inet6.h struct inet6_ifaddr { · line 84

Quoted 10 lines
include/net/if_inet6.h +3 -3
 
 struct ip6_sf_socklist {
-     unsigned int            sl_max;
-     unsigned int            sl_count;
-     struct in6_addr         sl_addr[];
+     struct list_head        list;
+     struct in6_addr         sl_addr;
+     struct rcu_head         rcu;
 };
 

I dunno about readability, but :

Quoted 2 lines

Your patches adds/delete more than 1000 lines, who is really going to review this ?

Sorry for that, I think I was so hasty.

Quoted 3 lines

You replace dense arrays by lists, so the performance will likely be hurt, as cpu caches will be poorly used.

Thanks, I understand why the arrays have been using.
I will send a v2 patch, which contains only the necessary changes.

Thanks a lot,
Taehee Yoo

#3 lore raw
Quoted 2 lines · Taehee Yoo

Thanks, I understand why the arrays have been using.
I will send a v2 patch, which contains only the necessary changes.

please send v2 as a patch series and not 8 individual patches + cover letter.

Thanks,

author
#4 lore raw
Quoted 8 lines · David Ahern
Quoted 2 lines · Taehee Yoo

Thanks, I understand why the arrays have been using.
I will send a v2 patch, which contains only the necessary changes.

please send v2 as a patch series and not 8 individual patches + cover letter.

Okay, I will do that.

Thanks,
Taehee Yoo

Quoted 1 line

Thanks,

maintainer
#5 lore raw
In reply to David Ahern
Quoted 6 lines · On Mon, 8 Feb 2021 19:18:40 -0700 David Ahern wrote:
Quoted 2 lines · Taehee Yoo

Thanks, I understand why the arrays have been using.
I will send a v2 patch, which contains only the necessary changes.

please send v2 as a patch series and not 8 individual patches + cover letter.

And if you use git send email please use --thread and --no-chain-reply-to, so that the patches are all "in response" to the cover letter.

author
#6 lore raw
Quoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Mon, 8 Feb 2021 19:18:40 -0700 David Ahern wrote:
Quoted 2 lines · Taehee Yoo

Thanks, I understand why the arrays have been using.
I will send a v2 patch, which contains only the necessary changes.

Quoted 6 lines
Quoted 2 lines

please send v2 as a patch series and not 8 individual patches + cover letter.

And if you use git send email please use --thread and --no-chain-reply-to, so that the patches are all "in response" to the cover letter.

Thank you for the advice!
I will use those options :)

Thanks!
Taehee Yoo

#7 lore raw
In reply to Taehee Yoo
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/20210209-072339
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 6626a0266566c5aea16178c5e6cd7fc4db3f2f56
config: mips-allyesconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/0631c9a306555a1d9ee0aefbd7a0cdc892719dd6
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/20210209-072339 git checkout 0631c9a306555a1d9ee0aefbd7a0cdc892719dd6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips

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

All warnings (new ones prefixed by >>):

net/ipv6/mcast.c: In function 'ip6_mc_del_src':

>> net/ipv6/mcast.c:2150:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]
    2150 |  int i, err, rv;
         |      ^
   net/ipv6/mcast.c: In function 'ip6_mc_del_src_bulk':
   net/ipv6/mcast.c:2218:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]
    2218 |  int i, rv;
         |      ^

vim +/i +2150 net/ipv6/mcast.c

2143
2144 static int ip6_mc_del_src(struct inet6_dev *idev, const struct in6_addr *mca,
2145 int sfmode, const struct in6_addr *psfsrc, int delta)
2146 {
2147 struct ifmcaddr6 *mc;
2148 bool found = false;
2149 int changerec = 0;

> 2150		int i, err, rv;

2151
2152 if (!idev)
2153 return -ENODEV;
2154
2155 read_lock_bh(&idev->lock);
2156 list_for_each_entry(mc, &idev->mc_list, list) {
2157 if (ipv6_addr_equal(mca, &mc->mca_addr)) {
2158 found = true;
2159 break;
2160 }
2161 }
2162 if (!found) {
2163 /* MCA not found?? bug */
2164 read_unlock_bh(&idev->lock);
2165 return -ESRCH;
2166 }
2167 spin_lock_bh(&mc->mca_lock);
2168 sf_markstate(mc);
2169 if (!delta) {
2170 if (!mc->mca_sfcount[sfmode]) {
2171 spin_unlock_bh(&mc->mca_lock);
2172 read_unlock_bh(&idev->lock);
2173 return -EINVAL;
2174 }
2175 mc->mca_sfcount[sfmode]--;
2176 }
2177 err = 0;
2178 i = 0;
2179
2180 if (psfsrc) {
2181 rv = ip6_mc_del1_src(mc, sfmode, psfsrc);
2182
2183 changerec |= rv > 0;
2184 if (!err && rv < 0)
2185 err = rv;
2186 }
2187
2188 if (mc->mca_sfmode == MCAST_EXCLUDE &&
2189 mc->mca_sfcount[MCAST_EXCLUDE] == 0 &&
2190 mc->mca_sfcount[MCAST_INCLUDE]) {
2191 struct ip6_sf_list *psf;
2192
2193 /* filter mode change */
2194 mc->mca_sfmode = MCAST_INCLUDE;
2195 mc->mca_crcount = idev->mc_qrv;
2196 idev->mc_ifc_count = mc->mca_crcount;
2197 list_for_each_entry(psf, &mc->mca_source_list, list)
2198 psf->sf_crcount = 0;
2199 mld_ifc_event(mc->idev);
2200 } else if (sf_setstate(mc) || changerec) {
2201 mld_ifc_event(mc->idev);
2202 }
2203 spin_unlock_bh(&mc->mca_lock);
2204 read_unlock_bh(&idev->lock);
2205 return err;
2206 }
2207

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