Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6468761ybi; Wed, 29 May 2019 08:16:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3h0Cy0OufmuqBccqlDBO9S9e7g7x3jGj4dtCuvQmaDZcIHW3PuHBJca93eocTUaFz/bJA X-Received: by 2002:a62:f245:: with SMTP id y5mr80637631pfl.12.1559142960884; Wed, 29 May 2019 08:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559142960; cv=none; d=google.com; s=arc-20160816; b=gjaMQ+Wzx+VRXvGqljRFo0Jl/kTw+vJUc1gXuHfYLNGxhd1LoHwY6y6idxQu5TFFE9 8v0XIgnz7AfIPgvC7RI5iknp6C64wDcuJrATvu2g0q+EIHDz5gFnwMXlCfVvLTzHU+84 ifftft+n9CArFdd89oXKgfb4ccZ4NzdPKluBS4pchloSUK3tDZm+VgvZ798eynf1pnAp LYpNusBxb6UMWfAZNJucCIA9zhQie8oWV7AYB/r6PClyBHxTuDPFD6/khBIdaGB7DojF 3mUsxFbO4zl8i2LVI6djYt79nyKfFTcM/tNdJ5LWUEsoo4DcjPMF/pqfKXe6NClkW2IZ fHWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=W2buZooF/pmx7z95pzXizhl/Lg5Xb9tNt67UtliOTiY=; b=KktShEd3woMzIdfkCOQFy33x/qiS6fEuV+e8iDcGZVdgBpEGWQSNrmr1CR+kCfLJi6 I1K+l/nxCHb1S3JyyH3jFyIFgKCBuMhjkb2g9UtXHem2btHBEmktu5B59FGLujh+AcuQ 9bP+dyexOCZBsQWUqKEyeR7G5GkGKDeaoYiKMNUpeFGW6B659u3/+/GDBwZd9sa4/QV3 ZZAutlTCIZGe6Rmvm2vjjcPM7ROCmA1Fmk+498wImLIzmADxeo0OdwL5gXuirJx6m782 AnRRQEXxNbWR7xYjPMw5pGWUztRxmF1A0RrrYqvbrr3kbGG0Kfsq7DlrI5H+o+2k8xer 0a8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si25322699pll.226.2019.05.29.08.15.44; Wed, 29 May 2019 08:16:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727105AbfE2PNw (ORCPT + 99 others); Wed, 29 May 2019 11:13:52 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34109 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbfE2PNw (ORCPT ); Wed, 29 May 2019 11:13:52 -0400 Received: by mail-wm1-f68.google.com with SMTP id e19so4493414wme.1 for ; Wed, 29 May 2019 08:13:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=W2buZooF/pmx7z95pzXizhl/Lg5Xb9tNt67UtliOTiY=; b=hYoBDqgCA9JdKalL6UyEyryzQ1UdtbzRaa7BET53Hn2oeGSLyZBiQoD21RxcdVJqBk SSSyq02j6LRt8PFwgTC9paSKqk9s4CuHvhOkek7Bib43cxMxSHIUnQWe/Bvrrzv5vKYI FUfwX7/j41O5Wb8g6C4olOvCREDAIK8Ipzgn+wtjxXan6dtdOolqT9UfcMKadbjsi9u1 Qpa5fZUj3xwCXWE6ObMM+qPmsmb9VgFIKKNn32yGL0grhZW2t3TIBxXDS8TiDtyiMWey whKOxEBVQsUND9jMwtHkCm41YOYK6DPl3rqGTAZp+3jG6FitBtl/7ag29cHF0upQKXNv +2kA== X-Gm-Message-State: APjAAAW3rDqLYrb1+u7sX042fDKzfayJllf4iEPFzUghKi8rXGgJCe7a U2Tw7uK7fyT0Y9iHi5I+zrwtR60E3YA= X-Received: by 2002:a1c:4d07:: with SMTP id o7mr7154944wmh.156.1559142830240; Wed, 29 May 2019 08:13:50 -0700 (PDT) Received: from raver.teknoraver.net (net-93-144-152-91.cust.dsl.teletu.it. [93.144.152.91]) by smtp.gmail.com with ESMTPSA id c131sm7284963wma.31.2019.05.29.08.13.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 29 May 2019 08:13:49 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Cc: "David S. Miller" , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2] net: avoid indirect calls in L4 checksum calculation Date: Wed, 29 May 2019 17:13:48 +0200 Message-Id: <20190529151348.31311-1-mcroce@redhat.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 283c16a2dfd3 ("indirect call wrappers: helpers to speed-up indirect calls of builtin") introduces some macros to avoid doing indirect calls. Use these helpers to remove two indirect calls in the L4 checksum calculation for devices which don't have hardware support for it. As a test I generate packets with pktgen out to a dummy interface with HW checksumming disabled, to have the checksum calculated in every sent packet. The packet rate measured with an i7-6700K CPU and a single pktgen thread raised from 6143 to 6608 Kpps, an increase by 7.5% Suggested-by: Davide Caratti Signed-off-by: Matteo Croce --- net/core/skbuff.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index e89be6282693..0c2e7d4946ef 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -76,6 +76,7 @@ #include #include #include +#include #include "datagram.h" @@ -2507,7 +2508,8 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len, if (copy > 0) { if (copy > len) copy = len; - csum = ops->update(skb->data + offset, copy, csum); + csum = INDIRECT_CALL_1(ops->update, csum_partial_ext, + skb->data + offset, copy, csum); if ((len -= copy) == 0) return csum; offset += copy; @@ -2534,9 +2536,13 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len, frag->page_offset + offset - start, copy, p, p_off, p_len, copied) { vaddr = kmap_atomic(p); - csum2 = ops->update(vaddr + p_off, p_len, 0); + csum2 = INDIRECT_CALL_1(ops->update, + csum_partial_ext, + vaddr + p_off, p_len, 0); kunmap_atomic(vaddr); - csum = ops->combine(csum, csum2, pos, p_len); + csum = INDIRECT_CALL_1(ops->combine, + csum_block_add_ext, csum, + csum2, pos, p_len); pos += p_len; } @@ -2559,7 +2565,8 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len, copy = len; csum2 = __skb_checksum(frag_iter, offset - start, copy, 0, ops); - csum = ops->combine(csum, csum2, pos, copy); + csum = INDIRECT_CALL_1(ops->combine, csum_block_add_ext, + csum, csum2, pos, copy); if ((len -= copy) == 0) return csum; offset += copy; -- 2.21.0