All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, romieu@fr.zoreil.com, 3chas3@gmail.com,
	andreyknvl@google.com
Subject: Re: [Patch net] atm: remove an unnecessary loop
Date: Thu, 12 Jan 2017 09:43:25 +0100	[thread overview]
Message-ID: <20170112084325.GC2264@dhcp22.suse.cz> (raw)
In-Reply-To: <1484197322-958-1-git-send-email-xiyou.wangcong@gmail.com>

On Wed 11-01-17 21:02:01, Cong Wang wrote:
> alloc_tx() is already inside a wait loop for a successful skb
> allocation, this loop inside alloc_tx() is quite unnecessary
> and actually problematic.

I am not familiar with this code at all but vcc_sendmsg seems to be one
of those cases where open coding __GFP_NOFAIL semantic makes sense as
there is an allocation fallback strategy implemented.

> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

I cannot give my reviewed-by because I am not familiar with the code but
this looks like an improvement to me.

> ---
>  net/atm/common.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/net/atm/common.c b/net/atm/common.c
> index a3ca922..7ec3bbc 100644
> --- a/net/atm/common.c
> +++ b/net/atm/common.c
> @@ -72,10 +72,11 @@ static struct sk_buff *alloc_tx(struct atm_vcc *vcc, unsigned int size)
>  			 sk_wmem_alloc_get(sk), size, sk->sk_sndbuf);
>  		return NULL;
>  	}
> -	while (!(skb = alloc_skb(size, GFP_KERNEL)))
> -		schedule();
> -	pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize);
> -	atomic_add(skb->truesize, &sk->sk_wmem_alloc);
> +	skb = alloc_skb(size, GFP_KERNEL);
> +	if (skb) {
> +		pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize);
> +		atomic_add(skb->truesize, &sk->sk_wmem_alloc);
> +	}
>  	return skb;
>  }
>  
> -- 
> 2.5.5

-- 
Michal Hocko
SUSE Labs

  parent reply	other threads:[~2017-01-12  8:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12  5:02 [Patch net] atm: remove an unnecessary loop Cong Wang
2017-01-12  5:02 ` [Patch net] atm: switch to the new wait API for vcc_sendmsg() Cong Wang
2017-01-12  8:43 ` Michal Hocko [this message]
2017-01-13  0:07 ` [Patch net] atm: remove an unnecessary loop Francois Romieu
2017-01-13  0:14   ` Cong Wang
2017-01-13 13:23     ` Francois Romieu
2017-01-13 18:18       ` Cong Wang
2017-01-14  0:15         ` Francois Romieu
2017-01-14  0:41           ` Cong Wang
2017-01-13 17:10   ` David Miller
2017-01-13 18:20     ` Cong Wang
2017-01-13 23:54       ` Chas Williams
2017-01-14  0:30         ` Cong Wang
2017-01-14 11:34           ` Chas Williams
2017-01-14  0:14       ` Francois Romieu
2017-01-14  0:24         ` Francois Romieu
2017-01-14  0:36         ` Cong Wang

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=20170112084325.GC2264@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=3chas3@gmail.com \
    --cc=andreyknvl@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.com \
    --cc=xiyou.wangcong@gmail.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.