Message ID | 1392169484-8256-3-git-send-email-wangweidong1@huawei.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On Wed, Feb 12, 2014 at 09:44:44AM +0800, Wang Weidong wrote: > Here, when the net is init_net, we needn't to kmemdup the ctl_table > again. So add a check for net. Also we can save some memory. > > Signed-off-by: Wang Weidong <wangweidong1@huawei.com> > --- > net/sctp/sysctl.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c > index d354de5..35c8923 100644 > --- a/net/sctp/sysctl.c > +++ b/net/sctp/sysctl.c > @@ -402,15 +402,18 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, > > int sctp_sysctl_net_register(struct net *net) > { > - struct ctl_table *table; > - int i; > + struct ctl_table *table = sctp_net_table; > + > + if (!net_eq(net, &init_net)) { > + int i; > > - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); > - if (!table) > - return -ENOMEM; > + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); > + if (!table) > + return -ENOMEM; > > - for (i = 0; table[i].data; i++) > - table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; > + for (i = 0; table[i].data; i++) > + table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; > + } > In the first version of this patch you complained about a lockdep issue. Did you figure out what that was, and if it related to these changes? Neil -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2014/2/12 19:53, Neil Horman wrote: > On Wed, Feb 12, 2014 at 09:44:44AM +0800, Wang Weidong wrote: >> Here, when the net is init_net, we needn't to kmemdup the ctl_table >> again. So add a check for net. Also we can save some memory. >> >> Signed-off-by: Wang Weidong <wangweidong1@huawei.com> >> --- >> net/sctp/sysctl.c | 17 ++++++++++------- >> 1 file changed, 10 insertions(+), 7 deletions(-) >> >> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c >> index d354de5..35c8923 100644 >> --- a/net/sctp/sysctl.c >> +++ b/net/sctp/sysctl.c >> @@ -402,15 +402,18 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, >> >> int sctp_sysctl_net_register(struct net *net) >> { >> - struct ctl_table *table; >> - int i; >> + struct ctl_table *table = sctp_net_table; >> + >> + if (!net_eq(net, &init_net)) { >> + int i; >> >> - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); >> - if (!table) >> - return -ENOMEM; >> + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); >> + if (!table) >> + return -ENOMEM; >> >> - for (i = 0; table[i].data; i++) >> - table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; >> + for (i = 0; table[i].data; i++) >> + table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; >> + } >> > In the first version of this patch you complained about a lockdep issue. Did > you figure out what that was, and if it related to these changes? > > Neil > > Hi Neil, The lockdep issue doesn't relate to these changes. I should send it by the another email. Sorry for confusing you. Regards Wang > . > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Feb 13, 2014 at 09:19:25AM +0800, Wang Weidong wrote: > On 2014/2/12 19:53, Neil Horman wrote: > > On Wed, Feb 12, 2014 at 09:44:44AM +0800, Wang Weidong wrote: > >> Here, when the net is init_net, we needn't to kmemdup the ctl_table > >> again. So add a check for net. Also we can save some memory. > >> > >> Signed-off-by: Wang Weidong <wangweidong1@huawei.com> > >> --- > >> net/sctp/sysctl.c | 17 ++++++++++------- > >> 1 file changed, 10 insertions(+), 7 deletions(-) > >> > >> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c > >> index d354de5..35c8923 100644 > >> --- a/net/sctp/sysctl.c > >> +++ b/net/sctp/sysctl.c > >> @@ -402,15 +402,18 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, > >> > >> int sctp_sysctl_net_register(struct net *net) > >> { > >> - struct ctl_table *table; > >> - int i; > >> + struct ctl_table *table = sctp_net_table; > >> + > >> + if (!net_eq(net, &init_net)) { > >> + int i; > >> > >> - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); > >> - if (!table) > >> - return -ENOMEM; > >> + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); > >> + if (!table) > >> + return -ENOMEM; > >> > >> - for (i = 0; table[i].data; i++) > >> - table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; > >> + for (i = 0; table[i].data; i++) > >> + table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; > >> + } > >> > > In the first version of this patch you complained about a lockdep issue. Did > > you figure out what that was, and if it related to these changes? > > > > Neil > > > > > Hi Neil, > > The lockdep issue doesn't relate to these changes. I should send it > by the another email. Sorry for confusing you. > > Regards > Wang > Then you probably don't need to mention it in the same note that you're proposing changes. Acked-by: Neil Horman <nhorman@tuxdriver.com> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2014/2/13 20:44, Neil Horman wrote: > On Thu, Feb 13, 2014 at 09:19:25AM +0800, Wang Weidong wrote: >> On 2014/2/12 19:53, Neil Horman wrote: >>> On Wed, Feb 12, 2014 at 09:44:44AM +0800, Wang Weidong wrote: >>>> Here, when the net is init_net, we needn't to kmemdup the ctl_table >>>> again. So add a check for net. Also we can save some memory. >>>> >>>> Signed-off-by: Wang Weidong <wangweidong1@huawei.com> >>>> --- >>>> net/sctp/sysctl.c | 17 ++++++++++------- >>>> 1 file changed, 10 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c >>>> index d354de5..35c8923 100644 >>>> --- a/net/sctp/sysctl.c >>>> +++ b/net/sctp/sysctl.c >>>> @@ -402,15 +402,18 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, >>>> >>>> int sctp_sysctl_net_register(struct net *net) >>>> { >>>> - struct ctl_table *table; >>>> - int i; >>>> + struct ctl_table *table = sctp_net_table; >>>> + >>>> + if (!net_eq(net, &init_net)) { >>>> + int i; >>>> >>>> - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); >>>> - if (!table) >>>> - return -ENOMEM; >>>> + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); >>>> + if (!table) >>>> + return -ENOMEM; >>>> >>>> - for (i = 0; table[i].data; i++) >>>> - table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; >>>> + for (i = 0; table[i].data; i++) >>>> + table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; >>>> + } >>>> >>> In the first version of this patch you complained about a lockdep issue. Did >>> you figure out what that was, and if it related to these changes? >>> >>> Neil >>> >>> >> Hi Neil, >> >> The lockdep issue doesn't relate to these changes. I should send it >> by the another email. Sorry for confusing you. >> >> Regards >> Wang >> > Then you probably don't need to mention it in the same note that you're > proposing changes. > Ok. Got it! Thanks Wang > Acked-by: Neil Horman <nhorman@tuxdriver.com> > > > . > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index d354de5..35c8923 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -402,15 +402,18 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, int sctp_sysctl_net_register(struct net *net) { - struct ctl_table *table; - int i; + struct ctl_table *table = sctp_net_table; + + if (!net_eq(net, &init_net)) { + int i; - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); - if (!table) - return -ENOMEM; + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); + if (!table) + return -ENOMEM; - for (i = 0; table[i].data; i++) - table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; + for (i = 0; table[i].data; i++) + table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; + } net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); return 0;
Here, when the net is init_net, we needn't to kmemdup the ctl_table again. So add a check for net. Also we can save some memory. Signed-off-by: Wang Weidong <wangweidong1@huawei.com> --- net/sctp/sysctl.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)