Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1039313ybj; Thu, 7 May 2020 13:21:36 -0700 (PDT) X-Google-Smtp-Source: APiQypKahrxUlNbRq1GGKpTAszilOnlgCca1iKALUhf4tekKBznRS/fLXWptDZAUEAJ1LUjkP/Kw X-Received: by 2002:a50:f390:: with SMTP id g16mr13263776edm.211.1588882896578; Thu, 07 May 2020 13:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588882896; cv=none; d=google.com; s=arc-20160816; b=zyln7dzJ8rlKyxfXSRI429jtE5koyxQJol5Y15UGmfD8wMzI85GoG2h3vRzTDA+enx GzniMITADzAe6RYFBX+wRmebAYvVsZYZK4AtcJxcioRONbDL9PTwZkIbGJ8DL35/FbSA vEVuXu0Q0F/689NhsBNlD5a6aJB2lrEdP+JG2FHpFqY0Zb3tcdAsuW8B0rmyVZpFnWqM nzT4Dz6ZiTcLFvveDcak1bzhFYtCWpTVRrZBhWDJMYAlqcEwcGjQD0fCJ2rK5kNL4u34 wwWQQlMKYHLmlk0EIuHGrfRuIwdTmqYjwDVr93Zhbh9tLUUm4VSRbEfh/ko9jRIY1GrY tV/A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=DQ4cukI1zpZScWOk4NGYdJ/llAFzl57UcopCz2+B6f8=; b=qnjqmYzfpgBMfWZnuVb/aCuZ6mo0YKBJ1XTCiu8Tgp7dQMPHTQEHpBiZ+I4EbgE6ip naI7a/1r/PA/GQSIrlpv0U2GRQhMxVL0x+Fzwd/AIziNOrIm/8p6I0pfJkIZNmVhJi3Y FslzZbqdRgXI2N3Xwk8SXlFzBfsTzlgoPmQSzUOLCw7BGOIIHNgibeVhvKSesc7vfy9W g6Y+gVhW2eNBKznqQCbwdB6u6h3Jwmt6RUHtjLx8XdInGwT91yvSw0HPu+IizuJpVHG/ o2+uRbEUsUaI4c/EieGrtUSK9m8VBbN0XDGStlEkRKaDSan9kWYfMVNrgWvGdHQ6T01q xaRA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si3811694edr.227.2020.05.07.13.21.13; Thu, 07 May 2020 13:21:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbgEGUTm (ORCPT + 99 others); Thu, 7 May 2020 16:19:42 -0400 Received: from www62.your-server.de ([213.133.104.62]:33822 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbgEGUTl (ORCPT ); Thu, 7 May 2020 16:19:41 -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 1jWmzZ-0000uo-43; Thu, 07 May 2020 22:19:37 +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 1jWmzY-000Pq5-CQ; Thu, 07 May 2020 22:19:36 +0200 Subject: Re: [RFC PATCH bpf-next 2/3] bpf, arm64: Optimize AND,OR,XOR,JSET BPF_K using arm64 logical 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 , Alexios Zavras , Thomas Gleixner , Marc Zyngier , Christoffer Dall , 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-3-luke.r.nels@gmail.com> From: Daniel Borkmann Message-ID: <2b05950b-5f7a-e5e7-81fe-27703c3ef77f@iogearbox.net> Date: Thu, 7 May 2020 22:19:35 +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-3-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_{AND,OR,XOR,JSET} BPF_K loads the immediate to > a temporary register before use. > > This patch changes the code to avoid using a temporary register > when the BPF immediate is encodable using an arm64 logical immediate > instruction. If the encoding fails (due to the immediate not being > encodable), it falls back to using a temporary register. > > Example of generated code for BPF_ALU32_IMM(BPF_AND, R0, 0x80000001): > > without optimization: > > 24: mov w10, #0x8000ffff > 28: movk w10, #0x1 > 2c: and w7, w7, w10 > > with optimization: > > 24: and w7, w7, #0x80000001 > > Since the encoding process is quite complex, the JIT reuses existing > functionality in arch/arm64/kernel/insn.c for encoding logical immediates > rather than duplicate it in the JIT. > > Co-developed-by: Xi Wang > Signed-off-by: Xi Wang > Signed-off-by: Luke Nelson Great find, thanks! Given Will wanted to queue them: Acked-by: Daniel Borkmann