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

@@ -142,6 +142,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

@@ -2060,6 +2060,21 @@ static void ld_preload_init()
}
}
static int get_thp_disable(void)
{
int ret = 0;
ret = prctl(PR_GET_THP_DISABLE, 0, 0, 0, 0);
/* PR_GET_THP_DISABLE supported since Linux 3.15 */
if (ret < 0) {
/* if not supported, make THP enable */
ret = 0;
}
return ret;
}
int main(int argc, char **argv)
{
int ret = 0;
@@ -2699,6 +2714,7 @@ int main(int argc, char **argv)
desc->uti_thread_rank = uti_thread_rank;
desc->uti_use_last_cpu = uti_use_last_cpu;
desc->thp_disable = get_thp_disable();
/* user_start and user_end are set by this call */
if (ioctl(fd, MCEXEC_UP_PREPARE_IMAGE, (unsigned long)desc) != 0) {