From patchwork Mon Aug 26 07:16:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Kuohai X-Patchwork-Id: 13777286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9ABE1C5321D for ; Mon, 26 Aug 2024 07:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=6vPUFk62wOdG58vXHN0xLjFm2LVZePMzLv62oPt9cYk=; b=aQizPfbIW/4QKyEcOVKSnsRsg1 wLcBSiq7GWtO4Egxq3fafeIhZ00xCweZWXd6ybXaS+yd1mOmi3k9+HN0uX8tBpPOpDD6oqqUT6y+e VG7C7mh4AS8y9xg1CV4DEJto3QIGKjcH1A8rG46tE4KVhGVSvY3FmmO5A+djCyPsgRb6f3KrWimZV gXOak89vzBaxlByBLpuZv8Ei5MuFzAH3n+bDF3jZqj4mzn9MnNN0y+Hh7YOYG2etvOxtP0duV8Rtr 1ffaW4W8wnoS8qmznwhhlwDC4Rp48kkj/wApajDuBDa5HKw1gNLrEcQTS89NKSnFNPkT0O9BZ84Mj vWH6BOMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siTrJ-00000006Cuk-1rVD; Mon, 26 Aug 2024 07:09:49 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siToH-00000006CDQ-08WE for linux-arm-kernel@bombadil.infradead.org; Mon, 26 Aug 2024 07:06:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=6vPUFk62wOdG58vXHN0xLjFm2LVZePMzLv62oPt9cYk=; b=P4M0kYGJ5axycwTliGbq3C84k6 8q+L3a2DgZLOCXxHzErDJw9ZhZ2uNZ5XIounkUdLAJpKrVzV8OoiV34jpgEBVGyTqcZ/uhDuHHazJ 1UcBpnlmbyVVybG76iuhxGYGKwPcBZ2YYTEYMDmidtD8nrJMuutDj2VF0Cm8D4lhvgUrkPIxYN9tA 33xdZ/xT4mCIO68DIaNUD7jxRD0JydpK4G4mQ+VHwEYNQryg9C/kkOcUijwanX3gcA/k/N49YvKuN O0eBIqOGOWINeyB0279WqBQXrAKbkr4qnejKs3PYZ3CmF4Dx/idT3qqiA0g+fJdGpQQ4OgCTCz0VK kfRc3SRA==; Received: from dggsgout11.his.huawei.com ([45.249.212.51]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siToB-0000000AZYi-1912 for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 07:06:39 +0000 Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4WshXj5Hyzz4f3l22 for ; Mon, 26 Aug 2024 15:05:57 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 19A181A0568 for ; Mon, 26 Aug 2024 15:06:13 +0800 (CST) Received: from k01.huawei.com (unknown [10.67.174.197]) by APP2 (Coremail) with SMTP id Syh0CgAH8L5jKcxmTz_5Cg--.20237S2; Mon, 26 Aug 2024 15:06:12 +0800 (CST) From: Xu Kuohai To: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Puranjay Mohan , Leon Hwang , Catalin Marinas , Will Deacon Subject: [PATCH bpf-next 0/2] bpf, arm64: Simplify jited prologue/epilogue Date: Mon, 26 Aug 2024 15:16:22 +0800 Message-Id: <20240826071624.350108-1-xukuohai@huaweicloud.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CM-TRANSID: Syh0CgAH8L5jKcxmTz_5Cg--.20237S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uFyfGFyxXFy5tF17XFy7KFg_yoW8XryUp3 W3XF4aqr1Du393WrZxJr43JFyrXF4fta4UXa47XF10y34UuF98uF1Sga4fKFWrJFyIvF45 WrW8Cr45Cr98Z3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyKb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI 7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxV Cjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY 6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6x AIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY 1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUF1v3UUUUU X-CM-SenderInfo: 50xn30hkdlqx5xdzvxpfor3voofrz/ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_080637_416497_4623AE2E X-CRM114-Status: UNSURE ( 7.04 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Xu Kuohai The arm64 jit blindly saves/restores all callee-saved registers, making the jited result looks a bit too compliated. For example, for an empty prog, the jited result is: 0: bti jc 4: mov x9, lr 8: nop c: paciasp 10: stp fp, lr, [sp, #-16]! 14: mov fp, sp 18: stp x19, x20, [sp, #-16]! 1c: stp x21, x22, [sp, #-16]! 20: stp x26, x25, [sp, #-16]! 24: mov x26, #0 28: stp x26, x25, [sp, #-16]! 2c: mov x26, sp 30: stp x27, x28, [sp, #-16]! 34: mov x25, sp 38: bti j // tailcall target 3c: sub sp, sp, #0 40: mov x7, #0 44: add sp, sp, #0 48: ldp x27, x28, [sp], #16 4c: ldp x26, x25, [sp], #16 50: ldp x26, x25, [sp], #16 54: ldp x21, x22, [sp], #16 58: ldp x19, x20, [sp], #16 5c: ldp fp, lr, [sp], #16 60: mov x0, x7 64: autiasp 68: ret Clearly, there is no need to save/restore unused callee-saved registers. This patch does this change, making the jited image to only save/restore the callee-saved registers it uses. Now the jited result of empty prog is: 0: bti jc 4: mov x9, lr 8: nop c: paciasp 10: stp fp, lr, [sp, #-16]! 14: mov fp, sp 18: stp xzr, x26, [sp, #-16]! 1c: mov x26, sp 20: bti j // tailcall target 24: mov x7, #0 28: ldp xzr, x26, [sp], #16 2c: ldp fp, lr, [sp], #16 30: mov x0, x7 34: autiasp 38: ret Xu Kuohai (2): bpf, arm64: Get rid of fpb bpf, arm64: Avoid blindly saving/restoring all callee-saved registers arch/arm64/net/bpf_jit_comp.c | 394 +++++++++++++++++----------------- 1 file changed, 192 insertions(+), 202 deletions(-) Acked-by: Puranjay Mohan