From patchwork Wed Nov 23 15:39:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 25062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2865171wrr; Wed, 23 Nov 2022 07:44:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf72aUwUpVCTBMDhgf+kvr7qVA6ly/L1ieiWGKACc0TEpQ49CGqmjxgdVon9thTwMP52NZzl X-Received: by 2002:a17:902:ee89:b0:187:1a3f:d54b with SMTP id a9-20020a170902ee8900b001871a3fd54bmr22985908pld.9.1669218242852; Wed, 23 Nov 2022 07:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669218242; cv=none; d=google.com; s=arc-20160816; b=xPusJoY5xKmbQzio5+q5lJj79ucf0ioY2eOJoyzJF12pHlQTcDGlVRZi+SfBnmaTOI crrz6EfDCjSBzX50V0Z67uJEnkv1Xgf0V0EDRoGFcgSPpYceR7VCc6VqbIyDiSv9WVD0 MRNTWCVR0jJtx2zlljyZNy6o9/QQsPlWiNe0u5HIP4zZ02zu586GDhJqOKVQ7tgPrZJC vFMkwNFEVZUULPOlHBlZynUE5vrJkORFAlkQ4ezGdpulkM7JgbA3VvLpcjd5A1KMiDbW wZzd4HhvFe2j8mZJ+w9i528ZW5xfOujAf3/rxIXwBBe8Xi/ckAct4RzTGoRH+fJePaek yjYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bTn6iPIDcY2LEhtM/zl8ZGzeHiW8JICeROFg+tKNG28=; b=OPrmttjw3J7udwNo2s16VbJBJ/EtM2M92Lzc02qhm+fA799CF9VxgGV34Prz+oJcmo 1hO8dRQEDOxh2eMJsYYRqDEIxn3Qm3Vwi2/tjFLhBt8ybs/jqw8yBm8IK6nl7yuyuBl6 l0I5nOESHjYEwmvjjqoiAApa824YvrbixzGAei/jT+EeuDZI+rZ0ExZERkILseDyzkuM ZJH5pS/0vp5uz+AZ6iRKI9xl2jP+hNBrKhSCm0n4tfuN2fbBWXoKmoTOWmsZpFFMQ49x AnCKi6xkbAbXHyMnK9QDImmwkp3ghuhrGcp+XrETLuIppFERK2OzDf4ZDLgLfjCU9sJz 6ntA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vRSCEWck; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a170902c94e00b0017808c0aa8bsi19497742pla.115.2022.11.23.07.43.50; Wed, 23 Nov 2022 07:44:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vRSCEWck; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237899AbiKWPkt (ORCPT + 99 others); Wed, 23 Nov 2022 10:40:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238197AbiKWPkT (ORCPT ); Wed, 23 Nov 2022 10:40:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D42F93CF8 for ; Wed, 23 Nov 2022 07:40:16 -0800 (PST) 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 A0A9461D84 for ; Wed, 23 Nov 2022 15:40:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F281C433C1; Wed, 23 Nov 2022 15:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669218015; bh=K44IU5zSr+xRSYeCBFFHSvlbL/P6QS9pgaMT4XAkl6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vRSCEWckR+qyWbBwXdDb1HYy7iZFIr/KBzkURDpS8Px1CDdbR6wes8ltwnXbGCEm5 wy/VDWMU1S/B1GT1t8GP78yB1Blh8+svK3vMGbH96vKxRK5wBmRwl8KP9NuHQStdkx OvVaDH/8Qv+VTG6Lm3PMgjurnElt7HTx+5SoV9+Axrxou5ocuOFQ7tJW62xGrHxrzr 8NhwJ6NFw/CgeJgzMJsviFaLo48Rv7Ild9yInafyfBP9gdvvU3ItR4L81D6fyhpHwY zkcnpvfxvQK8QJeGDVtIhcDktiq31DSJ+8dlyukYet2l6DDuDOwMiDAucwyFQwZd2Q b+242c6ae8lKA== 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 V3 2/5] riscv: ftrace: Remove wasted nops for !RISCV_ISA_C Date: Wed, 23 Nov 2022 10:39:47 -0500 Message-Id: <20221123153950.2911981-3-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221123153950.2911981-1-guoren@kernel.org> References: <20221123153950.2911981-1-guoren@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750302188235230813?= X-GMAIL-MSGID: =?utf-8?q?1750302188235230813?= 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)