Re-enable patch libhugetlbfs-fix-max-segment-cannot-adopt-the-x86.patch

This commit is contained in:
wangqiang 2024-09-27 11:00:05 +08:00
parent 9897505f8b
commit 86373b1822
3 changed files with 6 additions and 78 deletions

View File

@ -1,42 +0,0 @@
diff -Naur libhugetlbfs-2.16/elflink.c libhugetlbfs-2.16.new//elflink.c
--- libhugetlbfs-2.16/elflink.c 2017-11-09 20:30:38.000000000 -0500
+++ libhugetlbfs-2.16.new//elflink.c 2017-11-09 22:36:56.000000000 -0500
@@ -1131,7 +1131,10 @@
start = ALIGN_DOWN((unsigned long)seg[i].vaddr, hpage_size);
offset = (unsigned long)(seg[i].vaddr - start);
mapsize = ALIGN(offset + seg[i].memsz, hpage_size);
- mmap_flags = MAP_SHARED|MAP_FIXED;
+ if(__hugetlb_opts.share_mapping)
+ mmap_flags = MAP_SHARED|MAP_FIXED;
+ else
+ mmap_flags = MAP_PRIVATE|MAP_FIXED;
/* If requested, make no reservations */
if (__hugetlb_opts.no_reserve)
diff -Naur libhugetlbfs-2.16/hugeutils.c libhugetlbfs-2.16.new//hugeutils.c
--- libhugetlbfs-2.16/hugeutils.c 2013-03-09 21:59:52.000000000 -0500
+++ libhugetlbfs-2.16.new//hugeutils.c 2017-11-09 22:36:45.000000000 -0500
@@ -387,6 +387,12 @@
env = getenv("HUGETLB_NO_RESERVE");
if (env && !strcasecmp(env, "yes"))
__hugetlb_opts.no_reserve = true;
+
+ /* Determine if data segment share memory mapping */
+ __hugetlb_opts.share_mapping = false;
+ env = getenv("HUGETLB_SHAREMAPPING");
+ if (env && !strcasecmp(env, "yes"))
+ __hugetlb_opts.share_mapping = true;
}
void hugetlbfs_setup_kernel_page_size()
diff -Naur libhugetlbfs-2.16/libhugetlbfs_internal.h libhugetlbfs-2.16.new//libhugetlbfs_internal.h
--- libhugetlbfs-2.16/libhugetlbfs_internal.h 2013-03-09 21:59:52.000000000 -0500
+++ libhugetlbfs-2.16.new//libhugetlbfs_internal.h 2017-11-09 22:35:53.000000000 -0500
@@ -73,6 +73,7 @@
char *def_page_size;
char *morecore;
char *heapbase;
+ bool share_mapping;
};
/*

View File

@ -1,31 +0,0 @@
From 7c371e7de53554166711e0bcc37df94d0a78edd3 Mon Sep 17 00:00:00 2001
From: sangyan <sangyan@huawei.com>
Date: Fri, 21 Apr 2017 14:35:03 +0800
Subject: [PATCH] elflink.c: remap segments with MAP_SHARED flag
Mmapping segment with MAP_PRIVATE will create a private
copy-on-write mapping, as a result updates to the mapping
will cost extra pages. It will cost double number of pages
in the worst case, so we change to MAP_SHARED flag.
It is also safe to mmap a unlinked file or a read-only file.
---
elflink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/elflink.c b/elflink.c
index b746b26..8187ee0 100644
--- a/elflink.c
+++ b/elflink.c
@@ -1131,7 +1131,7 @@ static void remap_segments(struct seg_info *seg, int num)
start = ALIGN_DOWN((unsigned long)seg[i].vaddr, hpage_size);
offset = (unsigned long)(seg[i].vaddr - start);
mapsize = ALIGN(offset + seg[i].memsz, hpage_size);
- mmap_flags = MAP_PRIVATE|MAP_FIXED;
+ mmap_flags = MAP_SHARED|MAP_FIXED;
/* If requested, make no reservations */
if (__hugetlb_opts.no_reserve)
--
1.8.3.1

View File

@ -2,7 +2,7 @@
Name: libhugetlbfs
Version: 2.23
Release: 4
Release: 5
Summary: A library which provides easy access to huge pages of memory
License: LGPLv2+
URL: https://github.com/libhugetlbfs/libhugetlbfs
@ -13,10 +13,8 @@ Patch1: Disable-hugepage-backed-malloc-if-__morecore-is-not-.patch
Patch2: libhugetlbfs-2.23-sw.patch
Patch3: add-loongarch-support.patch
#Patch9000:libhugetlbfs-2.16-remap_segments_with_MAP_SHARED.patch
#Patch9001:libhugetlbfs-2.16-remap_segments_with_MAP_SHARED-2.patch
Patch9002:libhugetlbfs-make-cflags.patch
#Patch9003:libhugetlbfs-fix-max-segment-cannot-adopt-the-x86.patch
Patch9001:libhugetlbfs-make-cflags.patch
Patch9002:libhugetlbfs-fix-max-segment-cannot-adopt-the-x86.patch
BuildRequires: gcc glibc-devel glibc-static
@ -88,6 +86,9 @@ touch $RPM_BUILD_ROOT%{_sysconfdir}/security/limits.d/hugepages.conf
%changelog
* Fri Sep 27 2024 wangqiang <wangqiang1@kylinos.cn> - 2.23-5
- Re-enable patch libhugetlbfs-fix-max-segment-cannot-adopt-the-x86.patch
* Mon May 6 2024 yueyaoqiang <yueyaoqiang@kylinos.cn> - 2.23-4
- add libhugetlbfs_privutils.so for libhugetlbfs test