From patchwork Mon Oct 31 18:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2479368wru; Mon, 31 Oct 2022 11:43:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77O9COUiS29J2U60EUSqpLwZu7KRrBClOYD3fgMeobDCq1tdXS4v80ukOV2QQESrj1kBzZ X-Received: by 2002:aa7:96b6:0:b0:56c:8c22:78f0 with SMTP id g22-20020aa796b6000000b0056c8c2278f0mr15669457pfk.21.1667241780537; Mon, 31 Oct 2022 11:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667241780; cv=none; d=google.com; s=arc-20160816; b=VthDb8dshd3IWSNZ111eWWCCfxsCVxWu2bCo1NyI4aFybqBOTP6FU/b8J7PNA8oNSb zwafYggRnoDAyKXhoLji6mupmygcHTm68FGrBJfioxGYBY7B/aQq7EP79OsR5egk6WEj FddXmm+l9toayzQkxLf1o0TJVsasQ/qv7phNoD6oKT6Sb1r5yakS5iejqJlXI/dTKSi/ Lxi0/Mr2hTTb4xGGEuCIemU7I+W/3ozAagbjuhh/rRThdJMefsHgWhOBTwRCGULcZSUu 06OQG2tBj8FJAtrH+IWYWUnibIisq1Dcsy9Wfxx4vjeOwEjEEM4ioIlmtY38auvrvFhL oytg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xkN/AU8435Q0TYl8BhJEGqy5gjSFdQDymBq8MjDqeIU=; b=Zxz1QvfdKtL0TkgR/Sco2AI5qgGUPoJVP65JhQlWcnUxNGBV3kjzHQxXdB4Bf0Ycpv trRH0VCOiE/EOeGJw7jNJ9nmJYT7gsTiBV6109zqdHK3pGucQo06aVpFqPTJFL3cMRbl O/rS6Cl/eE9LEEfSzvJ6t/Jk8bIp1cN62FBGZ7dK7y5ggjG1IdTA5KHX0veSw8eod+0W EXHreiHKk6RsOBln7V3ye25AwqHizLIHQT60DRFWq5MI4I0epDdgCtlphLBxXWeC2seo xBgHibqVnXoRaEnFMYepWRK2Jf5o9wQx8vubX5aFLvK7L0B+dstGUHNxggmPeGzw7FkC SFWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BjgfbnyQ; 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 v21-20020a170902ca9500b0017ab01a9cb4si8059745pld.317.2022.10.31.11.42.47; Mon, 31 Oct 2022 11:43:00 -0700 (PDT) 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=BjgfbnyQ; 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 S229720AbiJaSj3 (ORCPT + 99 others); Mon, 31 Oct 2022 14:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiJaSj1 (ORCPT ); Mon, 31 Oct 2022 14:39:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B309DDF77 for ; Mon, 31 Oct 2022 11:39:26 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 69A53B819A9 for ; Mon, 31 Oct 2022 18:39:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2632C433C1; Mon, 31 Oct 2022 18:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667241564; bh=It14nDJvTqCUwHf/PuycyXWi6Kbor6f6XNY4NSVwgLE=; h=From:To:Cc:Subject:Date:From; b=BjgfbnyQkRTF0+PkDkOegY6LaF3LwWV0vcYyqsL3bgIUuoftJO1AgskCxUc/LvLSI lazDQKYdKatIhtRYHTVuw+X6AFDD77Lyt4q1Y/SL6I/JX5ELPVSSz9Z71+9UrYP1zX yoYqsnCZFcs7RWp91IiXeSphXoUaimfoHtLHjKYBkginNuaa203nnreCe0/bx4aEor bd4n2WrOnXiP2fP+ucM6f1vNqmPENJI71T19HHkxNPJLLylilyeRKtg3YREQvtpAjw NRxBoDsnrHiW9c/W8ghfPvqdv9zYLUDaj7ChG6MmNFT8x+pjT4v68iO8vxVE1/mPx0 Ivtd/6+a33yzA== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] riscv: vdso: fix build with llvm Date: Tue, 1 Nov 2022 02:29:43 +0800 Message-Id: <20221031182943.2453-1-jszhang@kernel.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Spam-Status: No, score=-8.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?1748229717187771594?= X-GMAIL-MSGID: =?utf-8?q?1748229717187771594?= Even after commit 89fd4a1df829 ("riscv: jump_label: mark arguments as const to satisfy asm constraints"), building with CC_OPTIMIZE_FOR_SIZE + LLVM=1 can reproduce below build error: CC arch/riscv/kernel/vdso/vgettimeofday.o In file included from :4: In file included from lib/vdso/gettimeofday.c:5: In file included from include/vdso/datapage.h:17: In file included from include/vdso/processor.h:10: In file included from arch/riscv/include/asm/vdso/processor.h:7: In file included from include/linux/jump_label.h:112: arch/riscv/include/asm/jump_label.h:42:3: error: invalid operand fo r inline asm constraint 'i' " .option push \n\t" ^ 1 error generated. I think the problem is when "-Os" is passed as CFLAGS, it's removed by "CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os" which is introduced in commit e05d57dcb8c7 ("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace"), thus no optimization at all for vgettimeofday.c arm64 does remove "-Os" as well, but it forces "-O2" after removing "-Os". I compared the generated vgettimeofday.o with "-O2" and "-Os", I think no big performance difference. So let's tell the kbuild not to remove "-Os" rather than follow arm64 style. vdso related performance can be improved a lot when building kernel with CC_OPTIMIZE_FOR_SIZE after this commit, ("-Os" VS no optimization) Fixes: e05d57dcb8c7 ("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace") Signed-off-by: Jisheng Zhang Tested-by: Conor Dooley --- arch/riscv/kernel/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile index f2e065671e4d..84ac0fe612e7 100644 --- a/arch/riscv/kernel/vdso/Makefile +++ b/arch/riscv/kernel/vdso/Makefile @@ -30,7 +30,7 @@ obj-y += vdso.o CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # Disable -pg to prevent insert call site -CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os +CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) # Disable profiling and instrumentation for VDSO code GCOV_PROFILE := n