From patchwork Sat Jan 6 14:55:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 185639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp143960dyq; Sat, 6 Jan 2024 06:56:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpaSIs7EKo7mDG5rW1iy84zGXGV5FiEbWdxf//PMxx2dxzvL2liXBN02C3GNGBf20y7/lS X-Received: by 2002:a17:906:4714:b0:a28:d4eb:4282 with SMTP id y20-20020a170906471400b00a28d4eb4282mr387135ejq.82.1704552965985; Sat, 06 Jan 2024 06:56:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704552965; cv=none; d=google.com; s=arc-20160816; b=I3E1jQBJUuvI2UNe+YetNsB7WqdXBgMkC6Kpbqsk9g5D7xAXGkE8g/5EPfPi6aR3Kf Hq89rUlCfKmZ05EvAzfT4cY1R1Z4jxG2xPkKxeZG+vS9zhqiHzpNtxRzx0tcMUnuXIF+ wgKEauVadEjUAcusFsyS/4l64LR2bFfuhJM7htrJIH8A/81vRwLDy/ZcpJlJ4TgZfNPe Q911ViP9RmkwsSnGO8Z/Q9ZPSg9MPNGpNVYk/BKMdHCXwSh3PEk07Z81/Q/Fdp/e7R4R APVobH5KvO5Ef09T3p0uYXP4Ri50q/24Ro13p/Y8fk87WoRhgCB5G2ot9D2YEOe/tfNt VrHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=+us7dZKVZS9L6t4yGXkmcCaqOu2T3nbg3sMWdwmhwns=; fh=7h184BFsaTrO/z01NDeK+LiSCBiT9t/aoDCzgSrDDy8=; b=egy315J+I8KAXrWFqPOdr6NQ0liGH5Vse2dJnRIHVosbvXN8U6vxTM8StzJQJM2u1I lVOyKAPTmfInv8c/xWD8vMfEIGbXokM7N5xqCpBZQUYKQrPaqc6X1ao7ATb6VHMsR4UH DotCsOTq3fSBBZio/kJxp8HH6VuaHKJe/S4vfRY2gjgfnzGPEQQhGEhTtE+fHNBjFOf3 P426qdgHNhNETWmWM3/qbxqfCgg47x5eDxUpwT2cl0ZrYwNda7pFTRuGnVTQZS8aUGst nFHWWk1G7fwoGcpyaRLhYim9nrEYPwl9RUxgvtcSwrxu8fd8lZMn4DCbB1cKcZxrAGEx ONOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18608-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18608-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ft14-20020a170907800e00b00a26ab945bcbsi1480960ejc.113.2024.01.06.06.56.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 06:56:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18608-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18608-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18608-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 964DC1F21096 for ; Sat, 6 Jan 2024 14:56:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35EE28C15; Sat, 6 Jan 2024 14:55:32 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC86479D9; Sat, 6 Jan 2024 14:55:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52ABBC433C7; Sat, 6 Jan 2024 14:55:28 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, Huacai Chen Subject: [PATCH] LoongArch: Change SHMLBA from SZ_64K to PAGE_SIZE Date: Sat, 6 Jan 2024 22:55:01 +0800 Message-Id: <20240106145501.3370364-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787353331017983410 X-GMAIL-MSGID: 1787353331017983410 LoongArch has hardware page coloring for L1 Cache, so we don't have cache aliases. But SFB (Store Fill Buffer) still has aliases. So we define SHMLBA to SZ_64K previously. But there are losts of applications use PAGE_SIZE rather than SHMLBA to mmap() file pages and shared pages. Of course we can fix them one by one, but not easy. On the other hand, we can simply disable SFB for 4KB page size to fix cache alias (there will be performance decrease, but acceptable), and in future we will fix SFB in hardware. So we can safely define SHMLBA to PAGE_SIZE (use the generic shmparam.h) to make life easier. Signed-off-by: Huacai Chen --- arch/loongarch/include/asm/shmparam.h | 12 ------------ arch/loongarch/kernel/head.S | 10 ++++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 arch/loongarch/include/asm/shmparam.h diff --git a/arch/loongarch/include/asm/shmparam.h b/arch/loongarch/include/asm/shmparam.h deleted file mode 100644 index c9554f48d2df..000000000000 --- a/arch/loongarch/include/asm/shmparam.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (C) 2020-2022 Loongson Technology Corporation Limited - */ -#ifndef _ASM_SHMPARAM_H -#define _ASM_SHMPARAM_H - -#define __ARCH_FORCE_SHMLBA 1 - -#define SHMLBA SZ_64K /* attach addr a multiple of this */ - -#endif /* _ASM_SHMPARAM_H */ diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index 53b883db0786..be187e99d358 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -75,6 +75,11 @@ SYM_CODE_START(kernel_entry) # kernel entry point la.pcrel t0, fw_arg2 st.d a2, t0, 0 +#ifdef CONFIG_PAGE_SIZE_4KB + li.d t0, 0 + li.d t1, CSR_STFILL + csrxchg t0, t1, LOONGARCH_CSR_IMPCTL1 +#endif /* KSave3 used for percpu base, initialized as 0 */ csrwr zero, PERCPU_BASE_KS /* GPR21 used for percpu base (runtime), initialized as 0 */ @@ -127,6 +132,11 @@ SYM_CODE_START(smpboot_entry) JUMP_VIRT_ADDR t0, t1 +#ifdef CONFIG_PAGE_SIZE_4KB + li.d t0, 0 + li.d t1, CSR_STFILL + csrxchg t0, t1, LOONGARCH_CSR_IMPCTL1 +#endif /* Enable PG */ li.w t0, 0xb0 # PLV=0, IE=0, PG=1 csrwr t0, LOONGARCH_CSR_CRMD