All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Wang Weidong <wangweidong1@huawei.com>,
	nhorman@tuxdriver.com, davem@davemloft.net, vyasevich@gmail.com
Cc: dborkman@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register
Date: Tue, 11 Feb 2014 19:47:20 +0300	[thread overview]
Message-ID: <52FA5418.6090007@cogentembedded.com> (raw)
In-Reply-To: <1392083346-9420-3-git-send-email-wangweidong1@huawei.com>

Hello.

On 02/11/2014 04:49 AM, 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 | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)

> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
> index 2ddb401..b65396b 100644
> --- a/net/sctp/sysctl.c
> +++ b/net/sctp/sysctl.c
> @@ -403,15 +403,17 @@ 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;
>
> -	table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
> -	if (!table)
> -		return -ENOMEM;
> +	if (!net_eq(net, &init_net)) {
> +		int i;

    Empty line after declaration wouldn't hurt, just like above.

> +		table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
> +		if (!table)
> +			return -ENOMEM;

WBR, Sergei

  reply	other threads:[~2014-02-11 15:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11  1:49 [PATCH v2 0/2] sctp: fix a problem with net_namespace Wang Weidong
2014-02-11  1:49 ` [PATCH v2 1/2] sctp: fix a missed .data initialization Wang Weidong
2014-02-11  1:49 ` [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
2014-02-11 16:47   ` Sergei Shtylyov [this message]
2014-02-12  1:21     ` Wang Weidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52FA5418.6090007@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=vyasevich@gmail.com \
    --cc=wangweidong1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.