Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1267044imp; Thu, 21 Feb 2019 23:32:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IYUYC8pLx6bgRWyZU0Cgc+2nPmT9a5zbI2lKl8Gg4/KB9+SDffhewA8uR2HwcBMUjY27m16 X-Received: by 2002:a65:614a:: with SMTP id o10mr2666375pgv.387.1550820744182; Thu, 21 Feb 2019 23:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550820744; cv=none; d=google.com; s=arc-20160816; b=Jj43HavS2cHn8QHZVa1Q70Jk1zUmf/nrmJzA8XGBn+z1iqPLy/lJMQeX2wePAmg9Nj j0PFTJdY+WbnM40IGsBfXRnIWUeSMgce5VZXqLtXkLpgECSS/huuGRZ7c07h4N2J7sR+ u6itDfLfe++bttnoYY3Ra7fUVpY3f59eAjpKm2czg7rM4nXa+N/sOSVfGD5lVWcttoqM x3Ntpj+RGot8kKLSl5jx58jeCTSE2J75ToozteZetCcz83c5x3AM9ItI/4Nf7qKOHUaH X69xPGSEPNHcA0q2rByjiTIR4sF43kV2OYPyMZoSmfcQfxzCU8s9sOUzJTooe3A/Jw7x yqUQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=g5o7/nAh2Kn4xkLj6sUhoDJtYHSpAyVtwVLnpvwKlH8=; b=fwcClquKs2pjywDPmyE9RE+numhLSGW4XypS1xfiTqzo2nRBrBu0gzoUutdvtPYwn2 BbMBjepcg0P55q3KkvnpnRjKcfMSzlIhQe8L1EAfBmXKWqOpjsRGj/VZADJkq36zv5pY z/xVpXLpI4OskU7mwEXi9Sl6oYKbosIC6vE0eEPHnGmyyFm/mA+pT4MEzDZlbNf7sjVW oLaVPRdiK+yQrT3EW/r+maZSX+FIJo+nzID2nZcvmoWnJN7J9lOLNfCuCdxfyUeCiihU YMUujYS+eh2yJtqAnbs/XxnIbGodmS3jL1gAfCpIB1DQHecHg+g56wmjlC7pat06UDnZ /qRA== 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 cc9si777253plb.59.2019.02.21.23.32.08; Thu, 21 Feb 2019 23:32:24 -0800 (PST) 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 S1726352AbfBVHbl convert rfc822-to-8bit (ORCPT + 99 others); Fri, 22 Feb 2019 02:31:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56168 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725824AbfBVHbl (ORCPT ); Fri, 22 Feb 2019 02:31:41 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0D203082A51; Fri, 22 Feb 2019 07:31:40 +0000 (UTC) Received: from carbon (ovpn-200-42.brq.redhat.com [10.40.200.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F51B5D9D4; Fri, 22 Feb 2019 07:31:32 +0000 (UTC) Date: Fri, 22 Feb 2019 08:31:31 +0100 From: Jesper Dangaard Brouer To: Daniel Borkmann Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "David S . Miller" , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Alexei Starovoitov , Peter Zijlstra , David Woodhouse , Andy Lutomirski , Borislav Petkov , Linus Torvalds , brouer@redhat.com Subject: Re: [PATCH] x86, retpolines: raise limit for generating indirect calls from switch-case Message-ID: <20190222083131.5a141e23@carbon> In-Reply-To: <20190221221941.29358-1-daniel@iogearbox.net> References: <20190221221941.29358-1-daniel@iogearbox.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 22 Feb 2019 07:31:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Feb 2019 23:19:41 +0100 Daniel Borkmann wrote: > Recent work on XDP from Björn and Magnus additionally found that > manually transforming the XDP return code switch statement with > more than 5 cases into if-else combination would result in a > considerable speedup in XDP layer due to avoidance of indirect > calls in CONFIG_RETPOLINE enabled builds. On i40e driver with > XDP prog attached, a 20-26% speedup has been observed [0]. Aside > from XDP, there are many other places later in the networking > stack's critical path with similar switch-case processing. Rather > than fixing every XDP-enabled driver and locations in stack by > hand, it would be good to instead raise the limit where gcc would > emit expensive indirect calls from the switch under retpolines I'm very happy to see this. Thanks to Björn for finding, analyzing and providing hand-coded-if-else code that demonstrated the performance issue for XDP. But I do think this GCC case-values-threshold param is a better and more generic solution to the issue we observed and measured in XDP land. And hopefully other parts of the network stack and kernel will also benefit. Acked-by: Jesper Dangaard Brouer Thanks for following up on this Daniel, -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer