prctl: Add support for PR_SET_THP_DISABLE and PR_GET_THP_DISABLE

Change-Id: I04c5568a9eb78bcac632b734f34bba49cf602c4d
Refs: #1181
This commit is contained in:
Ken Sato
2018-12-12 15:41:32 +09:00
committed by Masamichi Takagi
parent eb184419ea
commit dfd23c3ebe
24 changed files with 773 additions and 1 deletions

View File

@@ -484,6 +484,7 @@ static int process_msg_prepare_process(unsigned long rphys)
proc->termsig = SIGCHLD;
proc->mpol_flags = pn->mpol_flags;
proc->mpol_threshold = pn->mpol_threshold;
proc->thp_disable = pn->thp_disable;
proc->nr_processes = pn->nr_processes;
proc->process_rank = pn->process_rank;
proc->heap_extension = pn->heap_extension;

View File

@@ -556,6 +556,7 @@ struct process {
int uti_thread_rank; /* Spawn on Linux CPU when clone_count reaches this */
int uti_use_last_cpu; /* Work-around not to share CPU with OpenMP thread */
int clone_count;
int thp_disable;
// perf_event
int perf_status;

View File

@@ -86,6 +86,10 @@
#define SCD_MSG_FUTEX_WAKE 0x60
/* For prctl() */
#define PR_SET_THP_DISABLE 41
#define PR_GET_THP_DISABLE 42
/* Cloning flags. */
# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
@@ -201,6 +205,7 @@ struct program_load_desc {
unsigned long heap_extension;
long stack_premap;
unsigned long mpol_bind_mask;
int thp_disable;
int uti_thread_rank; /* N-th clone() spawns a thread on Linux CPU */
int uti_use_last_cpu; /* Work-around not to share CPU with OpenMP thread */
int nr_processes;

View File

@@ -114,6 +114,7 @@ init_process(struct process *proc, struct process *parent)
proc->fsgid = parent->fsgid;
proc->mpol_flags = parent->mpol_flags;
proc->mpol_threshold = parent->mpol_threshold;
proc->thp_disable = parent->thp_disable;
memcpy(proc->rlimit, parent->rlimit,
sizeof(struct rlimit) * MCK_RLIM_MAX);
memcpy(&proc->cpu_set, &parent->cpu_set,

View File

@@ -1658,7 +1658,8 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot,
pgshift = (flags >> MAP_HUGE_SHIFT) & 0x3F;
p2align = pgshift - PAGE_SHIFT;
}
else if ((flags & MAP_PRIVATE) && (flags & MAP_ANONYMOUS)) {
else if ((flags & MAP_PRIVATE) && (flags & MAP_ANONYMOUS)
&& !proc->thp_disable) {
pgshift = 0; /* transparent huge page */
p2align = PAGE_P2ALIGN;
@@ -5198,7 +5199,10 @@ int do_shmget(const key_t key, const size_t size, const int shmflg)
if (shmflg & SHM_HUGETLB) {
pgshift = (shmflg >> SHM_HUGE_SHIFT) & 0x3F;
} else if (proc->thp_disable) {
pgshift = PAGE_SHIFT;
} else {
/* transparent huge page */
size_t pgsize;
int p2align;