Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3878208pxb; Sat, 13 Feb 2021 12:33:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGTyZ1vv9uVXaVhklcWPOZ4cCtKCAFUCVK2IevRfoyqYsPjxOCrkF2eBM8n+EJwGXOfaDX X-Received: by 2002:a17:906:dff1:: with SMTP id lc17mr8553797ejc.198.1613248405924; Sat, 13 Feb 2021 12:33:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613248405; cv=none; d=google.com; s=arc-20160816; b=C6mMtjEM4y5aZRr6H8QgLor85doPrwhDhUz3iguw31osU8eVLssaOHLrgi6Rk0GQaO JC4bmtEHxC6P2dQUWl1cDsMfCztD5FCc1CcKfrIGbwbw/tDIwzSTxWPi5VfXZBNf8+w9 iE7C9XLMvOuPZzBCzvHIe0MicswUHLkEB7OJvP7mxnazpMC7SXWmbFynApYVGoTD8AoE dJIhgraOT+8VoszTQqGsa94mV/p4p1YtUP3A2SvW7wpjv1yYWv+SNYL1IJvUMRw6+7/f FTQhdbiKELPqkDdGNt6y+YaO0SQ4Rp/BEYr6k3AZniUcxr3OxclEkieT6frZAh9RpYhU ap9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JG1Vr3+XZeOCDX4ayu9Kw5Y6nxVv5uh+/era+kVHp+c=; b=l8/sRkR9T/E+d+jO8Q/nBaPLvm9d9SXLaDdYhVC5KM5fMkcIYraRhtwFgG0ujpbJRS z13L3AM+wJTVgrg4nKe16PJV9oT9UEdOh/hNbxMqgUByv13R2zvsNCBDR9oEogMahZo/ bGjmDaNQEVMovg4Soeah5oIgEPjO6V+p1pHeJal9QoclWFxiO7ElpAkk8JsO1GNfAdI9 gwofNj0Nz2E1zu4tMURZoZ/Jdjmx1LyW1ffc5QYhX/tnO6xabO+xbW5OkVYRSLSFV9N0 LrnKa7y2qwZ0TqJipWo28S47EJHh2yOUKTw6cYMXnwaCTn8+qOl9LJ0XHIWxOjucRXEt m+Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oDkaEDla; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si8849562edy.79.2021.02.13.12.33.01; Sat, 13 Feb 2021 12:33:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oDkaEDla; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbhBMUbO (ORCPT + 99 others); Sat, 13 Feb 2021 15:31:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbhBMUbK (ORCPT ); Sat, 13 Feb 2021 15:31:10 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A25C061574; Sat, 13 Feb 2021 12:30:30 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id u8so2831335ior.13; Sat, 13 Feb 2021 12:30:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JG1Vr3+XZeOCDX4ayu9Kw5Y6nxVv5uh+/era+kVHp+c=; b=oDkaEDlaOWmW+rSv6ahySY/RqHECLWmo1OVvDtZUgtkWeigRHCZx7UCVEC+PiTIp89 cO63xW30qxkzt8FvnWrqUPbjFPcnhxHoUh89LWPT7Cuk/4BW6pWNJsP2OMDuD6bQA7TM 7GPM6zlybjsrwx2GuyyMmHP7h7BsB5Em01oAHQHBWoFGW58nuxjMcGXZhgQa8x7F+lk7 HcpNTxZCEP5S81NgEuG2jUQ805uKPZ5y1lKLmn2UnaJymx+j6RC2dQCc0CYf+F9M6af2 rxhDYVDJfmPNVrFm9om4YJBCjCSqaLP5Ab9RCQZjky32tpyRgFSgKB7+OVSMVFX1PLur p/Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JG1Vr3+XZeOCDX4ayu9Kw5Y6nxVv5uh+/era+kVHp+c=; b=A/ttuVbRiFVyfKq7QKwf22OCE0X+8xNXQjdCoD/NhWMRQTf3Br7dIbHYn8FXUfCg2M KU86UvBdXXT/SLleyoLh6rNUlmRUUQeppZawYKDM03CMf3VOXCLB48NyCWyK8VK5Q7e4 zREqBRIThQgB3ocBdlKeSKi+t43/hTXuM+5ihpnUBeGq1ahnl+DrVGziprobED8p4tsQ CZPbu6ZMhA6VvWBZXEl6K5Pv/uo0X8R8PS9aneZMi2GEnkrca9mCPsAaBORcYlrbJHqs eH+4SuhtyyQcM5KIepk72wlPsp3IM6XSzluLNUd27OnqMEcEicm+tgKahGu8E/TcNlAa /KjA== X-Gm-Message-State: AOAM530mdfqGlg1WYno3QToSy5kj/wX/fOvJ9AcM1C+mCMrZVB8EuPtu RoAmI2eSzBvrfXVFmuF4WtFgkrC7OUv0OGwXni0= X-Received: by 2002:a05:6602:2c52:: with SMTP id x18mr7177077iov.5.1613248229578; Sat, 13 Feb 2021 12:30:29 -0800 (PST) MIME-Version: 1.0 References: <20210213141021.87840-1-alobakin@pm.me> In-Reply-To: <20210213141021.87840-1-alobakin@pm.me> From: Alexander Duyck Date: Sat, 13 Feb 2021 12:30:18 -0800 Message-ID: Subject: Re: [PATCH v6 net-next 00/11] skbuff: introduce skbuff_heads bulking and reusing To: Alexander Lobakin Cc: "David S. Miller" , Jakub Kicinski , Jonathan Lemon , Eric Dumazet , Dmitry Vyukov , Willem de Bruijn , Randy Dunlap , Kevin Hao , Pablo Neira Ayuso , Jakub Sitnicki , Marco Elver , Dexuan Cui , Paolo Abeni , Jesper Dangaard Brouer , Alexander Duyck , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Taehee Yoo , Wei Wang , Cong Wang , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Miaohe Lin , Guillaume Nault , Florian Westphal , Edward Cree , LKML , Netdev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 13, 2021 at 6:10 AM Alexander Lobakin wrote: > > Currently, all sorts of skb allocation always do allocate > skbuff_heads one by one via kmem_cache_alloc(). > On the other hand, we have percpu napi_alloc_cache to store > skbuff_heads queued up for freeing and flush them by bulks. > > We can use this cache not only for bulk-wiping, but also to obtain > heads for new skbs and avoid unconditional allocations, as well as > for bulk-allocating (like XDP's cpumap code and veth driver already > do). > > As this might affect latencies, cache pressure and lots of hardware > and driver-dependent stuff, this new feature is mostly optional and > can be issued via: > - a new napi_build_skb() function (as a replacement for build_skb()); > - existing {,__}napi_alloc_skb() and napi_get_frags() functions; > - __alloc_skb() with passing SKB_ALLOC_NAPI in flags. > > iperf3 showed 35-70 Mbps bumps for both TCP and UDP while performing > VLAN NAT on 1.2 GHz MIPS board. The boost is likely to be bigger > on more powerful hosts and NICs with tens of Mpps. > > Note on skbuff_heads from distant slabs or pfmemalloc'ed slabs: > - kmalloc()/kmem_cache_alloc() itself allows by default allocating > memory from the remote nodes to defragment their slabs. This is > controlled by sysctl, but according to this, skbuff_head from a > remote node is an OK case; > - The easiest way to check if the slab of skbuff_head is remote or > pfmemalloc'ed is: > > if (!dev_page_is_reusable(virt_to_head_page(skb))) > /* drop it */; > > ...*but*, regarding that most slabs are built of compound pages, > virt_to_head_page() will hit unlikely-branch every single call. > This check costed at least 20 Mbps in test scenarios and seems > like it'd be better to _not_ do this. > Alexander Lobakin (11): > skbuff: move __alloc_skb() next to the other skb allocation functions > skbuff: simplify kmalloc_reserve() > skbuff: make __build_skb_around() return void > skbuff: simplify __alloc_skb() a bit > skbuff: use __build_skb_around() in __alloc_skb() > skbuff: remove __kfree_skb_flush() > skbuff: move NAPI cache declarations upper in the file > skbuff: introduce {,__}napi_build_skb() which reuses NAPI cache heads > skbuff: allow to optionally use NAPI cache from __alloc_skb() > skbuff: allow to use NAPI cache from __napi_alloc_skb() > skbuff: queue NAPI_MERGED_FREE skbs into NAPI cache instead of freeing > > include/linux/skbuff.h | 4 +- > net/core/dev.c | 16 +- > net/core/skbuff.c | 428 +++++++++++++++++++++++------------------ > 3 files changed, 242 insertions(+), 206 deletions(-) > With the last few changes and testing to verify the need to drop the cache clearing this patch set looks good to me. Reviewed-by: Alexander Duyck