On 6/27/24 6:32 PM, Mina Almasry wrote:
@@ -1049,6 +1050,62 @@ static int sock_reserve_memory(struct sock *sk, int bytes) return 0; } +#ifdef CONFIG_PAGE_POOL +static noinline_for_stack int +sock_devmem_dontneed(struct sock *sk, sockptr_t optval, unsigned int optlen) +{
- unsigned int num_tokens, i, j, k, netmem_num = 0;
- struct dmabuf_token *tokens;
- netmem_ref netmems[16];
- int ret = 0;
- if (sk->sk_type != SOCK_STREAM || sk->sk_protocol != IPPROTO_TCP)
return -EBADF;
- if (optlen % sizeof(struct dmabuf_token) ||
optlen > sizeof(*tokens) * 128)
return -EINVAL;
- tokens = kvmalloc_array(128, sizeof(*tokens), GFP_KERNEL);
The '128' should be a named macro with a comment on why that value.