[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240227095244.23e5a740@kernel.org>
Date: Tue, 27 Feb 2024 09:52:44 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>, Paolo Abeni
<pabeni@...hat.com>, netdev@...r.kernel.org, eric.dumazet@...il.com,
Zhengchao Shao <shaozhengchao@...wei.com>
Subject: Re: [PATCH net-next] netlink: use kvmalloc() in
netlink_alloc_large_skb()
On Sat, 24 Feb 2024 09:06:30 +0000 Eric Dumazet wrote:
> struct sk_buff *netlink_alloc_large_skb(unsigned int size, int broadcast)
> {
> + size_t head_size = SKB_HEAD_ALIGN(size);
> struct sk_buff *skb;
> void *data;
>
> - if (size <= NLMSG_GOODSIZE || broadcast)
> + if (head_size <= PAGE_SIZE || broadcast)
> return alloc_skb(size, GFP_KERNEL);
>
> - size = SKB_DATA_ALIGN(size) +
> - SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> -
> - data = vmalloc(size);
> - if (data == NULL)
> + data = kvmalloc(head_size, GFP_KERNEL);
> + if (!data)
> return NULL;
>
> - skb = __build_skb(data, size);
> - if (skb == NULL)
> - vfree(data);
> - else
> + skb = __build_skb(data, head_size);
Is this going to work with KFENCE? Don't we need similar size
adjustment logic as we have in __slab_build_skb() ?
> + if (!skb)
> + kvfree(data);
> + else if (is_vmalloc_addr(data))
> skb->destructor = netlink_skb_destructor;
Powered by blists - more mailing lists