From patchwork Fri Jan 26 16:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nafees Ahmed Abdul X-Patchwork-Id: 13532870 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 5AA3BC47422 for ; Fri, 26 Jan 2024 16:15:09 +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: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:In-Reply-To:References: List-Owner; bh=jtSE/dI2TCKm45n6awbhbW4kYHNKjiH8uiYXgSt1RYA=; b=a907/NQP0+GWRy Hfi4ANClUPsaTrIdRtTSkcTY0Y+x7pvccIk2MWRZfWrPwwx+uFDviANsY1P9aGM/S9k8mmMl3dLKx BgwVkcmbFjkPEHL3pcYgRKKAOgFtliF2NU4D2rQxgUmDiL48u13WTko/evLFE5r70eAo/49eBDjT5 3sTZCWhwMC6PolUvAVPmFVROo7p5weeE4UWE6JvTQDjsN70WrrP0PDtCcasjdIswabOOeGk0P8mL/ xqrvlBSFjPH37u7wuHk9HTpclVeaG2miapumCDvO05H+Wyu2PXahrlLu++IJ+E3CB4dARCP1RnAt4 qRoV4JR5pNR7uvedDEbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTOr3-00000004dTX-2Ljd; Fri, 26 Jan 2024 16:14:57 +0000 Received: from smtp-fw-9106.amazon.com ([207.171.188.206]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTOr0-00000004dT2-3dH5 for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2024 16:14:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1706285694; x=1737821694; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=hbcbM0mgNcDJbhb7W4hs5AmcbcKugP3gW9Cef5JE+nk=; b=jLBRpH6XlJUJAggPjOZVv/ruzpxajih0w0bI8y3KpgOHq2UDx47JeuUC cPZedM1r+ku2YcqeGvFdEc0JxcbJ4R7NErwb4ZQTATIOHrr1PVt9dbWfz Buef8+M9f/5/aVo4LoLlwBsmj1ik5sC87NXEyBQRxb0uhda/FQsI02m7e Y=; X-IronPort-AV: E=Sophos;i="6.05,216,1701129600"; d="scan'208";a="700058638" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-m6i4x-9fe6ad2f.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-9106.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 16:14:50 +0000 Received: from smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev (iad7-ws-svc-p70-lb3-vlan3.iad.amazon.com [10.32.235.38]) by email-inbound-relay-iad-1a-m6i4x-9fe6ad2f.us-east-1.amazon.com (Postfix) with ESMTPS id 7140681008; Fri, 26 Jan 2024 16:14:49 +0000 (UTC) Received: from EX19MTAUWB002.ant.amazon.com [10.0.38.20:59355] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.23.214:2525] with esmtp (Farcaster) id 46e11d95-d3e9-481c-b61d-bdaf55ff7a2f; Fri, 26 Jan 2024 16:14:48 +0000 (UTC) X-Farcaster-Flow-ID: 46e11d95-d3e9-481c-b61d-bdaf55ff7a2f Received: from EX19D045UWA002.ant.amazon.com (10.13.139.12) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 16:14:47 +0000 Received: from EX19MTAUEC001.ant.amazon.com (10.252.135.222) by EX19D045UWA002.ant.amazon.com (10.13.139.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Fri, 26 Jan 2024 16:14:47 +0000 Received: from dev-dsk-nafeabd-1e-f694a9f3.us-east-1.amazon.com (172.19.189.43) by mail-relay.amazon.com (10.252.135.200) with Microsoft SMTP Server id 15.2.1118.40 via Frontend Transport; Fri, 26 Jan 2024 16:14:47 +0000 Received: by dev-dsk-nafeabd-1e-f694a9f3.us-east-1.amazon.com (Postfix, from userid 13250533) id 5346DA232; Fri, 26 Jan 2024 16:14:47 +0000 (UTC) From: Nafees Ahmed Abdul To: , CC: , Subject: [RFC] arm64: use different compiler inlining options for arm64 kernel builds Date: Fri, 26 Jan 2024 16:13:30 +0000 Message-ID: <20240126161330.1483-1-nafeabd@amazon.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_081454_979913_815E1326 X-CRM114-Status: GOOD ( 15.32 ) 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 It was observed that compiling the kernel with following compiler inlining options has showed performance improvement up to 4% across tested workloads. Below is the table with performance gains compared to default kernel on few of the workloads we tested. | Workload | Improvement | |-----------|-------------| | Nginx | 4% | | MongoDB | 3% | | Memcached | 3% | | Redis | 2% | The selected options increase inlining of the kernel functions which is positively impacting workload performance. We have arrived at these values by reviewing the options used with the gcc compiler at various optimization levels such as O1, O2 and O3. Benchmarking was performed on AWS Graviton 2/3 generation instances on 5.10 and 6.1 longterm supported kernels with GCC versions 10 and 11. Patch also adds noinline attribute to couple of functions for existing kselftests to pass on ftrace target. Signed-off-by: Nafees Ahmed Abdul --- arch/arm64/Makefile | 6 ++++++ fs/namei.c | 2 +- fs/open.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 47ecc4cff9d2..4ad2c7d0008d 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -101,6 +101,12 @@ KBUILD_CFLAGS += -Wa,-march=$(asm-arch) \ -DARM64_ASM_ARCH='"$(asm-arch)"' endif +ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE +KBUILD_CFLAGS += --param=early-inlining-insns=14 --param=inline-heuristics-hint-percent=600 \ + --param=inline-min-speedup=15 --param=max-inline-insns-auto=30 \ + --param=max-inline-insns-single=200 +endif + ifeq ($(CONFIG_SHADOW_CALL_STACK), y) KBUILD_CFLAGS += -ffixed-x18 endif diff --git a/fs/namei.c b/fs/namei.c index 71c13b2990b4..58e8f462c137 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4445,7 +4445,7 @@ SYSCALL_DEFINE1(unlink, const char __user *, pathname) * On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply passs @nop_mnt_idmap. */ -int vfs_symlink(struct mnt_idmap *idmap, struct inode *dir, +noinline vfs_symlink(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, const char *oldname) { int error; diff --git a/fs/open.c b/fs/open.c index 02dc608d40d8..afec5d0e30d3 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1421,7 +1421,7 @@ struct file *file_open_root(const struct path *root, } EXPORT_SYMBOL(file_open_root); -static long do_sys_openat2(int dfd, const char __user *filename, +static noinline long do_sys_openat2(int dfd, const char __user *filename, struct open_how *how) { struct open_flags op;