Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp527779pxb; Wed, 13 Jan 2021 09:17:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlk/Qo98FIx7wCiQH9hbztgv4tQdpnjbBTIQIprLgpx38ecatF0uQ9KDpdTaEzi65lpLhr X-Received: by 2002:aa7:da8f:: with SMTP id q15mr2568649eds.239.1610558254525; Wed, 13 Jan 2021 09:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610558254; cv=none; d=google.com; s=arc-20160816; b=NYVGKN0NnflShRZh6+s/r0QEA4/C2W8SV8AR8OhOL4+6QxQF5Io0w+EUPlMJudXK+H mHRl25rBrfu1LYnUREUYZ4ltgzWVDrnJmmLkA/nYnVhyt35F58mBWketnmw/4hfsUf5b zKe+fDG/4aQdpgT4qbxD3DX6XW5v3UPMXEI7hsVFPOkoPcjjusXHcqiWsDLbxCAkqrnX v+owiQlZjv4cy2Gg9ek0AE/HUG/VL06B/d1Qza+aefLy2y7VmJeJvydtWeOFr6vgL0WI ebJkhzXm1tyOjG1A7ZDXS6TFfaXYPcYX615NmldgRVOZIzgvziPfC0Vj0V6Gd5vP5WaX 4uxg== 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=iG5tn1Cp1H1SX7Oz4JztIttuqT2rpmzdP4e1bJ1egZw=; b=fH/wF1p8ljF4LNLhEoZbJ+kjtVWDze/aO9DsvKU5cHi9sFyNEWSiAYoiK/SJrbJnFc S2nZR+mS3vItDoWOhoYCu/9L4TMv1mULQJ3jOcMf6HqLiPFhJL5+cnA6/yDXaIIQP2gW IWOFkhmZFFgRRscy/sq/SGhXoK4ycoVNA97mlfypxIGFZPt8TCtr4kMZdyIFMtb3LGxJ om0JhBQ6NM11yonwVLWVF4/Y2iEt1Dr9DajoqQHyLM4NTNp4d/McLB+ACqKiYNpHPD1o OoaIZOHmNlTdd5bDuviGxhV8/yjN18iC+Jkfu17Wd/SIHol9nGZIvUfI2NI9Pu2vbxdB 2ChA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IsfSocUY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gj13si1135558ejb.521.2021.01.13.09.17.10; Wed, 13 Jan 2021 09:17:34 -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=@google.com header.s=20161025 header.b=IsfSocUY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727845AbhAMRQN (ORCPT + 99 others); Wed, 13 Jan 2021 12:16:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbhAMRQM (ORCPT ); Wed, 13 Jan 2021 12:16:12 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D6BBC061575 for ; Wed, 13 Jan 2021 09:15:32 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id n4so5547641iow.12 for ; Wed, 13 Jan 2021 09:15:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iG5tn1Cp1H1SX7Oz4JztIttuqT2rpmzdP4e1bJ1egZw=; b=IsfSocUY2mNt1pZMwug7a5E2OXpGai3WI/nMgxsA7go3zjPysB6IO+sNC+dySGXhGc 4H6AyB2YiJqCOY0x7RVe7qzU47Qf1r9Ia5zYEd+etR+wVvMHoCJK/l7vC7Jl5zPo1kcp pTIJi+KOwtPP2zUbG6jP1Vrp0Kse6CqaEFd3gisJ+izxmTnNHwWmYjD/79o6I87Ffib/ mIZroSmNeC/WT/FbrEm7WlhoJi3Uuc+GMAEGiOBqgzUSJo9/nct3s6h4Pft/tUd5XoSw HRzo5yF2gSALYwd3E/qVEMgniGsvgT3DZbAXyGHJme5Aemc/JTGQypy7bv4ana99XSMr s0cA== 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=iG5tn1Cp1H1SX7Oz4JztIttuqT2rpmzdP4e1bJ1egZw=; b=bC9qhxCqCLUQ+3f7C4OCrXFuwtpXCulM1MtQSmrXMqhwlwyQKqDLU6LnRyGimxst76 f4WYLJIqz5hh07STIC02jAIGZ567liGVkk2NdEsj2owjSr/x40wD5mG9IsoeU4+bImtA oI522xOMwpRKZodo+4N1vqTjuyzkWkw+wxYgMXjG03Jq+I8hYtpIH9g2tFXQAa+pAwkd 1VywcaXz6ncM+IndFzpW66bc+WyYM4UB/r0XCQatwtww78n1HeWJR+RvJZMH/sf+Y5v7 /f8UiIwZcPobXTm/xJt5vbyc2lLaJ5dpJAe+o82GdxSM8z1MU/Xldf62w6ruUrxeV/g9 ekzA== X-Gm-Message-State: AOAM5339GWPkq0HM4DXql1OOPiFbg2QcD+Wv3J3kK8+/UJazPi3SkTHX pu48po2QH74PGlQ9n8ld8Ad0H8xmonsHdQXGAqPYmQ== X-Received: by 2002:a92:9153:: with SMTP id t80mr3261980ild.216.1610558131599; Wed, 13 Jan 2021 09:15:31 -0800 (PST) MIME-Version: 1.0 References: <20210111182655.12159-1-alobakin@pm.me> <20210112110802.3914-1-alobakin@pm.me> <20210112170242.414b8664@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20210113090341.74832be9@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210113090341.74832be9@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Eric Dumazet Date: Wed, 13 Jan 2021 18:15:20 +0100 Message-ID: Subject: Re: [PATCH net-next 0/5] skbuff: introduce skbuff_heads bulking and reusing To: Jakub Kicinski Cc: Alexander Lobakin , Edward Cree , "David S. Miller" , Edward Cree , Jonathan Lemon , Willem de Bruijn , Miaohe Lin , Steffen Klassert , Guillaume Nault , Yadu Kishore , Al Viro , netdev , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 6:03 PM Jakub Kicinski wrote: > > On Wed, 13 Jan 2021 05:46:05 +0100 Eric Dumazet wrote: > > On Wed, Jan 13, 2021 at 2:02 AM Jakub Kicinski wrote: > > > > > > On Tue, 12 Jan 2021 13:23:16 +0100 Eric Dumazet wrote: > > > > On Tue, Jan 12, 2021 at 12:08 PM Alexander Lobakin wrote: > > > > > > > > > > From: Edward Cree > > > > > Date: Tue, 12 Jan 2021 09:54:04 +0000 > > > > > > > > > > > Without wishing to weigh in on whether this caching is a good idea... > > > > > > > > > > Well, we already have a cache to bulk flush "consumed" skbs, although > > > > > kmem_cache_free() is generally lighter than kmem_cache_alloc(), and > > > > > a page frag cache to allocate skb->head that is also bulking the > > > > > operations, since it contains a (compound) page with the size of > > > > > min(SZ_32K, PAGE_SIZE). > > > > > If they wouldn't give any visible boosts, I think they wouldn't hit > > > > > mainline. > > > > > > > > > > > Wouldn't it be simpler, rather than having two separate "alloc" and "flush" > > > > > > caches, to have a single larger cache, such that whenever it becomes full > > > > > > we bulk flush the top half, and when it's empty we bulk alloc the bottom > > > > > > half? That should mean fewer branches, fewer instructions etc. than > > > > > > having to decide which cache to act upon every time. > > > > > > > > > > I though about a unified cache, but couldn't decide whether to flush > > > > > or to allocate heads and how much to process. Your suggestion answers > > > > > these questions and generally seems great. I'll try that one, thanks! > > > > > > > > The thing is : kmalloc() is supposed to have batches already, and nice > > > > per-cpu caches. > > > > > > > > This looks like an mm issue, are we sure we want to get over it ? > > > > > > > > I would like a full analysis of why SLAB/SLUB does not work well for > > > > your test workload. > > > > > > +1, it does feel like we're getting into mm territory > > > > I read the existing code, and with Edward Cree idea of reusing the > > existing cache (storage of pointers), > > ths now all makes sense, since there will be not much added code (and > > new storage of 64 pointers) > > > > The remaining issue is to make sure KASAN will still work, we need > > this to detect old and new bugs. > > IDK much about MM, but we already have a kmem_cache for skbs and now > we're building a cache on top of a cache. Shouldn't MM take care of > providing a per-CPU BH-only lockless cache? I think part of the improvement comes from bulk operations, which are provided by mm layer. I also note Alexander made no provision for NUMA awareness. Probably reusing skb located on a remote node will not be ideal.