[Devel] net: Restore default sock_alloc_send_pskb() changed by initial cumulative patch

Submitted by Kirill Tkhai on Oct. 18, 2016, 3:29 p.m.

Details

Message ID 6b9ed14d-2d41-48d1-dba0-784902fceb91@virtuozzo.com
State New
Series "net: Restore default sock_alloc_send_pskb() changed by initial cumulative patch"
Headers show

Commit Message

Kirill Tkhai Oct. 18, 2016, 3:29 p.m.
Some of pre-2.6.32 kernel need linear skb allocation for these places. The most
probably, it's connected with problems of memory accounting then.

But now, these hunks creates problem for VMs, because allocation of continuous
big skbs fails there.

Restore the default behaviour to fix the problem.

https://jira.sw.ru/browse/PSBM-52390

Reported-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---

Patch hide | download patch | download mbox

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index a128823..d589b6d 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -605,7 +605,12 @@  static inline struct sk_buff *macvtap_alloc_skb(struct sock *sk, size_t prepad,
 {
 	struct sk_buff *skb;
 
-	skb = sock_alloc_send_skb(sk, prepad + linear, noblock, err);
+	/* Under a page?  Don't bother with paged skb. */
+	if (prepad + len < PAGE_SIZE || !linear)
+		linear = len;
+
+	skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
+				   err, 0);
 	if (!skb)
 		return NULL;
 
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index dabe51c..75c627b 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1028,8 +1028,12 @@  static struct sk_buff *tun_alloc_skb(struct tun_file *tfile,
 	struct sk_buff *skb;
 	int err;
 
-	linear = len;
-	skb = sock_alloc_send_skb(sk, prepad + linear, noblock, &err);
+	/* Under a page?  Don't bother with paged skb. */
+	if (prepad + len < PAGE_SIZE || !linear)
+		linear = len;
+
+	skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
+				   &err, 0);
 	if (!skb)
 		return ERR_PTR(err);
 

Comments

Roman Kagan Oct. 18, 2016, 3:41 p.m.
On Tue, Oct 18, 2016 at 06:29:04PM +0300, Kirill Tkhai wrote:
> Some of pre-2.6.32 kernel need linear skb allocation for these places. The most
> probably, it's connected with problems of memory accounting then.
> 
> But now, these hunks creates problem for VMs, because allocation of continuous
> big skbs fails there.
> 
> Restore the default behaviour to fix the problem.
> 
> https://jira.sw.ru/browse/PSBM-52390
> 
> Reported-by: Roman Kagan <rkagan@virtuozzo.com>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Konstantin Khorenko Oct. 19, 2016, 10:13 a.m.
Zhenya, Vasya,

please release it as a ReadyKernel patch.

Thank you.

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 10/18/2016 06:29 PM, Kirill Tkhai wrote:
> Some of pre-2.6.32 kernel need linear skb allocation for these places. The most
> probably, it's connected with problems of memory accounting then.
>
> But now, these hunks creates problem for VMs, because allocation of continuous
> big skbs fails there.
>
> Restore the default behaviour to fix the problem.
>
> https://jira.sw.ru/browse/PSBM-52390
>
> Reported-by: Roman Kagan <rkagan@virtuozzo.com>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index a128823..d589b6d 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -605,7 +605,12 @@ static inline struct sk_buff *macvtap_alloc_skb(struct sock *sk, size_t prepad,
>  {
>  	struct sk_buff *skb;
>
> -	skb = sock_alloc_send_skb(sk, prepad + linear, noblock, err);
> +	/* Under a page?  Don't bother with paged skb. */
> +	if (prepad + len < PAGE_SIZE || !linear)
> +		linear = len;
> +
> +	skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
> +				   err, 0);
>  	if (!skb)
>  		return NULL;
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index dabe51c..75c627b 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1028,8 +1028,12 @@ static struct sk_buff *tun_alloc_skb(struct tun_file *tfile,
>  	struct sk_buff *skb;
>  	int err;
>
> -	linear = len;
> -	skb = sock_alloc_send_skb(sk, prepad + linear, noblock, &err);
> +	/* Under a page?  Don't bother with paged skb. */
> +	if (prepad + len < PAGE_SIZE || !linear)
> +		linear = len;
> +
> +	skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
> +				   &err, 0);
>  	if (!skb)
>  		return ERR_PTR(err);
>
> .
>