From patchwork Thu Dec 8 09:12:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 13068158 X-Patchwork-Delegate: palmer@dabbelt.com 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 0E253C4332F for ; Thu, 8 Dec 2022 09:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hyKHys7CJ+E/XNSeLqo7kUI5lVtm0y8opQTqTckBQcQ=; b=BqJNJt/ArQFuIv +Ql/OW9lnVfPxuVLAA285vMLXm9vfEIfAGF24ofoJWIIC2WWuXxGXyPFRftri/u3MMENwiFJrrI0t u3C8PvS0lQVwoNzDCG9dQK2SHgkJR7dEAAwEVcoHORkK6eE1poF+t8Qi4etyOq5am8eeZ6FmcNAUc ajTIZPLFP/OVX7sJEjX+MWwC2XJIG0vcSuy31v7LpJYsF0Y+HrMm/J/nxDv4+5L7yVDdINAl+agrD 7i0TePSE3Z6MZrXFRcAQsoPPVWJsX12vDmTybSi0j9Vea7HkFqvNPvUi19XXO82CZcWjgLIQQ7PF9 vcrNe/EFLd7Q7LxRiFHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3DFf-00Av6E-NC; Thu, 08 Dec 2022 09:31:35 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3Cxo-00AhGW-1O for linux-riscv@lists.infradead.org; Thu, 08 Dec 2022 09:13:10 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DC27861E2A; Thu, 8 Dec 2022 09:13:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 010F6C433D6; Thu, 8 Dec 2022 09:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670490786; bh=K44IU5zSr+xRSYeCBFFHSvlbL/P6QS9pgaMT4XAkl6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/UXaRQrA35brDQUIPN4/w00QBDpafph2xKZwq8z0HqGZ4PW7e5T0MHGFPIHZ1Q9S cLnV7GzPgB6gQYPh2gA8Z7f44uiJD4ZLbfIzl1bG1CSmgAJ0Sen2gMb6QyVzuM45Qh 0cuOomAjJQRsMXS1hJ/ljDrItRZmaU4nv7E3w63Jfuu1DmdYNIxFYEx4WSj8bEGgYv ih6DLGzKbzcn/+2AH6hTGyXe2hHNhEzCBzC1DvqBeMZlRdFkf0JTfurz/8AwiOKya8 cts3o+LuJDIxIbL9LPfSYXXA4uX9+6hrJMBT/qr0JJiHkZXRBdDLM7MSDmfc0XIuOY RT4Q3QbPLdfDA== From: guoren@kernel.org To: anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, conor.dooley@microchip.com, heiko@sntech.de, rostedt@goodmis.org, mhiramat@kernel.org, jolsa@redhat.com, bp@suse.de, jpoimboe@kernel.org, suagrfillet@gmail.com, andy.chiu@sifive.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guo Ren , Guo Ren Subject: [PATCH -next V5 2/7] riscv: ftrace: Remove wasted nops for !RISCV_ISA_C Date: Thu, 8 Dec 2022 04:12:39 -0500 Message-Id: <20221208091244.203407-3-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221208091244.203407-1-guoren@kernel.org> References: <20221208091244.203407-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221208_011308_190139_8F5B39A7 X-CRM114-Status: UNSURE ( 7.66 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Guo Ren When CONFIG_RISCV_ISA_C=n, -fpatchable-function-entry=8 would generate more nops than we expect. Because it treat nop opcode as 0x00000013 instead of 0x0001. Dump of assembler code for function dw_pcie_free_msi: 0xffffffff806fce94 <+0>: sd ra,-8(sp) 0xffffffff806fce98 <+4>: auipc ra,0xff90f 0xffffffff806fce9c <+8>: jalr -684(ra) # 0xffffffff8000bbec 0xffffffff806fcea0 <+12>: ld ra,-8(sp) 0xffffffff806fcea4 <+16>: nop /* wasted */ 0xffffffff806fcea8 <+20>: nop /* wasted */ 0xffffffff806fceac <+24>: nop /* wasted */ 0xffffffff806fceb0 <+28>: nop /* wasted */ 0xffffffff806fceb4 <+0>: addi sp,sp,-48 0xffffffff806fceb8 <+4>: sd s0,32(sp) 0xffffffff806fcebc <+8>: sd s1,24(sp) 0xffffffff806fcec0 <+12>: sd s2,16(sp) 0xffffffff806fcec4 <+16>: sd s3,8(sp) 0xffffffff806fcec8 <+20>: sd ra,40(sp) 0xffffffff806fcecc <+24>: addi s0,sp,48 Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 1c8ec656e916..36cc609c5d03 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -11,7 +11,11 @@ LDFLAGS_vmlinux := ifeq ($(CONFIG_DYNAMIC_FTRACE),y) LDFLAGS_vmlinux := --no-relax KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY +ifeq ($(CONFIG_RISCV_ISA_C),y) CC_FLAGS_FTRACE := -fpatchable-function-entry=8 +else + CC_FLAGS_FTRACE := -fpatchable-function-entry=4 +endif endif ifeq ($(CONFIG_CMODEL_MEDLOW),y)