Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5312243ybl; Tue, 4 Feb 2020 11:33:04 -0800 (PST) X-Google-Smtp-Source: APXvYqziFFB5RnctWdHVsaQAq8jCUypa924nH+mVSApD98euAGMVV2eUAWuB1cZ5XlB6/Rfx2p8P X-Received: by 2002:a05:6830:10d5:: with SMTP id z21mr24555386oto.30.1580844784459; Tue, 04 Feb 2020 11:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580844784; cv=none; d=google.com; s=arc-20160816; b=nAK0AaXIaLUhweRgZfYBmGEYCsRJnBMsjYOs3NLFb98FCOGmDRXSvoe+iHSArkRECU riANftuOa4GkMZRKXBvE6kD3jKSYRI2r1kCTsEA8wW9F/2PppNGHFm66wbEggtRTcEkP K9kzha29J4++2WfFxMgp6PIOKmf03Apf/X/lKvSnW9l+I42oBF7t5L9VqwxuV+oB5T/M Lhf/Br0qxTMhoLeUQxgCqkkrjD/8wrbp2W9r56y6b3WUV3xYqB9cu8lT806FdKUbET9T QTncS72PXeRF0tx/2w3ptwuBpXN787sHvcu/4H9WScP9aWqOu75JN2M0aOPizEcqNF/D Wnhg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UapTR/Swn2AywRKzX/GSR/rd23O04e9h6Fgs9p2msUo=; b=IyTQeTAScXtO/qOrU6S7DHubqkkH6nersS0t4dbca9PWAfcaOMpbcxxhIxJxIn4kzG 58o1iGG5SjjcjfXeZfY0eRJmfq4eW5ObFmzFKr93KSLOL4X+bX191hLiUPUwpXWTCyMw T0MYUumz60ZfYt2RoRFa252fd0YHf8E7Ss9fB+kgARTC0vynR+rHRKdSgFb9B2bp46bd 5T9wLidYvWBCTTFM3HrjNhWww0lc0CHC00oQvzUASY2SJ8F6LTzF83FmW/9wHYLBGz92 zSf1bY1AQwOuq81bidnvM1gwNMd4bOaA1Xxctq/2yjdXrLe8lEZu5UhCE/unBpdTyVvC csZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="o/eOozhV"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m85si10750427oig.158.2020.02.04.11.32.52; Tue, 04 Feb 2020 11:33:04 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="o/eOozhV"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727546AbgBDTag (ORCPT + 99 others); Tue, 4 Feb 2020 14:30:36 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:37992 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727358AbgBDTaf (ORCPT ); Tue, 4 Feb 2020 14:30:35 -0500 Received: by mail-qt1-f194.google.com with SMTP id c24so15288969qtp.5; Tue, 04 Feb 2020 11:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=UapTR/Swn2AywRKzX/GSR/rd23O04e9h6Fgs9p2msUo=; b=o/eOozhV6u7iYKKKZLmW9I9eE+A50S7MONuuj7k/cxVH+dM2FEQTnarK5ohzH6rGvj 0CgNbVzW529C0KjCozjxar2OsHiNfHWDnX2D253V7ISvOQqErGLlZMwIM+CvfvAk/ETr kIN2VYeX2wVepBOg7pBlY3ot6HrDTlJcZar8+SV0kQAuWlb8sPSPR88RhgMETAMeMdzY 5OSNHeIIxUDDbrEHfmSZ+8Tu9uVC1FThvyOAscXaxa6fYkHHiOzH0GdC3vVlVJ72f7F6 bWTdyt9dGFRZE3xFNu6izLDDJf4wFBZDkFrHyopiOWXrfO0v+0bih6u0gyOnJ/ksyvBb 32Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=UapTR/Swn2AywRKzX/GSR/rd23O04e9h6Fgs9p2msUo=; b=D8/fl8ysVBYsuMreGgoJ6g9oyKGASzItM6bd0laCA9V9ifLJ4BDYo16yX+HOJ89Wx9 ev4OMGrQz8B3lIo+REwDINOdPyMzimBl60+YChAaY8km6mGwhkE7SRcxe+a5HJWINCET /gSbzF5eq1cfIJuWr69oMbDzE1Tgku4JuCHvgcaB8wcFCc58ZDQjYi+dh2YOwSrzy4hq SPB8WltlMox/Lw+h6lcbAauddvqOuA7Tk105AaHoPhObtC0SsaQUxn/sHjo7l6TC4xXB 0iuYu6BjVVcg5+3en8jUv1Sx5gsQAPAeyXwI2tuR+ibNpSlDq+6yPMIi/s4k57edI73i t+mA== X-Gm-Message-State: APjAAAUwGuPR9c796TUq/CO98Ra/ZUbWeVZPmMI7j/5Ex1Mk8Z+CRWwj eynK3SgXNoEVQvzqeyB+b0yDzROszrVUQ3YkluE= X-Received: by 2002:ac8:554b:: with SMTP id o11mr30093106qtr.36.1580844634484; Tue, 04 Feb 2020 11:30:34 -0800 (PST) MIME-Version: 1.0 References: <20200128021145.36774-1-palmerdabbelt@google.com> In-Reply-To: <20200128021145.36774-1-palmerdabbelt@google.com> From: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Date: Tue, 4 Feb 2020 20:30:23 +0100 Message-ID: Subject: Re: arm64: bpf: Elide some moves to a0 after calls To: Palmer Dabbelt Cc: Daniel Borkmann , Alexei Starovoitov , zlim.lnx@gmail.com, catalin.marinas@arm.com, will@kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , Shuah Khan , Netdev , bpf , linux-arm-kernel@lists.infradead.org, LKML , linux-kselftest@vger.kernel.org, clang-built-linux@googlegroups.com, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Jan 2020 at 03:14, Palmer Dabbelt wro= te: > > There's four patches here, but only one of them actually does anything. = The > first patch fixes a BPF selftests build failure on my machine and has alr= eady > been sent to the list separately. The next three are just staged such th= at > there are some patches that avoid changing any functionality pulled out f= rom > the whole point of those refactorings, with two cleanups and then the ide= a. > > Maybe this is an odd thing to say in a cover letter, but I'm not actually= sure > this patch set is a good idea. The issue of extra moves after calls came= up as > I was reviewing some unrelated performance optimizations to the RISC-V BP= F JIT. > I figured I'd take a whack at performing the optimization in the context = of the > arm64 port just to get a breath of fresh air, and I'm not convinced I lik= e the > results. > > That said, I think I would accept something like this for the RISC-V port > because we're already doing a multi-pass optimization for shrinking funct= ion > addresses so it's not as much extra complexity over there. If we do that= we > should probably start puling some of this code into the shared BPF compil= er, > but we're also opening the doors to more complicated BPF JIT optimization= s. > Given that the BPF JIT appears to have been designed explicitly to be > simple/fast as opposed to perform complex optimization, I'm not sure this= is a > sane way to move forward. > Obviously I can only speak for myself and the RISC-V JIT, but given that we already have opened the door for more advanced translations (branch relaxation e.g.), I think that this makes sense. At the same time we don't want to go all JVM on the JITs. :-P > I figured I'd send the patch set out as more of a question than anything = else. > Specifically: > > * How should I go about measuring the performance of these sort of > optimizations? I'd like to balance the time it takes to run the JIT wi= th the > time spent executing the program, but I don't have any feel for what re= al BPF > programs look like or have any benchmark suite to run. Is there someth= ing > out there this should be benchmarked against? (I'd also like to know t= hat to > run those benchmarks on the RISC-V port.) If you run the selftests 'test_progs' with -v it'll measure/print the execution time of the programs. I'd say *most* BPF program invokes a helper (via call). It would be interesting to see, for say the selftests, how often the optimization can be performed. > * Is this the sort of thing that makes sense in a BPF JIT? I guess I've = just > realized I turned "review this patch" into a way bigger rabbit hole tha= n I > really want to go down... > I'd say 'yes'. My hunch, and the workloads I've seen, BPF programs are usually loaded, and then resident for a long time. So, the JIT time is not super critical. The FB/Cilium folks can definitely provide a better sample point, than my hunch. ;-) Bj=C3=B6rn