Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3655198pxf; Mon, 22 Mar 2021 11:34:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5iHcheqymPjlgboajSLdukiJOUwUZu87+TaSRJiCPnRNgh/PsSg+qjWxkFU4t3rdlkFyq X-Received: by 2002:a05:6402:38f:: with SMTP id o15mr908400edv.361.1616438058055; Mon, 22 Mar 2021 11:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616438058; cv=none; d=google.com; s=arc-20160816; b=yaIJhabtVVCzLR90lnqkj4EnSEByjwCvkfeR/hVJx8ECnHCHyPy6Rgppz7455zJghu 79xWqBXQTftGqyPhXdIwcFR6PpOgoARxcPztzYqZNPLiC9tFtv15GNn9wh5RI/n5gKo2 w6fdXMyPNUwdcEzzj5Abs5zPz51PpPfJpMlarHfIbol+ujnf0pXYZCzIJQ5HQHVTbTSL zoluvpHMAnhmczCjGfPmVfVXG4IYlnph8Q4FFyPFEcpZgA3Vp4OZv+h2Z7c6qS7sB3+C +XCQjv/mXrb4zDH+gKIkPrK7w4Qe3PEuMsCoP7UBHL6VBznXxZPHMEotAYVvfaof8XQd 7Mhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:subject:reply-to:cc:from:to:dkim-signature:date; bh=b5bnSC21HmdPSasvb0lPwEo3mq8xZMPl9SmiGDrxhUA=; b=PUUA1uTxMI9Diy8B4BVXFwqUo+0sjKisRfpj3EtUBveoMok71JWnToMfsuu2uognc4 v/LmwBh6clEfyBudNSkZOXQpXzJ2+oGILCD+Rt16nnceXspyZ2Dm8n/uWjM2GaqI/gp2 HgoFnc9f+aPVIr7EcKxsDwG7WBEH4LcK4/3kTCEqsk5H416tZ4mXeK1zx3EA78scoC4Z veF6+cvfyyC+nt7eqcGF8uK7BMFrSe51xRdzdgTJEyo/Fk6oP2n1z9syNRM3PeXQxkwM 6RrrJXXYuvLYukQPOKIS59Sjztbmc9Wbxq4FdKh9c9TOsqGu4mWc8bOKFnLGPXkWdJKr fXqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=T7gFIEvl; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si11847992ejb.59.2021.03.22.11.33.55; Mon, 22 Mar 2021 11:34:18 -0700 (PDT) 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=@pm.me header.s=protonmail header.b=T7gFIEvl; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231250AbhCVSbJ (ORCPT + 99 others); Mon, 22 Mar 2021 14:31:09 -0400 Received: from mail-40136.protonmail.ch ([185.70.40.136]:36923 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbhCVSbC (ORCPT ); Mon, 22 Mar 2021 14:31:02 -0400 Date: Mon, 22 Mar 2021 18:30:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1616437860; bh=b5bnSC21HmdPSasvb0lPwEo3mq8xZMPl9SmiGDrxhUA=; h=Date:To:From:Cc:Reply-To:Subject:From; b=T7gFIEvlwC6tvcyiAGO7XGyjFHGvUsCeAnSnlZePqC9ObCS2k+FPNvlA6BCtbIfvK 0IiSFn0JyKe8s3lslelNM21/WjpYjbT9egUHW2iXTNhB/Iz9js+pkFG3w8OFZSYBIC Fp4PCGRVWGivgvfad8WOg819SMJ6F0CM5PjghkyVxGl3pO2IhW+JmhzjmK4ksM1sUO cflq/xEqRaQAAdxnFDGx+PTPBngvlY6XHklEwEtu/tfaYxXsn7zcDXzEWeNGpUaWuN O+jKscOJ20r9mriCfMJhbrbzHrA0KOl3WtqfLf2d6xPjBGvsS1S/XTNdwnAACN4M++ sAcXS508z8sVQ== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: Jesper Dangaard Brouer , Ilias Apalodimas , Matteo Croce , Mel Gorman , Alexander Lobakin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH net-next] page_pool: let the compiler optimize and inline core functions Message-ID: <20210322183047.10768-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As per disscussion in Page Pool bulk allocator thread [0], there are two functions in Page Pool core code that are marked as 'noinline'. The reason for this is not so clear, and even if it was made to reduce hotpath overhead, in fact it only makes things worse. As both of these functions as being called only once through the code, they could be inlined/folded into the non-static entry point. However, 'noinline' marks effectively prevent from doing that and induce totally unneeded fragmentation (baseline -> after removal): add/remove: 0/3 grow/shrink: 1/0 up/down: 1024/-1096 (-72) Function old new delta page_pool_alloc_pages 100 1124 +1024 page_pool_dma_map 164 - -164 page_pool_refill_alloc_cache 332 - -332 __page_pool_alloc_pages_slow 600 - -600 (taken from Mel's branch, hence factored-out page_pool_dma_map()) 1124 is a normal hotpath frame size, but these jumps between tiny page_pool_alloc_pages(), page_pool_refill_alloc_cache() and __page_pool_alloc_pages_slow() are really redundant and harmful for performance. This simple removal of 'noinline' keywords bumps the throughput on XDP_PASS + napi_build_skb() + napi_gro_receive() on 25+ Mbps for 1G embedded NIC. [0] https://lore.kernel.org/netdev/20210317222506.1266004-1-alobakin@pm.me Signed-off-by: Alexander Lobakin --- net/core/page_pool.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index ad8b0707af04..589e4df6ef2b 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -102,7 +102,6 @@ EXPORT_SYMBOL(page_pool_create); static void page_pool_return_page(struct page_pool *pool, struct page *pag= e); -noinline static struct page *page_pool_refill_alloc_cache(struct page_pool *pool) { =09struct ptr_ring *r =3D &pool->ring; @@ -181,7 +180,6 @@ static void page_pool_dma_sync_for_device(struct page_p= ool *pool, } /* slow path */ -noinline static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool, =09=09=09=09=09=09 gfp_t _gfp) { -- 2.31.0