Message ID | 20231209065931.3458-9-gregory.price@memverge.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mempolicy2, mbind2, and weighted interleave | expand |
Hi Gregory, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-everything] [also build test ERROR on deller-parisc/for-next powerpc/next powerpc/fixes s390/features jcmvbkbc-xtensa/xtensa-for-next arnd-asm-generic/master linus/master v6.7-rc4] [cannot apply to tip/x86/asm geert-m68k/for-next geert-m68k/for-linus next-20231208] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/mm-mempolicy-implement-the-sysfs-based-weighted_interleave-interface/20231209-150314 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20231209065931.3458-9-gregory.price%40memverge.com patch subject: [PATCH v2 08/11] mm/mempolicy: add set_mempolicy2 syscall config: arc-alldefconfig (https://download.01.org/0day-ci/archive/20231210/202312100003.aUR6uBvr-lkp@intel.com/config) compiler: arc-elf-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231210/202312100003.aUR6uBvr-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312100003.aUR6uBvr-lkp@intel.com/ All error/warnings (new ones prefixed by >>): In file included from init/main.c:21: >> include/linux/syscalls.h:825:43: warning: 'struct mpol_args' declared inside parameter list will not be visible outside of this definition or declaration 825 | asmlinkage long sys_set_mempolicy2(struct mpol_args *args, size_t size, | ^~~~~~~~~ -- In file included from arch/arc/kernel/sys.c:3: >> include/linux/syscalls.h:825:43: warning: 'struct mpol_args' declared inside parameter list will not be visible outside of this definition or declaration 825 | asmlinkage long sys_set_mempolicy2(struct mpol_args *args, size_t size, | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: warning: initialized field overwritten [-Woverride-init] 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL' 29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys) | ^~~~~~~~~ include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro '__SC_COMP' 34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: note: (near initialization for 'sys_call_table[0]') 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL' 29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys) | ^~~~~~~~~ include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro '__SC_COMP' 34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: warning: initialized field overwritten [-Woverride-init] 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:36:1: note: in expansion of macro '__SYSCALL' 36 | __SYSCALL(__NR_io_destroy, sys_io_destroy) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: note: (near initialization for 'sys_call_table[1]') 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:36:1: note: in expansion of macro '__SYSCALL' 36 | __SYSCALL(__NR_io_destroy, sys_io_destroy) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: warning: initialized field overwritten [-Woverride-init] 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL' 29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys) | ^~~~~~~~~ include/uapi/asm-generic/unistd.h:38:1: note: in expansion of macro '__SC_COMP' 38 | __SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: note: (near initialization for 'sys_call_table[2]') 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL' 29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys) | ^~~~~~~~~ include/uapi/asm-generic/unistd.h:38:1: note: in expansion of macro '__SC_COMP' 38 | __SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: warning: initialized field overwritten [-Woverride-init] 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:40:1: note: in expansion of macro '__SYSCALL' 40 | __SYSCALL(__NR_io_cancel, sys_io_cancel) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: note: (near initialization for 'sys_call_table[3]') 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:40:1: note: in expansion of macro '__SYSCALL' 40 | __SYSCALL(__NR_io_cancel, sys_io_cancel) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: warning: initialized field overwritten [-Woverride-init] 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:20:34: note: in expansion of macro '__SYSCALL' 20 | #define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _32) | ^~~~~~~~~ include/uapi/asm-generic/unistd.h:44:1: note: in expansion of macro '__SC_3264' 44 | __SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: note: (near initialization for 'sys_call_table[4]') 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:20:34: note: in expansion of macro '__SYSCALL' 20 | #define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _32) | ^~~~~~~~~ include/uapi/asm-generic/unistd.h:44:1: note: in expansion of macro '__SC_3264' 44 | __SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: warning: initialized field overwritten [-Woverride-init] 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:48:1: note: in expansion of macro '__SYSCALL' 48 | __SYSCALL(__NR_setxattr, sys_setxattr) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: note: (near initialization for 'sys_call_table[5]') 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:48:1: note: in expansion of macro '__SYSCALL' 48 | __SYSCALL(__NR_setxattr, sys_setxattr) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: warning: initialized field overwritten [-Woverride-init] 13 | #define __SYSCALL(nr, call) [nr] = (call), | ^ include/uapi/asm-generic/unistd.h:50:1: note: in expansion of macro '__SYSCALL' 50 | __SYSCALL(__NR_lsetxattr, sys_lsetxattr) | ^~~~~~~~~ arch/arc/kernel/sys.c:13:36: note: (near initialization for 'sys_call_table[6]') 13 | #define __SYSCALL(nr, call) [nr] = (call), -- In file included from kernel/time/hrtimer.c:30: >> include/linux/syscalls.h:825:43: warning: 'struct mpol_args' declared inside parameter list will not be visible outside of this definition or declaration 825 | asmlinkage long sys_set_mempolicy2(struct mpol_args *args, size_t size, | ^~~~~~~~~ kernel/time/hrtimer.c:120:35: warning: initialized field overwritten [-Woverride-init] 120 | [CLOCK_REALTIME] = HRTIMER_BASE_REALTIME, | ^~~~~~~~~~~~~~~~~~~~~ kernel/time/hrtimer.c:120:35: note: (near initialization for 'hrtimer_clock_to_base_table[0]') kernel/time/hrtimer.c:121:35: warning: initialized field overwritten [-Woverride-init] 121 | [CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC, | ^~~~~~~~~~~~~~~~~~~~~~ kernel/time/hrtimer.c:121:35: note: (near initialization for 'hrtimer_clock_to_base_table[1]') kernel/time/hrtimer.c:122:35: warning: initialized field overwritten [-Woverride-init] 122 | [CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME, | ^~~~~~~~~~~~~~~~~~~~~ kernel/time/hrtimer.c:122:35: note: (near initialization for 'hrtimer_clock_to_base_table[7]') kernel/time/hrtimer.c:123:35: warning: initialized field overwritten [-Woverride-init] 123 | [CLOCK_TAI] = HRTIMER_BASE_TAI, | ^~~~~~~~~~~~~~~~ kernel/time/hrtimer.c:123:35: note: (near initialization for 'hrtimer_clock_to_base_table[11]') kernel/time/hrtimer.c: In function '__run_hrtimer': kernel/time/hrtimer.c:1651:14: warning: variable 'expires_in_hardirq' set but not used [-Wunused-but-set-variable] 1651 | bool expires_in_hardirq; | ^~~~~~~~~~~~~~~~~~ -- >> arc-elf-ld: arch/arc/kernel/sys.o:(.data+0x724): undefined reference to `sys_set_mempolicy2' >> arc-elf-ld: arch/arc/kernel/sys.o:(.data+0x724): undefined reference to `sys_set_mempolicy2'
Hi Gregory, kernel test robot noticed the following build warnings: [auto build test WARNING on akpm-mm/mm-everything] [also build test WARNING on deller-parisc/for-next powerpc/next powerpc/fixes s390/features jcmvbkbc-xtensa/xtensa-for-next arnd-asm-generic/master linus/master v6.7-rc4] [cannot apply to tip/x86/asm geert-m68k/for-next geert-m68k/for-linus next-20231208] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Gregory-Price/mm-mempolicy-implement-the-sysfs-based-weighted_interleave-interface/20231209-150314 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20231209065931.3458-9-gregory.price%40memverge.com patch subject: [PATCH v2 08/11] mm/mempolicy: add set_mempolicy2 syscall config: arm-lpc32xx_defconfig (https://download.01.org/0day-ci/archive/20231210/202312100245.Jgz5mPhJ-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231210/202312100245.Jgz5mPhJ-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312100245.Jgz5mPhJ-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from kernel/time/time.c:33: >> include/linux/syscalls.h:825:43: warning: declaration of 'struct mpol_args' will not be visible outside of this function [-Wvisibility] 825 | asmlinkage long sys_set_mempolicy2(struct mpol_args *args, size_t size, | ^ 1 warning generated. -- In file included from kernel/time/hrtimer.c:30: >> include/linux/syscalls.h:825:43: warning: declaration of 'struct mpol_args' will not be visible outside of this function [-Wvisibility] 825 | asmlinkage long sys_set_mempolicy2(struct mpol_args *args, size_t size, | ^ kernel/time/hrtimer.c:1651:7: warning: variable 'expires_in_hardirq' set but not used [-Wunused-but-set-variable] 1651 | bool expires_in_hardirq; | ^ kernel/time/hrtimer.c:277:20: warning: unused function 'is_migration_base' [-Wunused-function] 277 | static inline bool is_migration_base(struct hrtimer_clock_base *base) | ^ kernel/time/hrtimer.c:1876:20: warning: unused function '__hrtimer_peek_ahead_timers' [-Wunused-function] 1876 | static inline void __hrtimer_peek_ahead_timers(void) | ^ 4 warnings generated. vim +825 include/linux/syscalls.h 794 795 /* CONFIG_MMU only */ 796 asmlinkage long sys_swapon(const char __user *specialfile, int swap_flags); 797 asmlinkage long sys_swapoff(const char __user *specialfile); 798 asmlinkage long sys_mprotect(unsigned long start, size_t len, 799 unsigned long prot); 800 asmlinkage long sys_msync(unsigned long start, size_t len, int flags); 801 asmlinkage long sys_mlock(unsigned long start, size_t len); 802 asmlinkage long sys_munlock(unsigned long start, size_t len); 803 asmlinkage long sys_mlockall(int flags); 804 asmlinkage long sys_munlockall(void); 805 asmlinkage long sys_mincore(unsigned long start, size_t len, 806 unsigned char __user * vec); 807 asmlinkage long sys_madvise(unsigned long start, size_t len, int behavior); 808 asmlinkage long sys_process_madvise(int pidfd, const struct iovec __user *vec, 809 size_t vlen, int behavior, unsigned int flags); 810 asmlinkage long sys_process_mrelease(int pidfd, unsigned int flags); 811 asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size, 812 unsigned long prot, unsigned long pgoff, 813 unsigned long flags); 814 asmlinkage long sys_mbind(unsigned long start, unsigned long len, 815 unsigned long mode, 816 const unsigned long __user *nmask, 817 unsigned long maxnode, 818 unsigned flags); 819 asmlinkage long sys_get_mempolicy(int __user *policy, 820 unsigned long __user *nmask, 821 unsigned long maxnode, 822 unsigned long addr, unsigned long flags); 823 asmlinkage long sys_set_mempolicy(int mode, const unsigned long __user *nmask, 824 unsigned long maxnode); > 825 asmlinkage long sys_set_mempolicy2(struct mpol_args *args, size_t size, 826 unsigned long flags); 827 asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, 828 const unsigned long __user *from, 829 const unsigned long __user *to); 830 asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages, 831 const void __user * __user *pages, 832 const int __user *nodes, 833 int __user *status, 834 int flags); 835 asmlinkage long sys_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, 836 siginfo_t __user *uinfo); 837 asmlinkage long sys_perf_event_open( 838 struct perf_event_attr __user *attr_uptr, 839 pid_t pid, int cpu, int group_fd, unsigned long flags); 840 asmlinkage long sys_accept4(int, struct sockaddr __user *, int __user *, int); 841 asmlinkage long sys_recvmmsg(int fd, struct mmsghdr __user *msg, 842 unsigned int vlen, unsigned flags, 843 struct __kernel_timespec __user *timeout); 844 asmlinkage long sys_recvmmsg_time32(int fd, struct mmsghdr __user *msg, 845 unsigned int vlen, unsigned flags, 846 struct old_timespec32 __user *timeout); 847 asmlinkage long sys_wait4(pid_t pid, int __user *stat_addr, 848 int options, struct rusage __user *ru); 849 asmlinkage long sys_prlimit64(pid_t pid, unsigned int resource, 850 const struct rlimit64 __user *new_rlim, 851 struct rlimit64 __user *old_rlim); 852 asmlinkage long sys_fanotify_init(unsigned int flags, unsigned int event_f_flags); 853 asmlinkage long sys_fanotify_mark(int fanotify_fd, unsigned int flags, 854 u64 mask, int fd, 855 const char __user *pathname); 856 asmlinkage long sys_name_to_handle_at(int dfd, const char __user *name, 857 struct file_handle __user *handle, 858 int __user *mnt_id, int flag); 859 asmlinkage long sys_open_by_handle_at(int mountdirfd, 860 struct file_handle __user *handle, 861 int flags); 862 asmlinkage long sys_clock_adjtime(clockid_t which_clock, 863 struct __kernel_timex __user *tx); 864 asmlinkage long sys_clock_adjtime32(clockid_t which_clock, 865 struct old_timex32 __user *tx); 866 asmlinkage long sys_syncfs(int fd); 867 asmlinkage long sys_setns(int fd, int nstype); 868 asmlinkage long sys_pidfd_open(pid_t pid, unsigned int flags); 869 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg, 870 unsigned int vlen, unsigned flags); 871 asmlinkage long sys_process_vm_readv(pid_t pid, 872 const struct iovec __user *lvec, 873 unsigned long liovcnt, 874 const struct iovec __user *rvec, 875 unsigned long riovcnt, 876 unsigned long flags); 877 asmlinkage long sys_process_vm_writev(pid_t pid, 878 const struct iovec __user *lvec, 879 unsigned long liovcnt, 880 const struct iovec __user *rvec, 881 unsigned long riovcnt, 882 unsigned long flags); 883 asmlinkage long sys_kcmp(pid_t pid1, pid_t pid2, int type, 884 unsigned long idx1, unsigned long idx2); 885 asmlinkage long sys_finit_module(int fd, const char __user *uargs, int flags); 886 asmlinkage long sys_sched_setattr(pid_t pid, 887 struct sched_attr __user *attr, 888 unsigned int flags); 889 asmlinkage long sys_sched_getattr(pid_t pid, 890 struct sched_attr __user *attr, 891 unsigned int size, 892 unsigned int flags); 893 asmlinkage long sys_renameat2(int olddfd, const char __user *oldname, 894 int newdfd, const char __user *newname, 895 unsigned int flags); 896 asmlinkage long sys_seccomp(unsigned int op, unsigned int flags, 897 void __user *uargs); 898 asmlinkage long sys_getrandom(char __user *buf, size_t count, 899 unsigned int flags); 900 asmlinkage long sys_memfd_create(const char __user *uname_ptr, unsigned int flags); 901 asmlinkage long sys_bpf(int cmd, union bpf_attr *attr, unsigned int size); 902 asmlinkage long sys_execveat(int dfd, const char __user *filename, 903 const char __user *const __user *argv, 904 const char __user *const __user *envp, int flags); 905 asmlinkage long sys_userfaultfd(int flags); 906 asmlinkage long sys_membarrier(int cmd, unsigned int flags, int cpu_id); 907 asmlinkage long sys_mlock2(unsigned long start, size_t len, int flags); 908 asmlinkage long sys_copy_file_range(int fd_in, loff_t __user *off_in, 909 int fd_out, loff_t __user *off_out, 910 size_t len, unsigned int flags); 911 asmlinkage long sys_preadv2(unsigned long fd, const struct iovec __user *vec, 912 unsigned long vlen, unsigned long pos_l, unsigned long pos_h, 913 rwf_t flags); 914 asmlinkage long sys_pwritev2(unsigned long fd, const struct iovec __user *vec, 915 unsigned long vlen, unsigned long pos_l, unsigned long pos_h, 916 rwf_t flags); 917 asmlinkage long sys_pkey_mprotect(unsigned long start, size_t len, 918 unsigned long prot, int pkey); 919 asmlinkage long sys_pkey_alloc(unsigned long flags, unsigned long init_val); 920 asmlinkage long sys_pkey_free(int pkey); 921 asmlinkage long sys_statx(int dfd, const char __user *path, unsigned flags, 922 unsigned mask, struct statx __user *buffer); 923 asmlinkage long sys_rseq(struct rseq __user *rseq, uint32_t rseq_len, 924 int flags, uint32_t sig); 925 asmlinkage long sys_open_tree(int dfd, const char __user *path, unsigned flags); 926 asmlinkage long sys_move_mount(int from_dfd, const char __user *from_path, 927 int to_dfd, const char __user *to_path, 928 unsigned int ms_flags); 929 asmlinkage long sys_mount_setattr(int dfd, const char __user *path, 930 unsigned int flags, 931 struct mount_attr __user *uattr, size_t usize); 932 asmlinkage long sys_fsopen(const char __user *fs_name, unsigned int flags); 933 asmlinkage long sys_fsconfig(int fs_fd, unsigned int cmd, const char __user *key, 934 const void __user *value, int aux); 935 asmlinkage long sys_fsmount(int fs_fd, unsigned int flags, unsigned int ms_flags); 936 asmlinkage long sys_fspick(int dfd, const char __user *path, unsigned int flags); 937 asmlinkage long sys_pidfd_send_signal(int pidfd, int sig, 938 siginfo_t __user *info, 939 unsigned int flags); 940 asmlinkage long sys_pidfd_getfd(int pidfd, int fd, unsigned int flags); 941 asmlinkage long sys_landlock_create_ruleset(const struct landlock_ruleset_attr __user *attr, 942 size_t size, __u32 flags); 943 asmlinkage long sys_landlock_add_rule(int ruleset_fd, enum landlock_rule_type rule_type, 944 const void __user *rule_attr, __u32 flags); 945 asmlinkage long sys_landlock_restrict_self(int ruleset_fd, __u32 flags); 946 asmlinkage long sys_memfd_secret(unsigned int flags); 947 asmlinkage long sys_set_mempolicy_home_node(unsigned long start, unsigned long len, 948 unsigned long home_node, 949 unsigned long flags); 950 asmlinkage long sys_cachestat(unsigned int fd, 951 struct cachestat_range __user *cstat_range, 952 struct cachestat __user *cstat, unsigned int flags); 953 asmlinkage long sys_map_shadow_stack(unsigned long addr, unsigned long size, unsigned int flags); 954
diff --git a/Documentation/admin-guide/mm/numa_memory_policy.rst b/Documentation/admin-guide/mm/numa_memory_policy.rst index 64c5804dc40f..aabc24db92d3 100644 --- a/Documentation/admin-guide/mm/numa_memory_policy.rst +++ b/Documentation/admin-guide/mm/numa_memory_policy.rst @@ -432,6 +432,8 @@ Set [Task] Memory Policy:: long set_mempolicy(int mode, const unsigned long *nmask, unsigned long maxnode); + long set_mempolicy2(struct mpol_args args, size_t size, + unsigned long flags); Set's the calling task's "task/process memory policy" to mode specified by the 'mode' argument and the set of nodes defined by @@ -440,6 +442,12 @@ specified by the 'mode' argument and the set of nodes defined by 'mode' argument with the flag (for example: MPOL_INTERLEAVE | MPOL_F_STATIC_NODES). +set_mempolicy2() is an extended version of set_mempolicy() capable +of setting a mempolicy which requires more information than can be +passed via get_mempolicy(). For example, weighted interleave with +task-local weights requires a weight array to be passed via the +'mpol_args->il_weights' argument in the 'struct mpol_args' arg. + See the set_mempolicy(2) man page for more details @@ -498,6 +506,8 @@ Extended Mempolicy Arguments:: The extended mempolicy argument structure is defined to allow the mempolicy interfaces future extensibility without the need for additional system calls. +Extended interfaces (set_mempolicy2) use this argument structure. + The core arguments (mode, mode_flags, pol_nodes, and pol_maxnodes) apply to all interfaces relative to their non-extended counterparts. Each additional field may only apply to specific extended interfaces. See the respective diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl index 18c842ca6c32..0dc288a1118a 100644 --- a/arch/alpha/kernel/syscalls/syscall.tbl +++ b/arch/alpha/kernel/syscalls/syscall.tbl @@ -496,3 +496,4 @@ 564 common futex_wake sys_futex_wake 565 common futex_wait sys_futex_wait 566 common futex_requeue sys_futex_requeue +567 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl index 584f9528c996..50172ec0e1f5 100644 --- a/arch/arm/tools/syscall.tbl +++ b/arch/arm/tools/syscall.tbl @@ -470,3 +470,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl index 7a4b780e82cb..839d90c535f2 100644 --- a/arch/m68k/kernel/syscalls/syscall.tbl +++ b/arch/m68k/kernel/syscalls/syscall.tbl @@ -456,3 +456,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/microblaze/kernel/syscalls/syscall.tbl b/arch/microblaze/kernel/syscalls/syscall.tbl index 5b6a0b02b7de..567c8b883735 100644 --- a/arch/microblaze/kernel/syscalls/syscall.tbl +++ b/arch/microblaze/kernel/syscalls/syscall.tbl @@ -462,3 +462,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index a842b41c8e06..cc0640e16f2f 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -395,3 +395,4 @@ 454 n32 futex_wake sys_futex_wake 455 n32 futex_wait sys_futex_wait 456 n32 futex_requeue sys_futex_requeue +457 n32 set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index 525cc54bc63b..f7262fde98d9 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -444,3 +444,4 @@ 454 o32 futex_wake sys_futex_wake 455 o32 futex_wait sys_futex_wait 456 o32 futex_requeue sys_futex_requeue +457 o32 set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index a47798fed54e..e10f0e8bd064 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -455,3 +455,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index 7fab411378f2..4f03f5f42b78 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -543,3 +543,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl index 86fec9b080f6..f98dadc2e9df 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -459,3 +459,4 @@ 454 common futex_wake sys_futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl index 363fae0fe9bf..f47ba9f2d05d 100644 --- a/arch/sh/kernel/syscalls/syscall.tbl +++ b/arch/sh/kernel/syscalls/syscall.tbl @@ -459,3 +459,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl index 7bcaa3d5ea44..53fb16616728 100644 --- a/arch/sparc/kernel/syscalls/syscall.tbl +++ b/arch/sparc/kernel/syscalls/syscall.tbl @@ -502,3 +502,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index c8fac5205803..4b4dc41b24ee 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -461,3 +461,4 @@ 454 i386 futex_wake sys_futex_wake 455 i386 futex_wait sys_futex_wait 456 i386 futex_requeue sys_futex_requeue +457 i386 set_mempolicy2 sys_set_mempolicy2 diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index 8cb8bf68721c..1bc2190bec27 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -378,6 +378,7 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 # # Due to a historical design error, certain syscalls are numbered differently diff --git a/arch/xtensa/kernel/syscalls/syscall.tbl b/arch/xtensa/kernel/syscalls/syscall.tbl index 06eefa9c1458..e26dc89399eb 100644 --- a/arch/xtensa/kernel/syscalls/syscall.tbl +++ b/arch/xtensa/kernel/syscalls/syscall.tbl @@ -427,3 +427,4 @@ 454 common futex_wake sys_futex_wake 455 common futex_wait sys_futex_wait 456 common futex_requeue sys_futex_requeue +457 common set_mempolicy2 sys_set_mempolicy2 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index fd9d12de7e92..3244cd990858 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -822,6 +822,8 @@ asmlinkage long sys_get_mempolicy(int __user *policy, unsigned long addr, unsigned long flags); asmlinkage long sys_set_mempolicy(int mode, const unsigned long __user *nmask, unsigned long maxnode); +asmlinkage long sys_set_mempolicy2(struct mpol_args *args, size_t size, + unsigned long flags); asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, const unsigned long __user *from, const unsigned long __user *to); diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 756b013fb832..55486aba099f 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -828,9 +828,11 @@ __SYSCALL(__NR_futex_wake, sys_futex_wake) __SYSCALL(__NR_futex_wait, sys_futex_wait) #define __NR_futex_requeue 456 __SYSCALL(__NR_futex_requeue, sys_futex_requeue) +#define __NR_set_mempolicy2 457 +__SYSCALL(__NR_set_mempolicy2, sys_set_mempolicy2) #undef __NR_syscalls -#define __NR_syscalls 457 +#define __NR_syscalls 458 /* * 32 bit systems traditionally used different diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 446167dcebdc..a56ff02f780e 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1633,6 +1633,42 @@ SYSCALL_DEFINE3(set_mempolicy, int, mode, const unsigned long __user *, nmask, return kernel_set_mempolicy(mode, nmask, maxnode); } +SYSCALL_DEFINE3(set_mempolicy2, struct mpol_args __user *, uargs, size_t, usize, + unsigned long, flags) +{ + struct mpol_args kargs; + struct mempolicy_args margs; + int err; + nodemask_t policy_nodemask; + unsigned long __user *nodes_ptr; + + if (flags) + return -EINVAL; + + err = copy_struct_from_user(&kargs, sizeof(kargs), uargs, usize); + if (err) + return err; + + err = validate_mpol_flags(kargs.mode, &kargs.mode_flags); + if (err) + return err; + + memset(&margs, '\0', sizeof(margs)); + margs.mode = kargs.mode; + margs.mode_flags = kargs.mode_flags; + if (kargs.pol_nodes) { + nodes_ptr = u64_to_user_ptr(kargs.pol_nodes); + err = get_nodes(&policy_nodemask, nodes_ptr, + kargs.pol_maxnodes); + if (err) + return err; + margs.policy_nodes = &policy_nodemask; + } else + margs.policy_nodes = NULL; + + return do_set_mempolicy(&margs); +} + static int kernel_migrate_pages(pid_t pid, unsigned long maxnode, const unsigned long __user *old_nodes, const unsigned long __user *new_nodes)
set_mempolicy2 is an extensible set_mempolicy interface which allows a user to set the per-task memory policy. Defined as: set_mempolicy2(struct mpol_args *args, size_t size, unsigned long flags); relevant mpol_args fields include the following: mode: The MPOL_* policy (DEFAULT, INTERLEAVE, etc.) mode_flags: The MPOL_F_* flags that were previously passed in or'd into the mode. This was split to hopefully allow future extensions additional mode/flag space. pol_nodes: the nodemask to apply for the memory policy pol_maxnodes: The max number of nodes described by pol_nodes The usize arg is intended for the user to pass in sizeof(mpol_args) to allow forward/backward compatibility whenever possible. The flags argument is intended to future proof the syscall against future extensions which may require interpreting the arguments in the structure differently. Semantics of `set_mempolicy` are otherwise the same as `set_mempolicy` as of this patch. Suggested-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Gregory Price <gregory.price@memverge.com> --- .../admin-guide/mm/numa_memory_policy.rst | 10 ++++++ arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + arch/m68k/kernel/syscalls/syscall.tbl | 1 + arch/microblaze/kernel/syscalls/syscall.tbl | 1 + arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + arch/parisc/kernel/syscalls/syscall.tbl | 1 + arch/powerpc/kernel/syscalls/syscall.tbl | 1 + arch/s390/kernel/syscalls/syscall.tbl | 1 + arch/sh/kernel/syscalls/syscall.tbl | 1 + arch/sparc/kernel/syscalls/syscall.tbl | 1 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + include/linux/syscalls.h | 2 ++ include/uapi/asm-generic/unistd.h | 4 ++- mm/mempolicy.c | 36 +++++++++++++++++++ 18 files changed, 65 insertions(+), 1 deletion(-)