From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19D08C54E49 for ; Thu, 7 May 2020 20:22:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EADA424959 for ; Thu, 7 May 2020 20:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728671AbgEGUWU (ORCPT ); Thu, 7 May 2020 16:22:20 -0400 Received: from www62.your-server.de ([213.133.104.62]:34222 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728045AbgEGUWT (ORCPT ); Thu, 7 May 2020 16:22:19 -0400 Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jWn26-0001Dl-GF; Thu, 07 May 2020 22:22:14 +0200 Received: from [178.195.186.98] (helo=pc-9.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWn21-0002Yj-BR; Thu, 07 May 2020 22:22:09 +0200 Subject: Re: [RFC PATCH bpf-next 3/3] bpf, arm64: Optimize ADD,SUB,JMP BPF_K using arm64 add/sub immediates To: Luke Nelson , bpf@vger.kernel.org Cc: Luke Nelson , Xi Wang , Catalin Marinas , Will Deacon , Alexei Starovoitov , Zi Shen Lim , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Mark Rutland , Enrico Weigelt , Torsten Duwe , Allison Randal , Thomas Gleixner , Christoffer Dall , Marc Zyngier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, clang-built-linux@googlegroups.com References: <20200507010504.26352-1-luke.r.nels@gmail.com> <20200507010504.26352-4-luke.r.nels@gmail.com> From: Daniel Borkmann Message-ID: Date: Thu, 7 May 2020 22:22:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200507010504.26352-4-luke.r.nels@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.2/25805/Thu May 7 14:14:46 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/7/20 3:05 AM, Luke Nelson wrote: > The current code for BPF_{ADD,SUB} BPF_K loads the BPF immediate to a > temporary register before performing the addition/subtraction. Similarly, > BPF_JMP BPF_K cases load the immediate to a temporary register before > comparison. > > This patch introduces optimizations that use arm64 immediate add, sub, > cmn, or cmp instructions when the BPF immediate fits. If the immediate > does not fit, it falls back to using a temporary register. > > Example of generated code for BPF_ALU64_IMM(BPF_ADD, R0, 2): > > without optimization: > > 24: mov x10, #0x2 > 28: add x7, x7, x10 > > with optimization: > > 24: add x7, x7, #0x2 > > The code could use A64_{ADD,SUB}_I directly and check if it returns > AARCH64_BREAK_FAULT, similar to how logical immediates are handled. > However, aarch64_insn_gen_add_sub_imm from insn.c prints error messages > when the immediate does not fit, and it's simpler to check if the > immediate fits ahead of time. > > Co-developed-by: Xi Wang > Signed-off-by: Xi Wang > Signed-off-by: Luke Nelson Same here: Acked-by: Daniel Borkmann Thanks! From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6229FC38A2A for ; Thu, 7 May 2020 20:22:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FFC324962 for ; Thu, 7 May 2020 20:22:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bD5Wh2BQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FFC324962 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=iogearbox.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=il5CXMJGKB/axsr1XyIm3uf4qItnEu6i1mvFksaqBLo=; b=bD5Wh2BQNC9eUlenMCH+gY5ju IgoSQCK+PVv4xDzMzLBHJeheEnopHdFNWzW6GTsumDVm9WDXcqkav9xLPFWlG+Pe5u3ADP1zlfShn wBaP7MjpVRRSGIOBFINu7GGaNLwK9pLG5IVqifBbzINVM1FlCFW1+D2G4K26fGPxojj8KmoQ9QUpk zdXwCWqTCel0a6+iiYB4JXChdMnj6lx8vof1Wcz0hreWrnVAIHetDmQxKHdPigVxCeK9Hh5+lmfhk 1J1T/Y5T6wU2XclkpGtMYPmm/ORomUQmhE8eIFQ//J9D8prSmy5pwxCGaCFG/IK/Rovz0Y+gV9IM1 K+/toabMA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jWn2S-0004Hy-Et; Thu, 07 May 2020 20:22:36 +0000 Received: from www62.your-server.de ([213.133.104.62]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jWn2Q-0004HT-1B for linux-arm-kernel@lists.infradead.org; Thu, 07 May 2020 20:22:35 +0000 Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jWn26-0001Dl-GF; Thu, 07 May 2020 22:22:14 +0200 Received: from [178.195.186.98] (helo=pc-9.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jWn21-0002Yj-BR; Thu, 07 May 2020 22:22:09 +0200 Subject: Re: [RFC PATCH bpf-next 3/3] bpf, arm64: Optimize ADD,SUB,JMP BPF_K using arm64 add/sub immediates To: Luke Nelson , bpf@vger.kernel.org References: <20200507010504.26352-1-luke.r.nels@gmail.com> <20200507010504.26352-4-luke.r.nels@gmail.com> From: Daniel Borkmann Message-ID: Date: Thu, 7 May 2020 22:22:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200507010504.26352-4-luke.r.nels@gmail.com> Content-Language: en-US X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.2/25805/Thu May 7 14:14:46 2020) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200507_132234_073343_F479AAE7 X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Song Liu , Zi Shen Lim , Alexei Starovoitov , Will Deacon , Marc Zyngier , John Fastabend , clang-built-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Yonghong Song , Andrii Nakryiko , Xi Wang , Luke Nelson , Torsten Duwe , KP Singh , Thomas Gleixner , Allison Randal , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Enrico Weigelt , Martin KaFai Lau , Christoffer Dall Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/7/20 3:05 AM, Luke Nelson wrote: > The current code for BPF_{ADD,SUB} BPF_K loads the BPF immediate to a > temporary register before performing the addition/subtraction. Similarly, > BPF_JMP BPF_K cases load the immediate to a temporary register before > comparison. > > This patch introduces optimizations that use arm64 immediate add, sub, > cmn, or cmp instructions when the BPF immediate fits. If the immediate > does not fit, it falls back to using a temporary register. > > Example of generated code for BPF_ALU64_IMM(BPF_ADD, R0, 2): > > without optimization: > > 24: mov x10, #0x2 > 28: add x7, x7, x10 > > with optimization: > > 24: add x7, x7, #0x2 > > The code could use A64_{ADD,SUB}_I directly and check if it returns > AARCH64_BREAK_FAULT, similar to how logical immediates are handled. > However, aarch64_insn_gen_add_sub_imm from insn.c prints error messages > when the immediate does not fit, and it's simpler to check if the > immediate fits ahead of time. > > Co-developed-by: Xi Wang > Signed-off-by: Xi Wang > Signed-off-by: Luke Nelson Same here: Acked-by: Daniel Borkmann Thanks! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel