[PATCH] LoongArch: Use the generic shmlab.h.
caiyinyu
caiyinyu@loongson.cn
Thu Sep 11 02:20:08 GMT 2025
gentle ping.
在 2025/9/9 下午3:03, caiyinyu 写道:
> The shmlba.h file related to the LoongArch architecture was introduced
> in commit 3eed5f3a1ee to address the mismatch in the SHMLBA definition
> between glibc and the kernel. See [1]. The SHMLBA definition was later
> updated in commit d23b77953f5a. See [2]. Now, we adopt the definition
> from the common layer.
>
> [1]:
> commit 3eed5f3a1ee356969afb403a1cf18d06f8d2d98a
> Author: caiyinyu <caiyinyu@loongson.cn>
> Date: Thu May 25 17:01:11 2023 +0800
>
> LoongArch: Fix inconsistency in SHMLBA macro values between glibc and kernel
>
> The LoongArch glibc was using the value of the SHMLBA macro from common code,
> which is __getpagesize() (16k), but this was inconsistent with the value of
> the SHMLBA macro in the kernel, which is SZ_64K (64k). This caused several
> shmat-related tests in LTP (Linux Test Project) to fail. This commit fixes
> the issue by ensuring that the glibc's SHMLBA macro value matches the value
> used in the kernel like other architectures.
>
> [2]:
> commit d23b77953f5a4fbf94c05157b186aac2a247ae32
> Author: Huacai Chen <chenhuacai@kernel.org>
> Date: Wed Jan 17 12:43:08 2024 +0800
>
> LoongArch: Change SHMLBA from SZ_64K to PAGE_SIZE
>
> 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: caiyinyu <caiyinyu@loongson.cn>
> Reported-by: lixing <lixing@loongson.cn>
> ---
> .../unix/sysv/linux/loongarch/bits/shmlba.h | 24 -------------------
> 1 file changed, 24 deletions(-)
> delete mode 100644 sysdeps/unix/sysv/linux/loongarch/bits/shmlba.h
>
> diff --git a/sysdeps/unix/sysv/linux/loongarch/bits/shmlba.h b/sysdeps/unix/sysv/linux/loongarch/bits/shmlba.h
> deleted file mode 100644
> index e74644d460..0000000000
> --- a/sysdeps/unix/sysv/linux/loongarch/bits/shmlba.h
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -/* Define SHMLBA. LoongArch version.
> - Copyright (C) 2023-2025 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public
> - License as published by the Free Software Foundation; either
> - version 2.1 of the License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library; if not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_SHM_H
> -# error "Never use <bits/shmlba.h> directly; include <sys/shm.h> instead."
> -#endif
> -
> -/* Segment low boundary address multiple. */
> -#define SHMLBA 0x10000
More information about the Libc-alpha
mailing list