!926 [sync] PR-924: try to enable system thp ability when LD_HUGEPAGE_LIB=2

From: @openeuler-sync-bot 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
This commit is contained in:
openeuler-ci-bot 2024-11-22 06:26:12 +00:00 committed by Gitee
commit 0180751415
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 42 additions and 1 deletions

View File

@ -71,7 +71,7 @@
##############################################################################
Name: glibc
Version: 2.34
Release: 160
Release: 161
Summary: The GNU libc libraries
License: %{all_license}
URL: http://www.gnu.org/software/glibc/
@ -365,6 +365,7 @@ Patch9050: change-hugepageedit-from-dynamic-link-to-static-link.patch
Patch9051: elf-the-hugepage-feature-of-dynamic-library-keep-com.patch
Patch9052: elf-add-some-debug-info-for-dynamic-library-hugepage.patch
Patch9053: Use-THP-for-dynamic-shared-library.patch
Patch9054: try-to-enable-system-thp-ability-when-LD_HUGEPAGE_LI.patch
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
@ -1540,6 +1541,9 @@ fi
%endif
%changelog
* Thu Nov 21 2024 Qingqing Li <liqingqing3@huawei.com> - 2.34-161
- try to enable system thp ability when LD_HUGEPAGE_LIB=2
* Wed Nov 06 2024 chengyechun <chengyechun1@huawei.com> - 2.34-160
- Type:bugfix
- CVE:NA

View File

@ -0,0 +1,37 @@
From 70eeedff7c588c0de85b6df561bb4683fb71e28a Mon Sep 17 00:00:00 2001
From: Qingqing Li <liqingqing3@huawei.com>
Date: Wed, 20 Nov 2024 14:43:42 +0800
Subject: [PATCH] try to enable system thp ability when LD_HUGEPAGE_LIB=2
---
elf/dl-load.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 063548ac..6c2eec09 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -75,6 +75,7 @@ struct filebuf
#include <dl-prop.h>
#include <not-cancel.h>
#ifdef HUGEPAGE_SHARED_LIB
+#include <sys/prctl.h>
#include <dl-map-segments-hugepage.h>
#endif
@@ -1310,6 +1311,12 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
(GLRO(dl_hugepage_mask) & DL_HUGEPAGE_LIB_THP_IN_FLAG) ||
((GLRO(dl_hugepage_mask) & DL_HUGEPAGE_PROBE_FLAG) && use_hugepage))
{
+ /* try to enable thp manually */
+ if (GLRO(dl_hugepage_mask) & DL_HUGEPAGE_LIB_THP_IN_FLAG)
+ {
+ (void)prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0);
+ }
+
_llvm_ld_relro_hp_fallback(phdr, relro_ph, l, hp_bitmap);
errstring = _dl_map_segments_largein (l, fd, header, type, loadcmds, nloadcmds,
maplength, hp_bitmap);
--
2.27.0