Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp731434rdb; Sat, 6 Jan 2024 06:55:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqdycK3h3nccmmVGZbNJzyGIFmWUN6adDaRQVgpXKhUvTzvWX4C2+skB7/Dmy1aLqzyUX9 X-Received: by 2002:a17:902:da82:b0:1d4:e2b3:9e70 with SMTP id j2-20020a170902da8200b001d4e2b39e70mr450355plx.44.1704552956410; Sat, 06 Jan 2024 06:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704552956; cv=none; d=google.com; s=arc-20160816; b=sTETalMI/9k6CsEzX172T5BaR7zvO7M1o2y02Y3ki+xR+1x91I6RZiC3iIUvw8QlTE Gzn66WpO19GQIoui3J8QY8tJPf1tladHBTgTWBXUFKMuhNHNCM5T5zVwv/3mnCAJ8aKd VG9416uwDhXPo//ee8XnNXshUA1apfgv6jiHZAOGaoOTI/kc1C57JlfzCkYppSAG0p8v oHN/FfVU7XySz5Js0H1Iq7Zu8RM+G28LJRkTiIhNLenOYSDDf/5vjOvoyyCMnLFfZ3xJ 8446dtdNU8/1R3D1gXH3zgYXL8n6oGC8i5DlAgqTPJLNDd9zkCc7a6WrikgW63MNyUQg c3kA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18608-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a4-20020a170902ecc400b001d2e6ed9349si3048877plh.479.2024.01.06.06.55.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 06:55:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-18608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18608-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 159B2283C97 for ; Sat, 6 Jan 2024 14:55:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37CD4847A; Sat, 6 Jan 2024 14:55:31 +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 Content-Transfer-Encoding: 8bit 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 -- 2.39.3