get_mempolicy(): store policy in per-process VM structure

This commit is contained in:
Balazs Gerofi
2016-10-16 09:10:36 +09:00
parent b88d75720f
commit 99a02e2941
3 changed files with 16 additions and 11 deletions

View File

@@ -168,6 +168,15 @@
#define PROCESS_NUMA_MASK_BITS 64 #define PROCESS_NUMA_MASK_BITS 64
enum {
MPOL_DEFAULT,
MPOL_PREFERRED,
MPOL_BIND,
MPOL_INTERLEAVE,
MPOL_LOCAL,
MPOL_MAX, /* always last member of enum */
};
#include <waitq.h> #include <waitq.h>
#include <futex.h> #include <futex.h>
@@ -598,6 +607,7 @@ struct process_vm {
long currss; long currss;
DECLARE_BITMAP(numa_mask, PROCESS_NUMA_MASK_BITS); DECLARE_BITMAP(numa_mask, PROCESS_NUMA_MASK_BITS);
int numa_mem_policy;
}; };
static inline int has_cap_ipc_lock(struct thread *th) static inline int has_cap_ipc_lock(struct thread *th)

View File

@@ -223,6 +223,7 @@ init_process_vm(struct process *owner, struct address_space *asp, struct process
} }
set_bit(i, &vm->numa_mask[0]); set_bit(i, &vm->numa_mask[0]);
} }
vm->numa_mem_policy = MPOL_DEFAULT;
return 0; return 0;
} }
@@ -384,6 +385,8 @@ clone_thread(struct thread *org, unsigned long pc, unsigned long sp,
} }
memcpy(&proc->vm->numa_mask, &org->vm->numa_mask, memcpy(&proc->vm->numa_mask, &org->vm->numa_mask,
sizeof(proc->vm->numa_mask)); sizeof(proc->vm->numa_mask));
proc->vm->numa_mem_policy =
org->vm->numa_mem_policy;
thread->proc = proc; thread->proc = proc;
thread->vm = proc->vm; thread->vm = proc->vm;

View File

@@ -7077,16 +7077,6 @@ out:
return error; return error;
} /* sys_getcpu() */ } /* sys_getcpu() */
/* XXX: move this to header.. */
enum {
MPOL_DEFAULT,
MPOL_PREFERRED,
MPOL_BIND,
MPOL_INTERLEAVE,
MPOL_LOCAL,
MPOL_MAX, /* always last member of enum */
};
SYSCALL_DECLARE(mbind) SYSCALL_DECLARE(mbind)
{ {
return -ENOSYS; return -ENOSYS;
@@ -7112,7 +7102,9 @@ SYSCALL_DECLARE(get_mempolicy)
} }
if (mode) { if (mode) {
error = copy_to_user(mode, MPOL_DEFAULT, sizeof(*mode)); error = copy_to_user(mode,
&cpu_local_var(current)->vm->numa_mem_policy,
sizeof(int));
if (error) { if (error) {
error = -EINVAL; error = -EINVAL;
goto out; goto out;