[PATCH] D140425: [BOLT] Fix hugify on new Linux kernels
Maksim Panchenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 12:01:25 PST 2022
maksfb created this revision.
maksfb added reviewers: treapster, yota9, Amir, ayermolo, rafauler, yavtuk.
Herald added a project: All.
maksfb requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Memory needs to be unlocked before madvise(2) is called for transparent
huge pages. I verified that /proc/<pid>/smaps reports FilePmdMapped
correctly. Note that there's a (non-deterministic) delay before the call
to madvise() is issued and pages are remapped. Thus, it's difficult to
test the functionality automatically.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D140425
Files:
bolt/runtime/common.h
bolt/runtime/hugify.cpp
Index: bolt/runtime/hugify.cpp
===================================================================
--- bolt/runtime/hugify.cpp
+++ bolt/runtime/hugify.cpp
@@ -157,6 +157,10 @@
return;
}
+ if (__munlock(From, (To - From)) == -1) {
+ char Msg[] = "[hugify] failed to unlock memory\n";
+ reportError(Msg, sizeof(Msg));
+ }
if (__madvise(From, (To - From), 14 /* MADV_HUGEPAGE */) == -1) {
char Msg[] = "[hugify] failed to allocate large page\n";
// TODO: allow user to control the failure behavior.
Index: bolt/runtime/common.h
===================================================================
--- bolt/runtime/common.h
+++ bolt/runtime/common.h
@@ -422,6 +422,16 @@
return ret;
}
+int __munlock(void *addr, size_t length) {
+ int ret;
+ __asm__ __volatile__("movq $0x96, %%rax\n"
+ "syscall\n"
+ : "=a"(ret)
+ : "D"(addr), "S"(length)
+ : "cc", "rcx", "r11", "memory");
+ return ret;
+}
+
#define _UTSNAME_LENGTH 65
struct UtsNameTy {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140425.484345.patch
Type: text/x-patch
Size: 1067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221220/662d1315/attachment.bin>
More information about the llvm-commits
mailing list