incoming
Subsystems (98)
Andrew Morton
maintainerPATCH 121/165 drivers/rapidio/rio-scan.c: use struct_size() helper
In reply to Andrew MortonFrom: "Gustavo A. R. Silva" <[email protected]>
Subject: drivers/rapidio/rio-scan.c: use struct_size() helper
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes.
Also, while there, use the preferred form for passing a size of a struct. The alternative form where struct name is spelled out hurts readability and introduces an opportunity for a bug when the pointer variable type is changed but the corresponding sizeof that is passed as argument is not.
This issue was found with the help of Coccinelle and, audited and fixed manually.
Addresses KSPP ID: https://github.com/KSPP/linux/issues/83
---
drivers/rapidio/rio-scan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/rapidio/rio-scan.c renamed from drivers/rapidio/rio-scan.c~rapidio-use-struct_size-helper +3 -5
@@ -330,7 +330,7 @@ static struct rio_dev *rio_setup_device(size_t size;u32 swpinfo =0 ; - size =sizeof (struct rio_dev ); + size =sizeof (*rdev);if (rio_mport_read_config_32 (port, destid, hopcount,RIO_PEF_CAR , &result))return NULL ;
@@ -338,10 +338,8 @@ static struct rio_dev *rio_setup_device(if (result & (RIO_PEF_SWITCH |RIO_PEF_MULTIPORT )) {rio_mport_read_config_32 (port, destid, hopcount,RIO_SWP_INFO_CAR , &swpinfo); -if (result &RIO_PEF_SWITCH ) { - size += (RIO_GET_TOTAL_PORTS (swpinfo) * -sizeof (rswitch->nextdev[0 ])) +sizeof (*rswitch); - } +if (result &RIO_PEF_SWITCH ) + size +=struct_size (rswitch, nextdev,RIO_GET_TOTAL_PORTS (swpinfo)); } rdev =kzalloc (size,GFP_KERNEL );
_
Andrew Morton
maintainerPATCH 122/165 rapidio/rio_mport_cdev: use array_size() helper in copy_{from,to}_user()
In reply to Andrew MortonFrom: "Gustavo A. R. Silva" <[email protected]>
Subject: rapidio/rio_mport_cdev: use array_size() helper in copy_{from,to}_user()
Use array_size() helper instead of the open-coded version in copy_{from,to}_user(). These sorts of multiplication factors need to be wrapped in array_size().
This issue was found with the help of Coccinelle and, audited and fixed manually.
Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
---
drivers/rapidio/devices/rio_mport_cdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rapidio/devices/rio_mport_cdev.c renamed from drivers/rapidio/devices/rio_mport_cdev.c~rapidio-rio_mport_cdev-use-array_size-helper-in-copy_fromto_user +2 -2
@@ -981,7 +981,7 @@ static int rio_mport_transfer_ioctl(struif (unlikely (copy_from_user (transfer, (void __user *)(uintptr_t )transaction.block, - transaction.count *sizeof (*transfer)))) { +array_size (sizeof (*transfer), transaction.count)))) { ret = -EFAULT ; goto out_free; }
@@ -994,7 +994,7 @@ static int rio_mport_transfer_ioctl(struif (unlikely (copy_to_user ((void __user *)(uintptr_t )transaction.block, transfer, - transaction.count *sizeof (*transfer)))) +array_size (sizeof (*transfer), transaction.count)))) ret = -EFAULT ; out_free:
_
Andrew Morton
maintainerPATCH 123/165 kernel/panic.c: make oops_may_print() return bool
In reply to Andrew MortonFrom: Tiezhu Yang <[email protected]>
Subject: kernel/panic.c: make oops_may_print() return bool
The return value of oops_may_print() is true or false, so change its type to reflect that.
---
include/linux/kernel.h | 2 +- kernel/panic.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/kernel.h renamed from include/linux/kernel.h~kernel-panicc-make-oops_may_print-return-bool +1 -1
@@ -322,7 +322,7 @@ void nmi_panic(struct pt_regs *regs, conextern void oops_enter (void );extern void oops_exit (void );void print_oops_end_marker (void ); -extern int oops_may_print (void ); +extern bool oops_may_print (void );void do_exit (long error_code)__noreturn ;void complete_and_exit (struct completion *,long )__noreturn ;
kernel/panic.c renamed from kernel/panic.c~kernel-panicc-make-oops_may_print-return-bool +1 -1
@@ -505,7 +505,7 @@ static void do_oops_enter_exit(void)* Return true if the calling CPU is allowed to print oops-related info. * This is a bit racy.. */ -int oops_may_print (void ) +bool oops_may_print (void ) {return pause_on_oops_flag ==0 ; }
_
Andrew Morton
maintainerPATCH 124/165 lib/Kconfig.debug: fix typo in the help text of CONFIG_PANIC_TIMEOUT
In reply to Andrew MortonFrom: Tiezhu Yang <[email protected]>
Subject: lib/Kconfig.debug: fix typo in the help text of CONFIG_PANIC_TIMEOUT
There exists duplicated "the" in the help text of CONFIG_PANIC_TIMEOUT, Remove it.
---
lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug renamed from lib/Kconfig.debug~lib-kconfigdebug-fix-typo-in-the-help-text-of-config_panic_timeout +1 -1
@@ -917,7 +917,7 @@ config PANIC_TIMEOUT int "panic timeout" default 0 help - Set the timeout value (in seconds) until a reboot occurs when the + Set the timeout value (in seconds) until a reboot occurs when the kernel panics. If n = 0, then we wait forever. A timeout value n > 0 will wait n seconds before rebooting, while a timeout value n < 0 will reboot immediately.
_
Andrew Morton
maintainerPATCH 125/165 panic: make print_oops_end_marker() static
In reply to Andrew MortonFrom: Yue Hu <[email protected]>
Subject: panic: make print_oops_end_marker() static
Since print_oops_end_marker() is not used externally, also remove it in kernel.h at the same time.
---
include/linux/kernel.h | 1 - kernel/panic.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
include/linux/kernel.h renamed from include/linux/kernel.h~panic-make-print_oops_end_marker-static +0 -1
@@ -321,7 +321,6 @@ void panic(const char *fmt, ...) __noretvoid nmi_panic (struct pt_regs *regs,const char *msg);extern void oops_enter (void );extern void oops_exit (void ); -void print_oops_end_marker (void );extern bool oops_may_print (void );void do_exit (long error_code)__noreturn ;void complete_and_exit (struct completion *,long )__noreturn ;
kernel/panic.c renamed from kernel/panic.c~panic-make-print_oops_end_marker-static +1 -1
@@ -551,7 +551,7 @@ static int init_oops_id(void) }late_initcall (init_oops_id); -void print_oops_end_marker (void ) +static void print_oops_end_marker (void ) {init_oops_id ();pr_warn ("---[ end trace %016llx ]---\n" , (unsigned long long )oops_id);
_
Andrew Morton
maintainerPATCH 126/165 kcov: unconditionally add -fno-stack-protector to compiler options
In reply to Andrew MortonFrom: Marco Elver <[email protected]>
Subject: kcov: unconditionally add -fno-stack-protector to compiler options
Unconditionally add -fno-stack-protector to KCOV's compiler options, as all supported compilers support the option. This saves a compiler invocation to determine if the option is supported.
Because Clang does not support -fno-conserve-stack, and -fno-stack-protector was wrapped in the same cc-option, we were missing -fno-stack-protector with Clang. Unconditionally adding this option fixes this for Clang.
---
kernel/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/Makefile renamed from kernel/Makefile~kcov-unconditionally-add-fno-stack-protector-to-compiler-options +1 -1
@@ -36,7 +36,7 @@ KCOV_INSTRUMENT_stacktrace.o := n KCOV_INSTRUMENT_kcov.o := n KASAN_SANITIZE_kcov.o := n KCSAN_SANITIZE_kcov.o := n -CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) +CFLAGS_kcov.o := $(call cc-option, -fno-conserve-stack) -fno-stack-protector # cond_syscall is currently not LTO compatible CFLAGS_sys_ni.o = $(DISABLE_LTO)
_
Andrew Morton
maintainerPATCH 127/165 kcov: make some symbols static
In reply to Andrew MortonFrom: Wei Yongjun <[email protected]>
Subject: kcov: make some symbols static
Fix sparse build warnings:
kernel/kcov.c:99:1: warning:
symbol '__pcpu_scope_kcov_percpu_data' was not declared. Should it be static?kernel/kcov.c:778:6: warning:
symbol 'kcov_remote_softirq_start' was not declared. Should it be static?kernel/kcov.c:795:6: warning:
symbol 'kcov_remote_softirq_stop' was not declared. Should it be static?
---
kernel/kcov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/kcov.c renamed from kernel/kcov.c~kcov-make-some-symbols-static +3 -3
@@ -96,7 +96,7 @@ struct kcov_percpu_data {int saved_sequence; }; -DEFINE_PER_CPU(struct kcov_percpu_data, kcov_percpu_data); +static DEFINE_PER_CPU(struct kcov_percpu_data, kcov_percpu_data);/* Must be called with kcov_remote_lock locked. */ static struct kcov_remote *kcov_remote_find (u64 handle)
@@ -775,7 +775,7 @@ static inline bool kcov_mode_enabled(unsreturn (mode & ~KCOV_IN_CTXSW ) !=KCOV_MODE_DISABLED ; } -void kcov_remote_softirq_start (struct task_struct *t) +static void kcov_remote_softirq_start (struct task_struct *t) {struct kcov_percpu_data *data =this_cpu_ptr (&kcov_percpu_data);unsigned int mode;
@@ -792,7 +792,7 @@ void kcov_remote_softirq_start(struct ta } } -void kcov_remote_softirq_stop (struct task_struct *t) +static void kcov_remote_softirq_stop (struct task_struct *t) {struct kcov_percpu_data *data =this_cpu_ptr (&kcov_percpu_data);
_
Andrew Morton
maintainerPATCH 128/165 scripts/gdb: fix python 3.8 SyntaxWarning
In reply to Andrew MortonFrom: Nick Desaulniers <[email protected]>
Subject: scripts/gdb: fix python 3.8 SyntaxWarning
Fixes the observed warnings:scripts/gdb/linux/rbtree.py:20: SyntaxWarning: "is" with a literal. Did you mean "=="?
if node is 0:scripts/gdb/linux/rbtree.py:36: SyntaxWarning: "is" with a literal. Did you mean "=="?
if node is 0:
It looks like this is a new warning added in Python 3.8. I've only seen this once after adding the add-auto-load-safe-path rule to my ~/.gdbinit for a new tree.
---
scripts/gdb/linux/rbtree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/gdb/linux/rbtree.py renamed from scripts/gdb/linux/rbtree.py~scripts-gdb-fix-python-38-syntaxwarning +2 -2
@@ -17,7 +17,7 @@ def rb_first(root): raise gdb.GdbError("Must be struct rb_root not {}".format(root.type)) node = root['rb_node'] - if node is 0: + if node == 0: return None while node['rb_left']:
@@ -33,7 +33,7 @@ def rb_last(root): raise gdb.GdbError("Must be struct rb_root not {}".format(root.type)) node = root['rb_node'] - if node is 0: + if node == 0: return None while node['rb_right']:
_
Andrew Morton
maintainerPATCH 129/165 ipc: uninline functions
In reply to Andrew MortonFrom: Alexey Dobriyan <[email protected]>
Subject: ipc: uninline functions
Two functions are only called via function pointers, don't bother inlining them.
---
ipc/sem.c | 3 +-- ipc/shm.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
ipc/sem.c renamed from ipc/sem.c~ipc-uninline-functions +1 -2
@@ -585,8 +585,7 @@ static int newary(struct ipc_namespace */* * Called with sem_ids.rwsem and ipcp locked. */ -static inline int sem_more_checks (struct kern_ipc_perm *ipcp, -struct ipc_params *params) +static int sem_more_checks (struct kern_ipc_perm *ipcp,struct ipc_params *params) {struct sem_array *sma;
ipc/shm.c renamed from ipc/shm.c~ipc-uninline-functions +1 -2
@@ -711,8 +711,7 @@ no_file:/* * Called with shm_ids.rwsem and ipcp locked. */ -static inline int shm_more_checks (struct kern_ipc_perm *ipcp, -struct ipc_params *params) +static int shm_more_checks (struct kern_ipc_perm *ipcp,struct ipc_params *params) {struct shmid_kernel *shp;
_
Andrew Morton
maintainerPATCH 130/165 ipc/shm.c: remove the superfluous break
In reply to Andrew MortonFrom: Liao Pingfang <[email protected]>
Subject: ipc/shm.c: remove the superfluous break
Remove the superfuous break, as there is a 'return' before it.
---
ipc/shm.c | 1 - 1 file changed, 1 deletion(-)
ipc/shm.c renamed from ipc/shm.c~ipc-shmc-remove-the-superfluous-break +0 -1
@@ -1380,7 +1380,6 @@ static long compat_ksys_shmctl(int shmidcase SHM_LOCK :case SHM_UNLOCK :return shmctl_do_lock (ns, shmid, cmd); -break ;default :return -EINVAL ; }
_
Andrew Morton
maintainerPATCH 131/165 mm/page_isolation: prefer the node of the source page
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/page_isolation: prefer the node of the source page
Patch series "clean-up the migration target allocation functions", v5.
This patch (of 9):
For locality, it's better to migrate the page to the same node rather than the node of the current caller's cpu.
---
mm/page_isolation.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/page_isolation.c renamed from mm/page_isolation.c~mm-page_isolation-prefer-the-node-of-the-source-page +3 -1
@@ -309,5 +309,7 @@ int test_pages_isolated(unsigned long ststruct page *alloc_migrate_target (struct page *page,unsigned long private) { -return new_page_nodemask (page,numa_node_id (), &node_states[N_MEMORY ]); +int nid =page_to_nid (page); + +return new_page_nodemask (page, nid, &node_states[N_MEMORY ]); }
_
Andrew Morton
maintainerPATCH 132/165 mm/migrate: move migration helper from .h to .c
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/migrate: move migration helper from .h to .c
It's not performance sensitive function. Move it to .c. This is a preparation step for future change.
---
include/linux/migrate.h | 33 +++++---------------------------- mm/migrate.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 28 deletions(-)
include/linux/migrate.h renamed from include/linux/migrate.h~mm-migrate-move-migration-helper-from-h-to-c +5 -28
@@ -31,34 +31,6 @@ enum migrate_reason {/* In mm/debug.c; also keep sync with include/trace/events/migrate.h */ extern const char *migrate_reason_names[MR_TYPES ]; -static inline struct page *new_page_nodemask (struct page *page, -int preferred_nid,nodemask_t *nodemask) -{ -gfp_t gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; -unsigned int order =0 ; -struct page *new_page =NULL ; - -if (PageHuge (page)) -return alloc_huge_page_nodemask (page_hstate (compound_head (page)), - preferred_nid, nodemask); - -if (PageTransHuge (page)) { - gfp_mask |=GFP_TRANSHUGE ; - order =HPAGE_PMD_ORDER ; - } - -if (PageHighMem (page) || (zone_idx (page_zone (page)) ==ZONE_MOVABLE )) - gfp_mask |= __GFP_HIGHMEM; - - new_page =__alloc_pages_nodemask (gfp_mask, order, - preferred_nid, nodemask); - -if (new_page &&PageTransHuge (new_page)) -prep_transhuge_page (new_page); - -return new_page; -} -#ifdef CONFIG_MIGRATION extern void putback_movable_pages (struct list_head *l);
@@ -67,6 +39,8 @@ extern int migrate_page(struct address_s enum migrate_mode mode);extern int migrate_pages (struct list_head *l,new_page_t new,free_page_t free,unsigned long private,enum migrate_mode mode,int reason); +extern struct page *new_page_nodemask (struct page *page, +int preferred_nid,nodemask_t *nodemask);extern int isolate_movable_page (struct page *page,isolate_mode_t mode);extern void putback_movable_page (struct page *page);
@@ -85,6 +59,9 @@ static inline int migrate_pages(struct l free_page_t free, unsigned long private, enum migrate_mode mode, int reason) { return -ENOSYS; } +static inline struct page *new_page_nodemask (struct page *page, +int preferred_nid,nodemask_t *nodemask) + {return NULL ; }static inline int isolate_movable_page (struct page *page,isolate_mode_t mode) {return -EBUSY ; }
mm/migrate.c renamed from mm/migrate.c~mm-migrate-move-migration-helper-from-h-to-c +29 -0
@@ -1538,6 +1538,35 @@ out:return rc; } +struct page *new_page_nodemask (struct page *page, +int preferred_nid,nodemask_t *nodemask) +{ +gfp_t gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; +unsigned int order =0 ; +struct page *new_page =NULL ; + +if (PageHuge (page)) +return alloc_huge_page_nodemask ( +page_hstate (compound_head (page)), + preferred_nid, nodemask); + +if (PageTransHuge (page)) { + gfp_mask |=GFP_TRANSHUGE ; + order =HPAGE_PMD_ORDER ; + } + +if (PageHighMem (page) || (zone_idx (page_zone (page)) ==ZONE_MOVABLE )) + gfp_mask |= __GFP_HIGHMEM; + + new_page =__alloc_pages_nodemask (gfp_mask, order, + preferred_nid, nodemask); + +if (new_page &&PageTransHuge (new_page)) +prep_transhuge_page (new_page); + +return new_page; +} +#ifdef CONFIG_NUMA static int store_status (int __user *status,int start,int value,int nr)
_
Andrew Morton
maintainerPATCH 133/165 mm/hugetlb: unify migration callbacks
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/hugetlb: unify migration callbacks
There is no difference between two migration callback functions, alloc_huge_page_node() and alloc_huge_page_nodemask(), except __GFP_THISNODE handling. It's redundant to have two almost similar functions in order to handle this flag. So, this patch tries to remove one by introducing a new argument, gfp_mask, to alloc_huge_page_nodemask().
After introducing gfp_mask argument, it's caller's job to provide correct gfp_mask. So, every callsites for alloc_huge_page_nodemask() are changed to provide gfp_mask.
Note that it's safe to remove a node id check in alloc_huge_page_node() since there is no caller passing NUMA_NO_NODE as a node id.
---
include/linux/hugetlb.h | 26 ++++++++++++++++++-------- mm/hugetlb.c | 35 ++--------------------------------- mm/mempolicy.c | 10 ++++++---- mm/migrate.c | 11 +++++++---- 4 files changed, 33 insertions(+), 49 deletions(-)
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~mm-hugetlb-unify-migration-callbacks +18 -8
@@ -10,6 +10,7 @@#include <linux/list.h> #include <linux/kref.h> #include <linux/pgtable.h> +#include <linux/gfp.h> struct ctl_table ;struct user_struct ;
@@ -506,9 +507,8 @@ struct huge_bootmem_page {struct page *alloc_huge_page (struct vm_area_struct *vma,unsigned long addr,int avoid_reserve); -struct page *alloc_huge_page_node (struct hstate *h,int nid);struct page *alloc_huge_page_nodemask (struct hstate *h,int preferred_nid, -nodemask_t *nmask); +nodemask_t *nmask,gfp_t gfp_mask);struct page *alloc_huge_page_vma (struct hstate *h,struct vm_area_struct *vma,unsigned long address); struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask,
@@ -694,6 +694,15 @@ static inline bool hugepage_movable_suppreturn true; } +/* Movability of hugepages depends on migration support. */ +static inline gfp_t htlb_alloc_mask (struct hstate *h) +{ +if (hugepage_movable_supported (h)) +return GFP_HIGHUSER_MOVABLE ; +else +return GFP_HIGHUSER ; +} +static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte) {
@@ -761,13 +770,9 @@ static inline struct page *alloc_huge_pareturn NULL ; } -static inline struct page *alloc_huge_page_node (struct hstate *h,int nid) -{ -return NULL ; -} -static inline struct page * -alloc_huge_page_nodemask (struct hstate *h,int preferred_nid,nodemask_t *nmask) +alloc_huge_page_nodemask (struct hstate *h,int preferred_nid, +nodemask_t *nmask,gfp_t gfp_mask) {return NULL ; }
@@ -880,6 +885,11 @@ static inline bool hugepage_movable_suppreturn false; } +static inline gfp_t htlb_alloc_mask (struct hstate *h) +{ +return 0 ; +} +static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte) {
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-unify-migration-callbacks +2 -33
@@ -1093,15 +1093,6 @@ retry_cpuset:return NULL ; } -/* Movability of hugepages depends on migration support. */ -static inline gfp_t htlb_alloc_mask (struct hstate *h) -{ -if (hugepage_movable_supported (h)) -return GFP_HIGHUSER_MOVABLE ; -else -return GFP_HIGHUSER ; -} - static struct page *dequeue_huge_page_vma(struct hstate *h, struct vm_area_struct *vma, unsigned long address, int avoid_reserve,
@@ -1986,31 +1977,9 @@ struct page *alloc_buddy_huge_page_with_ }/* page migration callback function */ -struct page *alloc_huge_page_node (struct hstate *h,int nid) -{ -gfp_t gfp_mask =htlb_alloc_mask (h); -struct page *page =NULL ; - -if (nid !=NUMA_NO_NODE ) - gfp_mask |= __GFP_THISNODE; - -spin_lock (&hugetlb_lock); -if (h->free_huge_pages - h->resv_huge_pages >0 ) - page =dequeue_huge_page_nodemask (h, gfp_mask, nid,NULL ); -spin_unlock (&hugetlb_lock); - -if (!page) - page =alloc_migrate_huge_page (h, gfp_mask, nid,NULL ); - -return page; -} - -/* page migration callback function */ struct page *alloc_huge_page_nodemask (struct hstate *h,int preferred_nid, -nodemask_t *nmask) +nodemask_t *nmask,gfp_t gfp_mask) { -gfp_t gfp_mask =htlb_alloc_mask (h); -spin_lock (&hugetlb_lock);if (h->free_huge_pages - h->resv_huge_pages >0 ) {struct page *page;
@@ -2038,7 +2007,7 @@ struct page *alloc_huge_page_vma(struct gfp_mask =htlb_alloc_mask (h); node =huge_node (vma, address, gfp_mask, &mpol, &nodemask); - page =alloc_huge_page_nodemask (h, node, nodemask); + page =alloc_huge_page_nodemask (h, node, nodemask, gfp_mask);mpol_cond_put (mpol);return page;
mm/mempolicy.c renamed from mm/mempolicy.c~mm-hugetlb-unify-migration-callbacks +6 -4
@@ -1068,10 +1068,12 @@ static int migrate_page_add(struct page/* page allocation callback for NUMA node migration */ struct page *alloc_new_node_page (struct page *page,unsigned long node) { -if (PageHuge (page)) -return alloc_huge_page_node (page_hstate (compound_head (page)), - node); -else if (PageTransHuge (page)) { +if (PageHuge (page)) { +struct hstate *h =page_hstate (compound_head (page)); +gfp_t gfp_mask =htlb_alloc_mask (h) | __GFP_THISNODE; + +return alloc_huge_page_nodemask (h, node,NULL , gfp_mask); + }else if (PageTransHuge (page)) {struct page *thp; thp = alloc_pages_node(node,
mm/migrate.c renamed from mm/migrate.c~mm-hugetlb-unify-migration-callbacks +7 -4
@@ -1545,10 +1545,13 @@ struct page *new_page_nodemask(struct paunsigned int order =0 ;struct page *new_page =NULL ; -if (PageHuge (page)) -return alloc_huge_page_nodemask ( -page_hstate (compound_head (page)), - preferred_nid, nodemask); +if (PageHuge (page)) { +struct hstate *h =page_hstate (compound_head (page)); + + gfp_mask =htlb_alloc_mask (h); +return alloc_huge_page_nodemask (h, preferred_nid, + nodemask, gfp_mask); + }if (PageTransHuge (page)) { gfp_mask |=GFP_TRANSHUGE ;
_
Andrew Morton
maintainerPATCH 134/165 mm/migrate: clear __GFP_RECLAIM to make the migration callback consistent with regular THP allocations
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/migrate: clear __GFP_RECLAIM to make the migration callback consistent with regular THP allocations
new_page_nodemask is a migration callback and it tries to use a common gfp flags for the target page allocation whether it is a base page or a THP. The later only adds GFP_TRANSHUGE to the given mask. This results in the allocation being slightly more aggressive than necessary because the resulting gfp mask will contain also __GFP_RECLAIM_KSWAPD. THP allocations usually exclude this flag to reduce over eager background reclaim during a high THP allocation load which has been seen during large mmaps initialization. There is no indication that this is a problem for migration as well but theoretically the same might happen when migrating large mappings to a different node. Make the migration callback consistent with regular THP allocations.
---
mm/migrate.c | 5 +++++ 1 file changed, 5 insertions(+)
mm/migrate.c renamed from mm/migrate.c~mm-migrate-clear-__gfp_reclaim-to-make-the-migration-callback-consistent-with-regular-thp-allocations +5 -0
@@ -1554,6 +1554,11 @@ struct page *new_page_nodemask(struct pa }if (PageTransHuge (page)) { +/* +* clear __GFP_RECLAIM to make the migration callback +* consistent with regular THP allocations. +*/ + gfp_mask &= ~__GFP_RECLAIM; gfp_mask |=GFP_TRANSHUGE ; order =HPAGE_PMD_ORDER ; }
_
Andrew Morton
maintainerPATCH 135/165 mm/migrate: introduce a standard migration target allocation function
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/migrate: introduce a standard migration target allocation function
There are some similar functions for migration target allocation. Since there is no fundamental difference, it's better to keep just one rather than keeping all variants. This patch implements base migration target allocation function. In the following patches, variants will be converted to use this function.
Changes should be mechanical, but, unfortunately, there are some differences. First, some callers' nodemask is assgined to NULL since NULL nodemask will be considered as all available nodes, that is, &node_states[N_MEMORY]. Second, for hugetlb page allocation, gfp_mask is redefined as regular hugetlb allocation gfp_mask plus __GFP_THISNODE if user provided gfp_mask has it. This is because future caller of this function requires to set this node constaint. Lastly, if provided nodeid is NUMA_NO_NODE, nodeid is set up to the node where migration source lives. It helps to remove simple wrappers for setting up the nodeid.
Note that PageHighmem() call in previous function is changed to open-code "is_highmem_idx()" since it provides more readability.
---
include/linux/hugetlb.h | 15 +++++++++++++++ include/linux/migrate.h | 9 +++++---- mm/internal.h | 7 +++++++ mm/memory-failure.c | 7 +++++-- mm/memory_hotplug.c | 12 ++++++++---- mm/migrate.c | 26 ++++++++++++++++---------- mm/page_isolation.c | 7 +++++-- 7 files changed, 61 insertions(+), 22 deletions(-)
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~mm-migrate-make-a-standard-migration-target-allocation-function +15 -0
@@ -703,6 +703,16 @@ static inline gfp_t htlb_alloc_mask(strureturn GFP_HIGHUSER ; } +static inline gfp_t htlb_modify_alloc_mask (struct hstate *h,gfp_t gfp_mask) +{ +gfp_t modified_mask =htlb_alloc_mask (h); + +/* Some callers might want to enforce node */ + modified_mask |= (gfp_mask & __GFP_THISNODE); + +return modified_mask; +} +static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte) {
@@ -889,6 +899,11 @@ static inline gfp_t htlb_alloc_mask(stru {return 0 ; } + +static inline gfp_t htlb_modify_alloc_mask (struct hstate *h,gfp_t gfp_mask) +{ +return 0 ; +}static inline spinlock_t *huge_pte_lockptr (struct hstate *h,struct mm_struct *mm,pte_t *pte)
include/linux/migrate.h renamed from include/linux/migrate.h~mm-migrate-make-a-standard-migration-target-allocation-function +5 -4
@@ -10,6 +10,8 @@typedef struct page *new_page_t (struct page *page,unsigned long private);typedef void free_page_t (struct page *page,unsigned long private); +struct migration_target_control ; +/* * Return values from addresss_space_operations.migratepage(): * - negative errno on page migration failure;
@@ -39,8 +41,7 @@ extern int migrate_page(struct address_s enum migrate_mode mode);extern int migrate_pages (struct list_head *l,new_page_t new,free_page_t free,unsigned long private,enum migrate_mode mode,int reason); -extern struct page *new_page_nodemask (struct page *page, -int preferred_nid,nodemask_t *nodemask); +extern struct page *alloc_migration_target (struct page *page,unsigned long private);extern int isolate_movable_page (struct page *page,isolate_mode_t mode);extern void putback_movable_page (struct page *page);
@@ -59,8 +60,8 @@ static inline int migrate_pages(struct l free_page_t free, unsigned long private, enum migrate_mode mode, int reason) { return -ENOSYS; } -static inline struct page *new_page_nodemask (struct page *page, -int preferred_nid,nodemask_t *nodemask) +static inline struct page *alloc_migration_target (struct page *page, +unsigned long private) {return NULL ; }static inline int isolate_movable_page (struct page *page,isolate_mode_t mode) {return -EBUSY ; }
mm/internal.h renamed from mm/internal.h~mm-migrate-make-a-standard-migration-target-allocation-function +7 -0
@@ -614,4 +614,11 @@ static inline bool is_migrate_highatomicvoid setup_zone_pageset (struct zone *zone);extern struct page *alloc_new_node_page (struct page *page,unsigned long node); + +struct migration_target_control { +int nid;/* preferred node id */ +nodemask_t *nmask; +gfp_t gfp_mask; +}; +#endif /* __MM_INTERNAL_H */
mm/memory-failure.c renamed from mm/memory-failure.c~mm-migrate-make-a-standard-migration-target-allocation-function +5 -2
@@ -1648,9 +1648,12 @@ EXPORT_SYMBOL(unpoison_memory);static struct page *new_page (struct page *p,unsigned long private) { -int nid =page_to_nid (p); +struct migration_target_control mtc = { + .nid =page_to_nid (p), + .gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; -return new_page_nodemask (p, nid, &node_states[N_MEMORY ]); +return alloc_migration_target (p, (unsigned long )&mtc); }/*
mm/memory_hotplug.c renamed from mm/memory_hotplug.c~mm-migrate-make-a-standard-migration-target-allocation-function +8 -4
@@ -1276,19 +1276,23 @@ found:static struct page *new_node_page (struct page *page,unsigned long private) { -int nid =page_to_nid (page);nodemask_t nmask = node_states[N_MEMORY ]; +struct migration_target_control mtc = { + .nid =page_to_nid (page), + .nmask = &nmask, + .gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + };/* * try to allocate from a different node but reuse this node if there * are no other online nodes to be used (e.g. we are offlining a part * of the only existing node) */ -node_clear (nid, nmask); +node_clear (mtc.nid, nmask);if (nodes_empty (nmask)) -node_set (nid, nmask); +node_set (mtc.nid, nmask); -return new_page_nodemask (page, nid, &nmask); +return alloc_migration_target (page, (unsigned long )&mtc); } static int
mm/migrate.c renamed from mm/migrate.c~mm-migrate-make-a-standard-migration-target-allocation-function +16 -10
@@ -1538,19 +1538,26 @@ out:return rc; } -struct page *new_page_nodemask (struct page *page, -int preferred_nid,nodemask_t *nodemask) +struct page *alloc_migration_target (struct page *page,unsigned long private) { -gfp_t gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; +struct migration_target_control *mtc; +gfp_t gfp_mask;unsigned int order =0 ;struct page *new_page =NULL ; +int nid; +int zidx; + + mtc = (struct migration_target_control *)private; + gfp_mask = mtc->gfp_mask; + nid = mtc->nid; +if (nid ==NUMA_NO_NODE ) + nid =page_to_nid (page);if (PageHuge (page)) {struct hstate *h =page_hstate (compound_head (page)); - gfp_mask =htlb_alloc_mask (h); -return alloc_huge_page_nodemask (h, preferred_nid, - nodemask, gfp_mask); + gfp_mask =htlb_modify_alloc_mask (h, gfp_mask); +return alloc_huge_page_nodemask (h, nid, mtc->nmask, gfp_mask); }if (PageTransHuge (page)) {
@@ -1562,12 +1569,11 @@ struct page *new_page_nodemask(struct pa gfp_mask |=GFP_TRANSHUGE ; order =HPAGE_PMD_ORDER ; } - -if (PageHighMem (page) || (zone_idx (page_zone (page)) ==ZONE_MOVABLE )) + zidx =zone_idx (page_zone (page)); +if (is_highmem_idx (zidx) || zidx ==ZONE_MOVABLE ) gfp_mask |= __GFP_HIGHMEM; - new_page =__alloc_pages_nodemask (gfp_mask, order, - preferred_nid, nodemask); + new_page =__alloc_pages_nodemask (gfp_mask, order, nid, mtc->nmask);if (new_page &&PageTransHuge (new_page))prep_transhuge_page (new_page);
mm/page_isolation.c renamed from mm/page_isolation.c~mm-migrate-make-a-standard-migration-target-allocation-function +5 -2
@@ -309,7 +309,10 @@ int test_pages_isolated(unsigned long ststruct page *alloc_migrate_target (struct page *page,unsigned long private) { -int nid =page_to_nid (page); +struct migration_target_control mtc = { + .nid =page_to_nid (page), + .gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + }; -return new_page_nodemask (page, nid, &node_states[N_MEMORY ]); +return alloc_migration_target (page, (unsigned long )&mtc); }
_
Andrew Morton
maintainerPATCH 136/165 mm/mempolicy: use a standard migration target allocation callback
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/mempolicy: use a standard migration target allocation callback
There is a well-defined migration target allocation callback. Use it.
---
mm/internal.h | 1 - mm/mempolicy.c | 31 ++++++------------------------- mm/migrate.c | 8 ++++++-- 3 files changed, 12 insertions(+), 28 deletions(-)
mm/internal.h renamed from mm/internal.h~mm-mempolicy-use-a-standard-migration-target-allocation-callback +0 -1
@@ -613,7 +613,6 @@ static inline bool is_migrate_highatomic }void setup_zone_pageset (struct zone *zone); -extern struct page *alloc_new_node_page (struct page *page,unsigned long node);struct migration_target_control {int nid;/* preferred node id */
mm/mempolicy.c renamed from mm/mempolicy.c~mm-mempolicy-use-a-standard-migration-target-allocation-callback +6 -25
@@ -1065,29 +1065,6 @@ static int migrate_page_add(struct pagereturn 0 ; } -/* page allocation callback for NUMA node migration */ -struct page *alloc_new_node_page (struct page *page,unsigned long node) -{ -if (PageHuge (page)) { -struct hstate *h =page_hstate (compound_head (page)); -gfp_t gfp_mask =htlb_alloc_mask (h) | __GFP_THISNODE; - -return alloc_huge_page_nodemask (h, node,NULL , gfp_mask); - }else if (PageTransHuge (page)) { -struct page *thp; - - thp =alloc_pages_node (node, - (GFP_TRANSHUGE | __GFP_THISNODE), -HPAGE_PMD_ORDER ); -if (!thp) -return NULL ; -prep_transhuge_page (thp); -return thp; - }else -return __alloc_pages_node (node,GFP_HIGHUSER_MOVABLE | - __GFP_THISNODE,0 ); -} -/* * Migrate pages from one node to a target node. * Returns error or the number of pages not migrated.
@@ -1098,6 +1075,10 @@ static int migrate_to_node(struct mm_strnodemask_t nmask;LIST_HEAD (pagelist);int err =0 ; +struct migration_target_control mtc = { + .nid = dest, + .gfp_mask =GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, + };nodes_clear (nmask);node_set (source, nmask);
@@ -1112,8 +1093,8 @@ static int migrate_to_node(struct mm_str flags | MPOL_MF_DISCONTIG_OK, &pagelist);if (!list_empty (&pagelist)) { - err =migrate_pages (&pagelist, alloc_new_node_page,NULL , dest, -MIGRATE_SYNC ,MR_SYSCALL ); + err =migrate_pages (&pagelist, alloc_migration_target,NULL , + (unsigned long )&mtc,MIGRATE_SYNC ,MR_SYSCALL );if (err)putback_movable_pages (&pagelist); }
mm/migrate.c renamed from mm/migrate.c~mm-mempolicy-use-a-standard-migration-target-allocation-callback +6 -2
@@ -1598,9 +1598,13 @@ static int do_move_pages_to_node(struct struct list_head *pagelist, int node) { int err; +struct migration_target_control mtc = { + .nid = node, + .gfp_mask =GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, + }; - err =migrate_pages (pagelist, alloc_new_node_page,NULL , node, -MIGRATE_SYNC ,MR_SYSCALL ); + err =migrate_pages (pagelist, alloc_migration_target,NULL , + (unsigned long )&mtc,MIGRATE_SYNC ,MR_SYSCALL );if (err)putback_movable_pages (pagelist);return err;
_
Andrew Morton
maintainerPATCH 137/165 mm/page_alloc: remove a wrapper for alloc_migration_target()
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/page_alloc: remove a wrapper for alloc_migration_target()
There is a well-defined standard migration target callback. Use it directly.
---
mm/page_alloc.c | 8 ++++++-- mm/page_isolation.c | 10 ---------- 2 files changed, 6 insertions(+), 12 deletions(-)
mm/page_alloc.c renamed from mm/page_alloc.c~mm-page_alloc-remove-a-wrapper-for-alloc_migration_target +6 -2
@@ -8347,6 +8347,10 @@ static int __alloc_contig_migrate_range(unsigned long pfn = start;unsigned int tries =0 ;int ret =0 ; +struct migration_target_control mtc = { + .nid =zone_to_nid (cc->zone), + .gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, + };migrate_prep ();
@@ -8373,8 +8377,8 @@ static int __alloc_contig_migrate_range( &cc->migratepages); cc->nr_migratepages -= nr_reclaimed; - ret =migrate_pages (&cc->migratepages, alloc_migrate_target, -NULL ,0 , cc->mode,MR_CONTIG_RANGE ); + ret =migrate_pages (&cc->migratepages, alloc_migration_target, +NULL , (unsigned long )&mtc, cc->mode,MR_CONTIG_RANGE ); }if (ret <0 ) {putback_movable_pages (&cc->migratepages);
mm/page_isolation.c renamed from mm/page_isolation.c~mm-page_alloc-remove-a-wrapper-for-alloc_migration_target +0 -10
@@ -306,13 +306,3 @@ int test_pages_isolated(unsigned long streturn pfn < end_pfn ? -EBUSY :0 ; } - -struct page *alloc_migrate_target (struct page *page,unsigned long private) -{ -struct migration_target_control mtc = { - .nid =page_to_nid (page), - .gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, - }; - -return alloc_migration_target (page, (unsigned long )&mtc); -}
_
Andrew Morton
maintainerPATCH 138/165 mm/gup: restrict CMA region by using allocation scope API
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/gup: restrict CMA region by using allocation scope API
We have well defined scope API to exclude CMA region. Use it rather than manipulating gfp_mask manually. With this change, we can now restore __GFP_MOVABLE for gfp_mask like as usual migration target allocation. It would result in that the ZONE_MOVABLE is also searched by page allocator. For hugetlb, gfp_mask is redefined since it has a regular allocation mask filter for migration target. __GPF_NOWARN is added to hugetlb gfp_mask filter since a new user for gfp_mask filter, gup, want to be silent when allocation fails.
Note that this can be considered as a fix for the commit 9a4e9f3b2d73 ("mm: update get_user_pages_longterm to migrate pages allocated from CMA region"). However, "Fixes" tag isn't added here since it is just suboptimal but it doesn't cause any problem.
---
include/linux/hugetlb.h | 2 ++ mm/gup.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-)
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~mm-gup-restrict-cma-region-by-using-allocation-scope-api +2 -0
@@ -710,6 +710,8 @@ static inline gfp_t htlb_modify_alloc_ma/* Some callers might want to enforce node */ modified_mask |= (gfp_mask & __GFP_THISNODE); + modified_mask |= (gfp_mask & __GFP_NOWARN); +return modified_mask; }
mm/gup.c renamed from mm/gup.c~mm-gup-restrict-cma-region-by-using-allocation-scope-api +8 -9
@@ -1620,10 +1620,12 @@ static struct page *new_non_cma_page(str* Trying to allocate a page for migration. Ignore allocation * failure warnings. We don't force __GFP_THISNODE here because * this node here is the node where we have CMA reservation and -* in some case these nodes will have really less non movable +* in some case these nodes will have really less non CMA * allocation memory. +* +* Note that CMA region is prohibited by allocation scope. */ -gfp_t gfp_mask =GFP_USER | __GFP_NOWARN; +gfp_t gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_NOWARN;if (PageHighMem (page)) gfp_mask |= __GFP_HIGHMEM;
@@ -1631,6 +1633,8 @@ static struct page *new_non_cma_page(str#ifdef CONFIG_HUGETLB_PAGE if (PageHuge (page)) {struct hstate *h =page_hstate (page); + + gfp_mask =htlb_modify_alloc_mask (h, gfp_mask);/* * We don't want to dequeue from the pool because pool pages will * mostly be from the CMA region.
@@ -1645,11 +1649,6 @@ static struct page *new_non_cma_page(str*/ gfp_t thp_gfpmask =GFP_TRANSHUGE | __GFP_NOWARN; -/* -* Remove the movable mask so that we don't allocate from -* CMA area again. -*/ - thp_gfpmask &= ~__GFP_MOVABLE; thp =__alloc_pages_node (nid, thp_gfpmask,HPAGE_PMD_ORDER );if (!thp)return NULL ;
@@ -1795,7 +1794,6 @@ static long __gup_longterm_locked(struct vmas_tmp, NULL, gup_flags);if (gup_flags &FOLL_LONGTERM ) { -memalloc_nocma_restore (flags);if (rc <0 ) goto out;
@@ -1808,9 +1806,10 @@ static long __gup_longterm_locked(struct rc =check_and_migrate_cma_pages (tsk, mm, start, rc, pages, vmas_tmp, gup_flags); +out: +memalloc_nocma_restore (flags); } -out:if (vmas_tmp != vmas)kfree (vmas_tmp);return rc;
_
Andrew Morton
maintainerPATCH 139/165 mm/hugetlb: make hugetlb migration callback CMA aware
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/hugetlb: make hugetlb migration callback CMA aware
new_non_cma_page() in gup.c requires to allocate the new page that is not on the CMA area. new_non_cma_page() implements it by using allocation scope APIs.
However, there is a work-around for hugetlb. Normal hugetlb page allocation API for migration is alloc_huge_page_nodemask(). It consists of two steps. First is dequeing from the pool. Second is, if there is no available page on the queue, allocating by using the page allocator.
new_non_cma_page() can't use this API since first step (deque) isn't aware of scope API to exclude CMA area. So, new_non_cma_page() exports hugetlb internal function for the second step, alloc_migrate_huge_page(), to global scope and uses it directly. This is suboptimal since hugetlb pages on the queue cannot be utilized.
This patch tries to fix this situation by making the deque function on hugetlb CMA aware. In the deque function, CMA memory is skipped if PF_MEMALLOC_NOCMA flag is found.
---
include/linux/hugetlb.h | 2 -- mm/gup.c | 6 +----- mm/hugetlb.c | 11 +++++++++-- 3 files changed, 10 insertions(+), 9 deletions(-)
include/linux/hugetlb.h renamed from include/linux/hugetlb.h~mm-hugetlb-make-hugetlb-migration-callback-cma-aware +0 -2
@@ -511,8 +511,6 @@ struct page *alloc_huge_page_nodemask(st nodemask_t *nmask, gfp_t gfp_mask);struct page *alloc_huge_page_vma (struct hstate *h,struct vm_area_struct *vma,unsigned long address); -struct page *alloc_migrate_huge_page (struct hstate *h,gfp_t gfp_mask, -int nid,nodemask_t *nmask);int huge_add_to_page_cache (struct page *page,struct address_space *mapping,pgoff_t idx);
mm/gup.c renamed from mm/gup.c~mm-hugetlb-make-hugetlb-migration-callback-cma-aware +1 -5
@@ -1635,11 +1635,7 @@ static struct page *new_non_cma_page(strstruct hstate *h =page_hstate (page); gfp_mask =htlb_modify_alloc_mask (h, gfp_mask); -/* -* We don't want to dequeue from the pool because pool pages will -* mostly be from the CMA region. -*/ - return alloc_migrate_huge_page(h, gfp_mask, nid, NULL); + return alloc_huge_page_nodemask(h, nid, NULL, gfp_mask); }#endif if (PageTransHuge (page)) {
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-make-hugetlb-migration-callback-cma-aware +9 -2
@@ -19,6 +19,7 @@#include <linux/memblock.h> #include <linux/sysfs.h> #include <linux/slab.h> +#include <linux/sched/mm.h> #include <linux/mmdebug.h> #include <linux/sched/signal.h> #include <linux/rmap.h>
@@ -1040,10 +1041,16 @@ static void enqueue_huge_page(struct hststatic struct page *dequeue_huge_page_node_exact (struct hstate *h,int nid) {struct page *page; +bool nocma = !!(current->flags &PF_MEMALLOC_NOCMA ); + +list_for_each_entry (page, &h->hugepage_freelists[nid], lru) { +if (nocma &&is_migrate_cma_page (page)) +continue ; -list_for_each_entry (page, &h->hugepage_freelists[nid], lru)if (!PageHWPoison (page))break ; + } +/* * if 'non-isolated free hugepage' not found on the list, * the allocation fails.
@@ -1935,7 +1942,7 @@ out_unlock:return page; } -struct page *alloc_migrate_huge_page (struct hstate *h,gfp_t gfp_mask, +static struct page *alloc_migrate_huge_page (struct hstate *h,gfp_t gfp_mask,int nid,nodemask_t *nmask) {struct page *page;
_
Andrew Morton
maintainerPATCH 140/165 mm/gup: use a standard migration target allocation callback
In reply to Andrew MortonFrom: Joonsoo Kim <[email protected]>
Subject: mm/gup: use a standard migration target allocation callback
There is a well-defined migration target allocation callback. Use it.
---
mm/gup.c | 54 +++++------------------------------------------------ 1 file changed, 6 insertions(+), 48 deletions(-)
mm/gup.c renamed from mm/gup.c~mm-gup-use-a-standard-migration-target-allocation-callback +6 -48
@@ -1609,52 +1609,6 @@ static bool check_dax_vmas(struct vm_are }#ifdef CONFIG_CMA -static struct page *new_non_cma_page (struct page *page,unsigned long private) -{ -/* -* We want to make sure we allocate the new page from the same node -* as the source page. -*/ -int nid =page_to_nid (page); -/* -* Trying to allocate a page for migration. Ignore allocation -* failure warnings. We don't force __GFP_THISNODE here because -* this node here is the node where we have CMA reservation and -* in some case these nodes will have really less non CMA -* allocation memory. -* -* Note that CMA region is prohibited by allocation scope. -*/ -gfp_t gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_NOWARN; - -if (PageHighMem (page)) - gfp_mask |= __GFP_HIGHMEM; - -#ifdef CONFIG_HUGETLB_PAGE -if (PageHuge (page)) { -struct hstate *h =page_hstate (page); - - gfp_mask =htlb_modify_alloc_mask (h, gfp_mask); -return alloc_huge_page_nodemask (h, nid,NULL , gfp_mask); - } -#endif -if (PageTransHuge (page)) { -struct page *thp; -/* -* ignore allocation failure warnings -*/ -gfp_t thp_gfpmask =GFP_TRANSHUGE | __GFP_NOWARN; - - thp =__alloc_pages_node (nid, thp_gfpmask,HPAGE_PMD_ORDER ); -if (!thp) -return NULL ; -prep_transhuge_page (thp); -return thp; - } - -return __alloc_pages_node (nid, gfp_mask,0 ); -} - static long check_and_migrate_cma_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
@@ -1669,6 +1623,10 @@ static long check_and_migrate_cma_pages(bool migrate_allow = true;LIST_HEAD (cma_page_list);long ret = nr_pages; +struct migration_target_control mtc = { + .nid =NUMA_NO_NODE , + .gfp_mask =GFP_USER | __GFP_MOVABLE | __GFP_NOWARN, + }; check_again:for (i =0 ; i < nr_pages;) {
@@ -1714,8 +1672,8 @@ check_again:for (i =0 ; i < nr_pages; i++)put_page (pages[i]); -if (migrate_pages (&cma_page_list, new_non_cma_page, -NULL ,0 ,MIGRATE_SYNC ,MR_CONTIG_RANGE )) { +if (migrate_pages (&cma_page_list, alloc_migration_target,NULL , + (unsigned long )&mtc,MIGRATE_SYNC ,MR_CONTIG_RANGE )) {/* * some of the pages failed migration. Do get_user_pages * without migration.
_
Andrew Morton
maintainerPATCH 141/165 mm: do page fault accounting in handle_mm_fault
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm: do page fault accounting in handle_mm_fault
Patch series "mm: Page fault accounting cleanups", v5.
This is v5 of the pf accounting cleanup series. It originates from Gerald Schaefer's report on an issue a week ago regarding to incorrect page fault accountings for retried page fault after commit 4064b9827063 ("mm: allow VM_FAULT_RETRY for multiple times"):
https://lore.kernel.org/lkml/20200610174811.44b94525@thinkpad/
What this series did:
- Correct page fault accounting: we do accounting for a page fault (no matter whether it's from #PF handling, or gup, or anything else) only with the one that completed the fault. For example, page fault retries should not be counted in page fault counters. Same to the perf events.
- Unify definition of PERF_COUNT_SW_PAGE_FAULTS: currently this perf event is used in an adhoc way across different archs.
Case (1): for many archs it's done at the entry of a page fault handler, so that it will also cover e.g. errornous faults.
Case (2): for some other archs, it is only accounted when the page fault is resolved successfully.
Case (3): there're still quite some archs that have not enabled this perf event.
Since this series will touch merely all the archs, we unify this perf event to always follow case (1), which is the one that makes most sense. And since we moved the accounting into handle_mm_fault, the other two MAJ/MIN perf events are well taken care of naturally.
- Unify definition of "major faults": the definition of "major fault" is slightly changed when used in accounting (not VM_FAULT_MAJOR). More information in patch 1.
- Always account the page fault onto the one that triggered the page fault. This does not matter much for #PF handlings, but mostly for gup. More information on this in patch 25.
Patchset layout:
Patch 1: Introduced the accounting in handle_mm_fault(), not enabled. Patch 2-23: Enable the new accounting for arch #PF handlers one by one. Patch 24: Enable the new accounting for the rest outliers (gup, iommu, etc.) Patch 25: Cleanup GUP task_struct pointer since it's not needed any more
This patch (of 25):
This is a preparation patch to move page fault accountings into the general code in handle_mm_fault(). This includes both the per task flt_maj/flt_min counters, and the major/minor page fault perf events. To do this, the pt_regs pointer is passed into handle_mm_fault().
PERF_COUNT_SW_PAGE_FAULTS should still be kept in per-arch page fault handlers.
So far, all the pt_regs pointer that passed into handle_mm_fault() is NULL, which means this patch should have no intented functional change.
---
arch/alpha/mm/fault.c | 2 - arch/arc/mm/fault.c | 2 - arch/arm/mm/fault.c | 2 - arch/arm64/mm/fault.c | 2 - arch/csky/mm/fault.c | 3 + arch/hexagon/mm/vm_fault.c | 2 - arch/ia64/mm/fault.c | 2 - arch/m68k/mm/fault.c | 2 - arch/microblaze/mm/fault.c | 2 - arch/mips/mm/fault.c | 2 - arch/nds32/mm/fault.c | 2 - arch/nios2/mm/fault.c | 2 - arch/openrisc/mm/fault.c | 2 - arch/parisc/mm/fault.c | 2 - arch/powerpc/mm/copro_fault.c | 2 - arch/powerpc/mm/fault.c | 2 - arch/riscv/mm/fault.c | 2 - arch/s390/mm/fault.c | 2 - arch/sh/mm/fault.c | 2 - arch/sparc/mm/fault_32.c | 4 +- arch/sparc/mm/fault_64.c | 2 - arch/um/kernel/trap.c | 2 - arch/x86/mm/fault.c | 2 - arch/xtensa/mm/fault.c | 2 - drivers/iommu/amd/iommu_v2.c | 2 - drivers/iommu/intel/svm.c | 3 + include/linux/mm.h | 7 ++- mm/gup.c | 4 +- mm/hmm.c | 3 + mm/ksm.c | 3 + mm/memory.c | 64 +++++++++++++++++++++++++++++++- 31 files changed, 103 insertions(+), 34 deletions(-)
arch/alpha/mm/fault.c renamed from arch/alpha/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -148,7 +148,7 @@ retry:/* If for any reason at all we couldn't handle the fault, make sure we exit gracefully rather than endlessly redo the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/arc/mm/fault.c renamed from arch/arc/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -130,7 +130,7 @@ retry: goto bad_area; } - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );/* Quick path to respond to signals */ if (fault_signal_pending (fault, regs)) {
arch/arm64/mm/fault.c renamed from arch/arm64/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -428,7 +428,7 @@ static vm_fault_t __do_page_fault(struct*/ if (!(vma->vm_flags & vm_flags))return VM_FAULT_BADACCESS ; -return handle_mm_fault (vma, addr &PAGE_MASK , mm_flags); +return handle_mm_fault (vma, addr &PAGE_MASK , mm_flags,NULL ); }static bool is_el0_instruction_abort (unsigned int esr)
arch/arm/mm/fault.c renamed from arch/arm/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -224,7 +224,7 @@ good_area: goto out; } -return handle_mm_fault (vma, addr &PAGE_MASK , flags); +return handle_mm_fault (vma, addr &PAGE_MASK , flags,NULL ); check_stack:/* Don't allow expansion below FIRST_USER_ADDRESS */
arch/csky/mm/fault.c renamed from arch/csky/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +2 -1
@@ -150,7 +150,8 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, write ?FAULT_FLAG_WRITE :0 ); + fault =handle_mm_fault (vma, address, write ?FAULT_FLAG_WRITE :0 , +NULL );if (unlikely (fault &VM_FAULT_ERROR )) {if (fault &VM_FAULT_OOM ) goto out_of_memory;
arch/hexagon/mm/vm_fault.c renamed from arch/hexagon/mm/vm_fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -88,7 +88,7 @@ good_area:break ; } - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/ia64/mm/fault.c renamed from arch/ia64/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -143,7 +143,7 @@ retry:* sure we exit gracefully rather than endlessly redo the * fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/m68k/mm/fault.c renamed from arch/m68k/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -134,7 +134,7 @@ good_area:* the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );pr_debug ("handle_mm_fault returns %x\n" , fault);if (fault_signal_pending (fault, regs))
arch/microblaze/mm/fault.c renamed from arch/microblaze/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -214,7 +214,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/mips/mm/fault.c renamed from arch/mips/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -152,7 +152,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/nds32/mm/fault.c renamed from arch/nds32/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -206,7 +206,7 @@ good_area:* the fault. */ - fault =handle_mm_fault (vma, addr, flags); + fault =handle_mm_fault (vma, addr, flags,NULL );/* * If we need to retry but a fatal signal is pending, handle the
arch/nios2/mm/fault.c renamed from arch/nios2/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -131,7 +131,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/openrisc/mm/fault.c renamed from arch/openrisc/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -159,7 +159,7 @@ good_area:* the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/parisc/mm/fault.c renamed from arch/parisc/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -302,7 +302,7 @@ good_area:* fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/mm/copro_fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -64,7 +64,7 @@ int copro_handle_mm_fault(struct mm_stru } ret =0 ; - *flt =handle_mm_fault (vma, ea, is_write ?FAULT_FLAG_WRITE :0 ); + *flt =handle_mm_fault (vma, ea, is_write ?FAULT_FLAG_WRITE :0 ,NULL );if (unlikely (*flt &VM_FAULT_ERROR )) {if (*flt &VM_FAULT_OOM ) { ret = -ENOMEM ;
arch/powerpc/mm/fault.c renamed from arch/powerpc/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -511,7 +511,7 @@ retry:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL ); major |= fault &VM_FAULT_MAJOR ;
arch/riscv/mm/fault.c renamed from arch/riscv/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -109,7 +109,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, addr, flags); + fault =handle_mm_fault (vma, addr, flags,NULL );/* * If we need to retry but a fatal signal is pending, handle the
arch/s390/mm/fault.c renamed from arch/s390/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -476,7 +476,7 @@ retry:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs)) { fault =VM_FAULT_SIGNAL ;if (flags &FAULT_FLAG_RETRY_NOWAIT )
arch/sh/mm/fault.c renamed from arch/sh/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -482,7 +482,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (unlikely (fault & (VM_FAULT_RETRY |VM_FAULT_ERROR )))if (mm_fault_error (regs, error_code, address, fault))
arch/sparc/mm/fault_32.c renamed from arch/sparc/mm/fault_32.c~mm-do-page-fault-accounting-in-handle_mm_fault +2 -2
@@ -234,7 +234,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
@@ -410,7 +410,7 @@ good_area:if (!(vma->vm_flags & (VM_READ |VM_EXEC ))) goto bad_area; } -switch (handle_mm_fault (vma, address, flags)) { +switch (handle_mm_fault (vma, address, flags,NULL )) {case VM_FAULT_SIGBUS :case VM_FAULT_OOM : goto do_sigbus;
arch/sparc/mm/fault_64.c renamed from arch/sparc/mm/fault_64.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -422,7 +422,7 @@ good_area: goto bad_area; } - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs)) goto exit_exception;
arch/um/kernel/trap.c renamed from arch/um/kernel/trap.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -71,7 +71,7 @@ good_area: do { vm_fault_t fault; - fault = handle_mm_fault(vma, address, flags); + fault = handle_mm_fault(vma, address, flags, NULL); if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) goto out_nosemaphore;
arch/x86/mm/fault.c renamed from arch/x86/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -1291,7 +1291,7 @@ good_area:* userland). The return to userland is identified whenever * FAULT_FLAG_USER|FAULT_FLAG_KILLABLE are both set in flags. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL ); major |= fault &VM_FAULT_MAJOR ;/* Quick path to respond to signals */
arch/xtensa/mm/fault.c renamed from arch/xtensa/mm/fault.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -107,7 +107,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags); + fault =handle_mm_fault (vma, address, flags,NULL );if (fault_signal_pending (fault, regs))return ;
drivers/iommu/amd/iommu_v2.c renamed from drivers/iommu/amd/iommu_v2.c~mm-do-page-fault-accounting-in-handle_mm_fault +1 -1
@@ -495,7 +495,7 @@ static void do_fault(struct work_structif (access_error (vma, fault)) goto out; - ret =handle_mm_fault (vma, address, flags); + ret =handle_mm_fault (vma, address, flags,NULL ); out:mmap_read_unlock (mm);
drivers/iommu/intel/svm.c renamed from drivers/iommu/intel/svm.c~mm-do-page-fault-accounting-in-handle_mm_fault +2 -1
@@ -872,7 +872,8 @@ static irqreturn_t prq_event_thread(int goto invalid; ret =handle_mm_fault (vma, address, - req->wr_req ?FAULT_FLAG_WRITE :0 ); + req->wr_req ?FAULT_FLAG_WRITE :0 , +NULL );if (ret &VM_FAULT_ERROR ) goto invalid;
include/linux/mm.h renamed from include/linux/mm.h~mm-do-page-fault-accounting-in-handle_mm_fault +5 -2
@@ -38,6 +38,7 @@ struct file_ra_state;struct user_struct ;struct writeback_control ;struct bdi_writeback ; +struct pt_regs ;void init_mm_internals (void );
@@ -1658,7 +1659,8 @@ int invalidate_inode_page(struct page *p#ifdef CONFIG_MMU extern vm_fault_t handle_mm_fault (struct vm_area_struct *vma, -unsigned long address,unsigned int flags); +unsigned long address,unsigned int flags, +struct pt_regs *regs);extern int fixup_user_fault (struct task_struct *tsk,struct mm_struct *mm,unsigned long address,unsigned int fault_flags,bool *unlocked);
@@ -1668,7 +1670,8 @@ void unmap_mapping_range(struct address_ loff_t const holebegin, loff_t const holelen, int even_cows);#else static inline vm_fault_t handle_mm_fault (struct vm_area_struct *vma, -unsigned long address,unsigned int flags) +unsigned long address,unsigned int flags, +struct pt_regs *regs) {/* should never happen if there's no MMU */ BUG ();
mm/gup.c renamed from mm/gup.c~mm-do-page-fault-accounting-in-handle_mm_fault +2 -2
@@ -884,7 +884,7 @@ static int faultin_page(struct task_stru fault_flags |=FAULT_FLAG_TRIED ; } - ret =handle_mm_fault (vma, address, fault_flags); + ret =handle_mm_fault (vma, address, fault_flags,NULL );if (ret &VM_FAULT_ERROR ) {int err =vm_fault_to_errno (ret, *flags);
@@ -1238,7 +1238,7 @@ retry: fatal_signal_pending(current))return -EINTR ; - ret =handle_mm_fault (vma, address, fault_flags); + ret =handle_mm_fault (vma, address, fault_flags,NULL ); major |= ret &VM_FAULT_MAJOR ;if (ret &VM_FAULT_ERROR ) {int err =vm_fault_to_errno (ret,0 );
mm/hmm.c renamed from mm/hmm.c~mm-do-page-fault-accounting-in-handle_mm_fault +2 -1
@@ -75,7 +75,8 @@ static int hmm_vma_fault(unsigned long a }for (; addr < end; addr +=PAGE_SIZE ) -if (handle_mm_fault (vma, addr, fault_flags) &VM_FAULT_ERROR ) +if (handle_mm_fault (vma, addr, fault_flags,NULL ) & +VM_FAULT_ERROR )return -EFAULT ;return -EBUSY ; }
mm/ksm.c renamed from mm/ksm.c~mm-do-page-fault-accounting-in-handle_mm_fault +2 -1
@@ -480,7 +480,8 @@ static int break_ksm(struct vm_area_strubreak ;if (PageKsm (page)) ret =handle_mm_fault (vma, addr, -FAULT_FLAG_WRITE |FAULT_FLAG_REMOTE ); +FAULT_FLAG_WRITE |FAULT_FLAG_REMOTE , +NULL );else ret =VM_FAULT_WRITE ;put_page (page);
mm/memory.c renamed from mm/memory.c~mm-do-page-fault-accounting-in-handle_mm_fault +63 -1
88 lines not on this page · raw message
_
Andrew Morton
maintainerPATCH 142/165 mm/alpha: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/alpha: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault().
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/alpha/mm/fault.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/alpha/mm/fault.c renamed from arch/alpha/mm/fault.c~mm-alpha-use-general-page-fault-accounting +3 -5
@@ -25,6 +25,7 @@#include <linux/interrupt.h> #include <linux/extable.h> #include <linux/uaccess.h> +#include <linux/perf_event.h> extern void die_if_kernel (char *,struct pt_regs *,long ,unsigned long *);
@@ -116,6 +117,7 @@ do_page_fault(unsigned long address, uns#endif if (user_mode (regs)) flags |=FAULT_FLAG_USER ; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry:mmap_read_lock (mm); vma =find_vma (mm, address);
@@ -148,7 +150,7 @@ retry:/* If for any reason at all we couldn't handle the fault, make sure we exit gracefully rather than endlessly redo the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -164,10 +166,6 @@ retry: }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 143/165 mm/arc: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/arc: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem.
---
arch/arc/mm/fault.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
arch/arc/mm/fault.c renamed from arch/arc/mm/fault.c~mm-arc-use-general-page-fault-accounting +3 -15
@@ -105,6 +105,7 @@ void do_page_fault(unsigned long addressif (write) flags |=FAULT_FLAG_WRITE ; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry:mmap_read_lock (mm);
@@ -130,7 +131,7 @@ retry: goto bad_area; } - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);/* Quick path to respond to signals */ if (fault_signal_pending (fault, regs)) {
@@ -155,22 +156,9 @@ bad_area:* Major/minor page fault accounting * (in case of retry we only land here once) */ -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); - -if (likely (!(fault &VM_FAULT_ERROR ))) { -if (fault &VM_FAULT_MAJOR ) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , - regs, address); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , - regs, address); - } - +if (likely (!(fault &VM_FAULT_ERROR )))/* Normal return path: fault Handled Gracefully */ return ; - }if (!user_mode (regs)) goto no_context;
_
Andrew Morton
maintainerPATCH 144/165 mm/arm: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/arm: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened. To do this, we need to pass the pt_regs pointer into __do_page_fault().
Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem.
---
arch/arm/mm/fault.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)
arch/arm/mm/fault.c renamed from arch/arm/mm/fault.c~mm-arm-use-general-page-fault-accounting +6 -19
@@ -202,7 +202,8 @@ static inline bool access_error(unsignedstatic vm_fault_t __kprobes __do_page_fault (struct mm_struct *mm,unsigned long addr,unsigned int fsr, -unsigned int flags,struct task_struct *tsk) +unsigned int flags,struct task_struct *tsk, +struct pt_regs *regs) {struct vm_area_struct *vma;vm_fault_t fault;
@@ -224,7 +225,7 @@ good_area: goto out; } -return handle_mm_fault (vma, addr &PAGE_MASK , flags,NULL ); +return handle_mm_fault (vma, addr &PAGE_MASK , flags, regs); check_stack:/* Don't allow expansion below FIRST_USER_ADDRESS */
@@ -266,6 +267,8 @@ do_page_fault(unsigned long addr, unsignif ((fsr &FSR_WRITE ) && !(fsr &FSR_CM )) flags |=FAULT_FLAG_WRITE ; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, addr); +/* * As per x86, we may deadlock here. However, since the kernel only * validly references user space from well defined areas of the code,
@@ -290,7 +293,7 @@ retry:#endif } - fault =__do_page_fault (mm, addr, fsr, flags, tsk); + fault =__do_page_fault (mm, addr, fsr, flags, tsk, regs);/* If we need to retry but a fatal signal is pending, handle the * signal first. We do not need to release the mmap_lock because
@@ -302,23 +305,7 @@ retry:return 0 ; } -/* -* Major/minor page fault accounting is only done on the -* initial attempt. If we go through a retry, it is extremely -* likely that the page will be found in page cache at that point. -*/ - -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, addr);if (!(fault &VM_FAULT_ERROR ) && flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , - regs, addr); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , - regs, addr); - }if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; goto retry;
_
Andrew Morton
maintainerPATCH 145/165 mm/arm64: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/arm64: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened. To do this, we pass pt_regs pointer into __do_page_fault().
---
arch/arm64/mm/fault.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-)
arch/arm64/mm/fault.c renamed from arch/arm64/mm/fault.c~mm-arm64-use-general-page-fault-accounting +6 -23
@@ -404,7 +404,8 @@ static void do_bad_area(unsigned long ad#define VM_FAULT_BADACCESS 0x020000static vm_fault_t __do_page_fault (struct mm_struct *mm,unsigned long addr, -unsigned int mm_flags,unsigned long vm_flags) +unsigned int mm_flags,unsigned long vm_flags, +struct pt_regs *regs) {struct vm_area_struct *vma =find_vma (mm, addr);
@@ -428,7 +429,7 @@ static vm_fault_t __do_page_fault(struct*/ if (!(vma->vm_flags & vm_flags))return VM_FAULT_BADACCESS ; -return handle_mm_fault (vma, addr &PAGE_MASK , mm_flags,NULL ); +return handle_mm_fault (vma, addr &PAGE_MASK , mm_flags, regs); }static bool is_el0_instruction_abort (unsigned int esr)
@@ -450,7 +451,7 @@ static int __kprobes do_page_fault(unsig {const struct fault_info *inf;struct mm_struct *mm = current->mm; -vm_fault_t fault, major =0 ; +vm_fault_t fault;unsigned long vm_flags =VM_ACCESS_FLAGS ;unsigned int mm_flags =FAULT_FLAG_DEFAULT ;
@@ -516,8 +517,7 @@ retry:#endif } - fault =__do_page_fault (mm, addr, mm_flags, vm_flags); - major |= fault &VM_FAULT_MAJOR ; + fault =__do_page_fault (mm, addr, mm_flags, vm_flags, regs);/* Quick path to respond to signals */ if (fault_signal_pending (fault, regs)) {
@@ -538,25 +538,8 @@ retry:* Handle the "normal" (no error) case first. */ if (likely (!(fault & (VM_FAULT_ERROR |VM_FAULT_BADMAP | -VM_FAULT_BADACCESS )))) { -/* -* Major/minor page fault accounting is only done -* once. If we go through a retry, it is extremely -* likely that the page will be found in page cache at -* that point. -*/ -if (major) { - current->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , regs, - addr); - }else { - current->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , regs, - addr); - } - +VM_FAULT_BADACCESS ))))return 0 ; - }/* * If we are in kernel mode at this point, we have no context to
_
Andrew Morton
maintainerPATCH 146/165 mm/csky: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/csky: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
---
arch/csky/mm/fault.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
arch/csky/mm/fault.c renamed from arch/csky/mm/fault.c~mm-csky-use-general-page-fault-accounting +1 -11
@@ -151,7 +151,7 @@ good_area:* the fault. */ fault =handle_mm_fault (vma, address, write ?FAULT_FLAG_WRITE :0 , -NULL ); + regs);if (unlikely (fault &VM_FAULT_ERROR )) {if (fault &VM_FAULT_OOM ) goto out_of_memory;
@@ -161,16 +161,6 @@ good_area: goto bad_area;BUG (); } -if (fault &VM_FAULT_MAJOR ) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , regs, - address); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , regs, - address); - } -mmap_read_unlock (mm);return ;
_
Andrew Morton
maintainerPATCH 147/165 mm/hexagon: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/hexagon: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/hexagon/mm/vm_fault.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/hexagon/mm/vm_fault.c renamed from arch/hexagon/mm/vm_fault.c~mm-hexagon-use-general-page-fault-accounting +4 -5
@@ -18,6 +18,7 @@#include <linux/signal.h> #include <linux/extable.h> #include <linux/hardirq.h> +#include <linux/perf_event.h> /* * Decode of hardware exception sends us to one of several
@@ -53,6 +54,8 @@ void do_page_fault(unsigned long addressif (user_mode (regs)) flags |=FAULT_FLAG_USER ; + +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry:mmap_read_lock (mm); vma =find_vma (mm, address);
@@ -88,7 +91,7 @@ good_area:break ; } - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -96,10 +99,6 @@ good_area:/* The most common case -- we are done. */ if (likely (!(fault &VM_FAULT_ERROR ))) {if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ; goto retry;
_
Andrew Morton
maintainerPATCH 148/165 mm/ia64: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/ia64: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/ia64/mm/fault.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/ia64/mm/fault.c renamed from arch/ia64/mm/fault.c~mm-ia64-use-general-page-fault-accounting +4 -5
@@ -14,6 +14,7 @@#include <linux/kdebug.h> #include <linux/prefetch.h> #include <linux/uaccess.h> +#include <linux/perf_event.h> #include <asm/processor.h> #include <asm/exception.h>
@@ -105,6 +106,8 @@ ia64_do_page_fault (unsigned long addres flags |=FAULT_FLAG_USER ;if (mask &VM_WRITE ) flags |=FAULT_FLAG_WRITE ; + +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry:mmap_read_lock (mm);
@@ -143,7 +146,7 @@ retry:* sure we exit gracefully rather than endlessly redo the * fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -166,10 +169,6 @@ retry: }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 149/165 mm/m68k: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/m68k: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/m68k/mm/fault.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/m68k/mm/fault.c renamed from arch/m68k/mm/fault.c~mm-m68k-use-general-page-fault-accounting +4 -10
@@ -12,6 +12,7 @@#include <linux/interrupt.h> #include <linux/module.h> #include <linux/uaccess.h> +#include <linux/perf_event.h> #include <asm/setup.h> #include <asm/traps.h>
@@ -84,6 +85,8 @@ int do_page_fault(struct pt_regs *regs,if (user_mode (regs)) flags |=FAULT_FLAG_USER ; + +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry:mmap_read_lock (mm);
@@ -134,7 +137,7 @@ good_area:* the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);pr_debug ("handle_mm_fault returns %x\n" , fault);if (fault_signal_pending (fault, regs))
@@ -150,16 +153,7 @@ good_area:BUG (); } -/* -* Major/minor page fault accounting is only done on the -* initial attempt. If we go through a retry, it is extremely -* likely that the page will be found in page cache at that point. -*/ if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 150/165 mm/microblaze: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/microblaze: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/microblaze/mm/fault.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/microblaze/mm/fault.c renamed from arch/microblaze/mm/fault.c~mm-microblaze-use-general-page-fault-accounting +4 -5
@@ -28,6 +28,7 @@#include <linux/mman.h> #include <linux/mm.h> #include <linux/interrupt.h> +#include <linux/perf_event.h> #include <asm/page.h> #include <asm/mmu.h>
@@ -121,6 +122,8 @@ void do_page_fault(struct pt_regs *regs,if (user_mode (regs)) flags |=FAULT_FLAG_USER ; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); +/* When running in the kernel we expect faults to occur only to * addresses in user space. All other faults represent errors in the * kernel and should generate an OOPS. Unfortunately, in the case of an
@@ -214,7 +217,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -230,10 +233,6 @@ good_area: }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (unlikely (fault &VM_FAULT_MAJOR )) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 151/165 mm/mips: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/mips: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem.
---
arch/mips/mm/fault.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
arch/mips/mm/fault.c renamed from arch/mips/mm/fault.c~mm-mips-use-general-page-fault-accounting +3 -11
@@ -96,6 +96,8 @@ static void __kprobes __do_page_fault(stif (user_mode (regs)) flags |=FAULT_FLAG_USER ; + +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry:mmap_read_lock (mm); vma =find_vma (mm, address);
@@ -152,12 +154,11 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address);if (unlikely (fault &VM_FAULT_ERROR )) {if (fault &VM_FAULT_OOM ) goto out_of_memory;
@@ -168,15 +169,6 @@ good_area:BUG (); }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , - regs, address); - tsk->maj_flt++; - }else { -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , - regs, address); - tsk->min_flt++; - }if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 152/165 mm/nds32: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/nds32: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Fix PERF_COUNT_SW_PAGE_FAULTS perf event manually for page fault retries, by moving it before taking mmap_sem.
---
arch/nds32/mm/fault.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
arch/nds32/mm/fault.c renamed from arch/nds32/mm/fault.c~mm-nds32-use-general-page-fault-accounting +3 -16
@@ -121,6 +121,8 @@ void do_page_fault(unsigned long entry,if (unlikely (faulthandler_disabled () || !mm)) goto no_context; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, addr); +/* * As per x86, we may deadlock here. However, since the kernel only * validly references user space from well defined areas of the code,
@@ -206,7 +208,7 @@ good_area:* the fault. */ - fault =handle_mm_fault (vma, addr, flags,NULL ); + fault =handle_mm_fault (vma, addr, flags, regs);/* * If we need to retry but a fatal signal is pending, handle the
@@ -228,22 +230,7 @@ good_area: goto bad_area; } -/* -* Major/minor page fault accounting is only done on the initial -* attempt. If we go through a retry, it is extremely likely that the -* page will be found in page cache at that point. -*/ -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, addr);if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ , -1 , regs, addr); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN , -1 , regs, addr); - }if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 153/165 mm/nios2: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/nios2: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/nios2/mm/fault.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/nios2/mm/fault.c renamed from arch/nios2/mm/fault.c~mm-nios2-use-general-page-fault-accounting +4 -10
@@ -24,6 +24,7 @@#include <linux/mm.h> #include <linux/extable.h> #include <linux/uaccess.h> +#include <linux/perf_event.h> #include <asm/mmu_context.h> #include <asm/traps.h>
@@ -83,6 +84,8 @@ asmlinkage void do_page_fault(struct pt_if (user_mode (regs)) flags |=FAULT_FLAG_USER ; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); +if (!mmap_read_trylock (mm)) {if (!user_mode (regs) && !search_exception_tables (regs->ea)) goto bad_area_nosemaphore;
@@ -131,7 +134,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -146,16 +149,7 @@ good_area:BUG (); } -/* -* Major/minor page fault accounting is only done on the -* initial attempt. If we go through a retry, it is extremely -* likely that the page will be found in page cache at that point. -*/ if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 154/165 mm/openrisc: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/openrisc: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/openrisc/mm/fault.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
arch/openrisc/mm/fault.c renamed from arch/openrisc/mm/fault.c~mm-openrisc-use-general-page-fault-accounting +4 -5
@@ -15,6 +15,7 @@#include <linux/interrupt.h> #include <linux/extable.h> #include <linux/sched/signal.h> +#include <linux/perf_event.h> #include <linux/uaccess.h> #include <asm/siginfo.h>
@@ -103,6 +104,8 @@ asmlinkage void do_page_fault(struct pt_if (in_interrupt () || !mm) goto no_context; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); + retry:mmap_read_lock (mm); vma =find_vma (mm, address);
@@ -159,7 +162,7 @@ good_area:* the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -176,10 +179,6 @@ good_area:if (flags &FAULT_FLAG_ALLOW_RETRY ) {/*RGD modeled on Cris */ -if (fault &VM_FAULT_MAJOR ) - tsk->maj_flt++; -else - tsk->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 155/165 mm/parisc: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/parisc: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Add the missing PERF_COUNT_SW_PAGE_FAULTS perf events too. Note, the other two perf events (PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]) were done in handle_mm_fault().
---
arch/parisc/mm/fault.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/parisc/mm/fault.c renamed from arch/parisc/mm/fault.c~mm-parisc-use-general-page-fault-accounting +3 -5
@@ -18,6 +18,7 @@#include <linux/extable.h> #include <linux/uaccess.h> #include <linux/hugetlb.h> +#include <linux/perf_event.h> #include <asm/traps.h>
@@ -281,6 +282,7 @@ void do_page_fault(struct pt_regs *regs, acc_type =parisc_acctyp (code, regs->iir);if (acc_type &VM_WRITE ) flags |=FAULT_FLAG_WRITE ; +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); retry:mmap_read_lock (mm); vma =find_vma_prev (mm, address, &prev_vma);
@@ -302,7 +304,7 @@ good_area:* fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -323,10 +325,6 @@ good_area:BUG (); }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) {/* * No need to mmap_read_unlock(mm) as we would
_
Andrew Morton
maintainerPATCH 156/165 mm/powerpc: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/powerpc: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault().
---
arch/powerpc/mm/fault.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
arch/powerpc/mm/fault.c renamed from arch/powerpc/mm/fault.c~mm-powerpc-use-general-page-fault-accounting +3 -8
@@ -511,7 +511,7 @@ retry:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs); major |= fault &VM_FAULT_MAJOR ;
@@ -537,14 +537,9 @@ retry:/* * Major/minor page fault accounting. */ -if (major) { - current->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , regs, address); +if (major)cmo_account_page_fault (); - }else { - current->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , regs, address); - } +return 0 ; }NOKPROBE_SYMBOL (__do_page_fault);
_
Andrew Morton
maintainerPATCH 157/165 mm/riscv: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/riscv: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
---
arch/riscv/mm/fault.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
arch/riscv/mm/fault.c renamed from arch/riscv/mm/fault.c~mm-riscv-use-general-page-fault-accounting +1 -15
@@ -109,7 +109,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, addr, flags,NULL ); + fault =handle_mm_fault (vma, addr, flags, regs);/* * If we need to retry but a fatal signal is pending, handle the
@@ -127,21 +127,7 @@ good_area:BUG (); } -/* -* Major/minor page fault accounting is only done on the -* initial attempt. If we go through a retry, it is extremely -* likely that the page will be found in page cache at that point. -*/ if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ , -1 , regs, addr); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN , -1 , regs, addr); - }if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 158/165 mm/s390: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/s390: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
---
arch/s390/mm/fault.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
arch/s390/mm/fault.c renamed from arch/s390/mm/fault.c~mm-s390-use-general-page-fault-accounting +1 -15
@@ -476,7 +476,7 @@ retry:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs)) { fault =VM_FAULT_SIGNAL ;if (flags &FAULT_FLAG_RETRY_NOWAIT )
@@ -486,21 +486,7 @@ retry:if (unlikely (fault &VM_FAULT_ERROR )) goto out_up; -/* -* Major/minor page fault accounting is only done on the -* initial attempt. If we go through a retry, it is extremely -* likely that the page will be found in page cache at that point. -*/ if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , - regs, address); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , - regs, address); - }if (fault &VM_FAULT_RETRY ) {if (IS_ENABLED (CONFIG_PGSTE ) && gmap && (flags &FAULT_FLAG_RETRY_NOWAIT )) {
_
Andrew Morton
maintainerPATCH 159/165 mm/sh: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/sh: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
---
arch/sh/mm/fault.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/sh/mm/fault.c renamed from arch/sh/mm/fault.c~mm-sh-use-general-page-fault-accounting +1 -10
@@ -482,22 +482,13 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (unlikely (fault & (VM_FAULT_RETRY |VM_FAULT_ERROR )))if (mm_fault_error (regs, error_code, address, fault))return ;if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , - regs, address); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , - regs, address); - }if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 160/165 mm/sparc32: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/sparc32: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
---
arch/sparc/mm/fault_32.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/sparc/mm/fault_32.c renamed from arch/sparc/mm/fault_32.c~mm-sparc32-use-general-page-fault-accounting +1 -10
@@ -234,7 +234,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -250,15 +250,6 @@ good_area: }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { - current->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ , -1 , regs, address); - }else { - current->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN , -1 , regs, address); - }if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 161/165 mm/sparc64: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/sparc64: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
---
arch/sparc/mm/fault_64.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/sparc/mm/fault_64.c renamed from arch/sparc/mm/fault_64.c~mm-sparc64-use-general-page-fault-accounting +1 -10
@@ -422,7 +422,7 @@ good_area: goto bad_area; } - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs)) goto exit_exception;
@@ -438,15 +438,6 @@ good_area: }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) { - current->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ , -1 , regs, address); - }else { - current->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN , -1 , regs, address); - }if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
_
Andrew Morton
maintainerPATCH 162/165 mm/x86: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/x86: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault().
---
arch/x86/mm/fault.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
arch/x86/mm/fault.c renamed from arch/x86/mm/fault.c~mm-x86-use-general-page-fault-accounting +2 -15
@@ -1139,7 +1139,7 @@ void do_user_addr_fault(struct pt_regs *struct vm_area_struct *vma;struct task_struct *tsk;struct mm_struct *mm; -vm_fault_t fault, major =0 ; +vm_fault_t fault;unsigned int flags =FAULT_FLAG_DEFAULT ; tsk = current;
@@ -1291,8 +1291,7 @@ good_area:* userland). The return to userland is identified whenever * FAULT_FLAG_USER|FAULT_FLAG_KILLABLE are both set in flags. */ - fault =handle_mm_fault (vma, address, flags,NULL ); - major |= fault &VM_FAULT_MAJOR ; + fault =handle_mm_fault (vma, address, flags, regs);/* Quick path to respond to signals */ if (fault_signal_pending (fault, regs)) {
@@ -1319,18 +1318,6 @@ good_area:return ; } -/* -* Major/minor page fault accounting. If any of the events -* returned VM_FAULT_MAJOR, we account it as a major fault. -*/ -if (major) { - tsk->maj_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , regs, address); - }else { - tsk->min_flt++; -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , regs, address); - } -check_v8086_mode (regs, address, tsk); }NOKPROBE_SYMBOL (do_user_addr_fault);
_
Andrew Morton
maintainerPATCH 163/165 mm/xtensa: use general page fault accounting
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/xtensa: use general page fault accounting
Use the general page fault accounting by passing regs into handle_mm_fault(). It naturally solve the issue of multiple page fault accounting when page fault retry happened.
Remove the PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN] perf events because it's now also done in handle_mm_fault().
Move the PERF_COUNT_SW_PAGE_FAULTS event higher before taking mmap_sem for the fault, then it'll match with the rest of the archs.
---
arch/xtensa/mm/fault.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
arch/xtensa/mm/fault.c renamed from arch/xtensa/mm/fault.c~mm-xtensa-use-general-page-fault-accounting +4 -11
@@ -72,6 +72,9 @@ void do_page_fault(struct pt_regs *regs)if (user_mode (regs)) flags |=FAULT_FLAG_USER ; + +perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); + retry:mmap_read_lock (mm); vma =find_vma (mm, address);
@@ -107,7 +110,7 @@ good_area:* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (vma, address, flags,NULL ); + fault =handle_mm_fault (vma, address, flags, regs);if (fault_signal_pending (fault, regs))return ;
@@ -122,10 +125,6 @@ good_area:BUG (); }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
@@ -139,12 +138,6 @@ good_area: }mmap_read_unlock (mm); -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 , regs, address); -if (flags &VM_FAULT_MAJOR ) -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , regs, address); -else -perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , regs, address); -return ;/* Something tried to access memory that isn't in our memory map..
_
Andrew Morton
maintainerPATCH 164/165 mm: clean up the last pieces of page fault accountings
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm: clean up the last pieces of page fault accountings
Here're the last pieces of page fault accounting that were still done outside handle_mm_fault() where we still have regs==NULL when calling handle_mm_fault():
arch/powerpc/mm/copro_fault.c: copro_handle_mm_fault
arch/sparc/mm/fault_32.c: force_user_fault
arch/um/kernel/trap.c: handle_page_fault
mm/gup.c: faultin_page
fixup_user_fault
mm/hmm.c: hmm_vma_fault
mm/ksm.c: break_ksmSome of them has the issue of duplicated accounting for page fault retries. Some of them didn't do the accounting at all.
This patch cleans all these up by letting handle_mm_fault() to do per-task page fault accounting even if regs==NULL (though we'll still skip the perf event accountings). With that, we can safely remove all the outliers now.
There's another functional change in that now we account the page faults to the caller of gup, rather than the task_struct that passed into the gup code. More information of this can be found at [1].
After this patch, below things should never be touched again outside handle_mm_fault():
- task_struct.[maj|min]_flt
- PERF_COUNT_SW_PAGE_FAULTS_[MAJ|MIN]
[1] https://lore.kernel.org/lkml/CAHk-=wj_V2Tps2QrMn20_W0OJF9xqNh52XSGA42s-ZJ8Y+GyKw@mail.gmail.com/
---
arch/powerpc/mm/copro_fault.c | 5 ----- arch/um/kernel/trap.c | 4 ---- mm/gup.c | 13 ------------- mm/memory.c | 17 ++++++++++------- 4 files changed, 10 insertions(+), 29 deletions(-)
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/mm/copro_fault.c~mm-clean-up-the-last-pieces-of-page-fault-accountings +0 -5
@@ -76,11 +76,6 @@ int copro_handle_mm_fault(struct mm_struBUG (); } -if (*flt &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++; - out_unlock:mmap_read_unlock (mm);return ret;
arch/um/kernel/trap.c renamed from arch/um/kernel/trap.c~mm-clean-up-the-last-pieces-of-page-fault-accountings +0 -4
@@ -88,10 +88,6 @@ good_area:BUG (); }if (flags &FAULT_FLAG_ALLOW_RETRY ) { -if (fault &VM_FAULT_MAJOR ) - current->maj_flt++; -else - current->min_flt++;if (fault &VM_FAULT_RETRY ) { flags |=FAULT_FLAG_TRIED ;
mm/gup.c renamed from mm/gup.c~mm-clean-up-the-last-pieces-of-page-fault-accountings +0 -13
@@ -893,13 +893,6 @@ static int faultin_page(struct task_struBUG (); } -if (tsk) { -if (ret &VM_FAULT_MAJOR ) - tsk->maj_flt++; -else - tsk->min_flt++; - } -if (ret &VM_FAULT_RETRY ) {if (locked && !(fault_flags &FAULT_FLAG_RETRY_NOWAIT )) *locked =0 ;
@@ -1255,12 +1248,6 @@ retry: goto retry; } -if (tsk) { -if (major) - tsk->maj_flt++; -else - tsk->min_flt++; - }return 0 ; }EXPORT_SYMBOL_GPL (fixup_user_fault);
mm/memory.c renamed from mm/memory.c~mm-clean-up-the-last-pieces-of-page-fault-accountings +10 -7
@@ -4400,20 +4400,23 @@ static inline void mm_account_fault(stru*/ major = (ret &VM_FAULT_MAJOR ) || (flags &FAULT_FLAG_TRIED ); +if (major) + current->maj_flt++; +else + current->min_flt++; +/* -* If the fault is done for GUP, regs will be NULL, and we will skip -* the fault accounting. +* If the fault is done for GUP, regs will be NULL. We only do the +* accounting for the per thread fault counters who triggered the +* fault, and we skip the perf event updates. */ if (!regs)return ; -if (major) { - current->maj_flt++; +if (major)perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MAJ ,1 , regs, address); - }else { - current->min_flt++; +else perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 , regs, address); - } }/*
_
Andrew Morton
maintainerPATCH 165/165 mm/gup: remove task_struct pointer for all gup code
In reply to Andrew MortonFrom: Peter Xu <[email protected]>
Subject: mm/gup: remove task_struct pointer for all gup code
After the cleanup of page fault accounting, gup does not need to pass task_struct around any more. Remove that parameter in the whole gup stack.
---
arch/arc/kernel/process.c | 2 arch/s390/kvm/interrupt.c | 2 arch/s390/kvm/kvm-s390.c | 2 arch/s390/kvm/priv.c | 8 - arch/s390/mm/gmap.c | 4 drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 2 drivers/infiniband/core/umem_odp.c | 2 drivers/vfio/vfio_iommu_type1.c | 4 fs/exec.c | 2 include/linux/mm.h | 9 - kernel/events/uprobes.c | 6 - kernel/futex.c | 2 mm/gup.c | 101 +++++++----------- mm/memory.c | 2 mm/process_vm_access.c | 2 security/tomoyo/domain.c | 2 virt/kvm/async_pf.c | 2 virt/kvm/kvm_main.c | 2 18 files changed, 69 insertions(+), 87 deletions(-)
arch/arc/kernel/process.c renamed from arch/arc/kernel/process.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -91,7 +91,7 @@ fault: goto fail;mmap_read_lock (current->mm); - ret =fixup_user_fault (current, current->mm, (unsigned long ) uaddr, + ret =fixup_user_fault (current->mm, (unsigned long ) uaddr,FAULT_FLAG_WRITE ,NULL );mmap_read_unlock (current->mm);
arch/s390/kvm/interrupt.c renamed from arch/s390/kvm/interrupt.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -2768,7 +2768,7 @@ static struct page *get_map_page(structstruct page *page =NULL ;mmap_read_lock (kvm->mm); -get_user_pages_remote (NULL , kvm->mm, uaddr,1 ,FOLL_WRITE , +get_user_pages_remote (kvm->mm, uaddr,1 ,FOLL_WRITE , &page,NULL ,NULL );mmap_read_unlock (kvm->mm);return page;
arch/s390/kvm/kvm-s390.c renamed from arch/s390/kvm/kvm-s390.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -1892,7 +1892,7 @@ static long kvm_s390_set_skeys(struct kv r =set_guest_storage_key (current->mm, hva, keys[i],0 );if (r) { - r =fixup_user_fault (current, current->mm, hva, + r =fixup_user_fault (current->mm, hva,FAULT_FLAG_WRITE , &unlocked);if (r)break ;
arch/s390/kvm/priv.c renamed from arch/s390/kvm/priv.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +4 -4
@@ -273,7 +273,7 @@ retry: rc =get_guest_storage_key (current->mm, vmaddr, &key);if (rc) { - rc =fixup_user_fault (current, current->mm, vmaddr, + rc =fixup_user_fault (current->mm, vmaddr,FAULT_FLAG_WRITE , &unlocked);if (!rc) {mmap_read_unlock (current->mm);
@@ -319,7 +319,7 @@ retry:mmap_read_lock (current->mm); rc =reset_guest_reference_bit (current->mm, vmaddr);if (rc <0 ) { - rc =fixup_user_fault (current, current->mm, vmaddr, + rc =fixup_user_fault (current->mm, vmaddr,FAULT_FLAG_WRITE , &unlocked);if (!rc) {mmap_read_unlock (current->mm);
@@ -390,7 +390,7 @@ static int handle_sske(struct kvm_vcpu * m3 & SSKE_MC);if (rc <0 ) { - rc =fixup_user_fault (current, current->mm, vmaddr, + rc =fixup_user_fault (current->mm, vmaddr,FAULT_FLAG_WRITE , &unlocked); rc = !rc ? -EAGAIN : rc; }
@@ -1094,7 +1094,7 @@ static int handle_pfmf(struct kvm_vcpu * rc =cond_set_guest_storage_key (current->mm, vmaddr, key,NULL , nq, mr, mc);if (rc <0 ) { - rc =fixup_user_fault (current, current->mm, vmaddr, + rc =fixup_user_fault (current->mm, vmaddr,FAULT_FLAG_WRITE , &unlocked); rc = !rc ? -EAGAIN : rc; }
arch/s390/mm/gmap.c renamed from arch/s390/mm/gmap.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +2 -2
@@ -649,7 +649,7 @@ retry: rc = vmaddr; goto out_up; } -if (fixup_user_fault (current, gmap->mm, vmaddr, fault_flags, +if (fixup_user_fault (gmap->mm, vmaddr, fault_flags, &unlocked)) { rc = -EFAULT ; goto out_up;
@@ -879,7 +879,7 @@ static int gmap_pte_op_fixup(struct gmapBUG_ON (gmap_is_shadow (gmap)); fault_flags = (prot ==PROT_WRITE ) ?FAULT_FLAG_WRITE :0 ; -if (fixup_user_fault (current, mm, vmaddr, fault_flags, &unlocked)) +if (fixup_user_fault (mm, vmaddr, fault_flags, &unlocked))return -EFAULT ;if (unlocked)/* lost mmap_lock, caller has to retry __gmap_translate */
drivers/gpu/drm/i915/gem/i915_gem_userptr.c renamed from drivers/gpu/drm/i915/gem/i915_gem_userptr.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -469,7 +469,7 @@ __i915_gem_userptr_get_pages_worker(stru locked =1 ; } ret = pin_user_pages_remote - (work->task, mm, + (mm, obj->userptr.ptr + pinned * PAGE_SIZE, npages - pinned, flags,
drivers/infiniband/core/umem_odp.c renamed from drivers/infiniband/core/umem_odp.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -439,7 +439,7 @@ int ib_umem_odp_map_dma_pages(struct ib_* complex (and doesn't gain us much performance in most use * cases). */ - npages =get_user_pages_remote (owning_process, owning_mm, + npages =get_user_pages_remote (owning_mm, user_virt, gup_num_pages, flags, local_page_list,NULL ,NULL );mmap_read_unlock (owning_mm);
drivers/vfio/vfio_iommu_type1.c renamed from drivers/vfio/vfio_iommu_type1.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +2 -2
@@ -425,7 +425,7 @@ static int follow_fault_pfn(struct vm_arif (ret) {bool unlocked = false; - ret =fixup_user_fault (NULL , mm, vaddr, + ret =fixup_user_fault (mm, vaddr,FAULT_FLAG_REMOTE | (write_fault ?FAULT_FLAG_WRITE :0 ), &unlocked);
@@ -453,7 +453,7 @@ static int vaddr_get_pfn(struct mm_struc flags |=FOLL_WRITE ;mmap_read_lock (mm); - ret =pin_user_pages_remote (NULL , mm, vaddr,1 , flags |FOLL_LONGTERM , + ret =pin_user_pages_remote (mm, vaddr,1 , flags |FOLL_LONGTERM , page,NULL ,NULL );if (ret ==1 ) { *pfn =page_to_pfn (page[0 ]);
fs/exec.c renamed from fs/exec.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -217,7 +217,7 @@ static struct page *get_arg_page(struct* We are doing an exec(). 'current' is the process * doing the exec and bprm->mm is the new process's mm. */ - ret =get_user_pages_remote (current, bprm->mm, pos,1 , gup_flags, + ret =get_user_pages_remote (bprm->mm, pos,1 , gup_flags, &page,NULL ,NULL );if (ret <=0 )return NULL ;
include/linux/mm.h renamed from include/linux/mm.h~mm-gup-remove-task_struct-pointer-for-all-gup-code +4 -5
@@ -1661,7 +1661,7 @@ int invalidate_inode_page(struct page *pextern vm_fault_t handle_mm_fault (struct vm_area_struct *vma,unsigned long address,unsigned int flags,struct pt_regs *regs); -extern int fixup_user_fault (struct task_struct *tsk,struct mm_struct *mm, +extern int fixup_user_fault (struct mm_struct *mm,unsigned long address,unsigned int fault_flags,bool *unlocked); void unmap_mapping_pages(struct address_space *mapping,
@@ -1677,8 +1677,7 @@ static inline vm_fault_t handle_mm_faultBUG ();return VM_FAULT_SIGBUS ; } -static inline int fixup_user_fault (struct task_struct *tsk, -struct mm_struct *mm,unsigned long address, +static inline int fixup_user_fault (struct mm_struct *mm,unsigned long address,unsigned int fault_flags,bool *unlocked) {/* should never happen if there's no MMU */
@@ -1704,11 +1703,11 @@ extern int access_remote_vm(struct mm_stextern int __access_remote_vm (struct task_struct *tsk,struct mm_struct *mm,unsigned long addr,void *buf,int len,unsigned int gup_flags); -long get_user_pages_remote (struct task_struct *tsk,struct mm_struct *mm, +long get_user_pages_remote (struct mm_struct *mm,unsigned long start,unsigned long nr_pages,unsigned int gup_flags,struct page **pages,struct vm_area_struct **vmas,int *locked); -long pin_user_pages_remote (struct task_struct *tsk,struct mm_struct *mm, +long pin_user_pages_remote (struct mm_struct *mm,unsigned long start,unsigned long nr_pages,unsigned int gup_flags,struct page **pages,struct vm_area_struct **vmas,int *locked);
kernel/events/uprobes.c renamed from kernel/events/uprobes.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +3 -3
@@ -376,7 +376,7 @@ __update_ref_ctr(struct mm_struct *mm, uif (!vaddr || !d)return -EINVAL ; - ret =get_user_pages_remote (NULL , mm, vaddr,1 , + ret =get_user_pages_remote (mm, vaddr,1 ,FOLL_WRITE , &page, &vma,NULL );if (unlikely (ret <=0 )) {/*
@@ -477,7 +477,7 @@ retry:if (is_register) gup_flags |=FOLL_SPLIT_PMD ;/* Read the page with vaddr into memory */ - ret =get_user_pages_remote (NULL , mm, vaddr,1 , gup_flags, + ret =get_user_pages_remote (mm, vaddr,1 , gup_flags, &old_page, &vma,NULL );if (ret <=0 )return ret;
@@ -2029,7 +2029,7 @@ static int is_trap_at_addr(struct mm_str* but we treat this as a 'remote' access since it is * essentially a kernel access to the memory. */ - result =get_user_pages_remote (NULL , mm, vaddr,1 ,FOLL_FORCE , &page, + result =get_user_pages_remote (mm, vaddr,1 ,FOLL_FORCE , &page,NULL ,NULL );if (result <0 )return result;
kernel/futex.c renamed from kernel/futex.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -678,7 +678,7 @@ static int fault_in_user_writeable(u32 _int ret;mmap_read_lock (mm); - ret =fixup_user_fault (current, mm, (unsigned long )uaddr, + ret =fixup_user_fault (mm, (unsigned long )uaddr,FAULT_FLAG_WRITE ,NULL );mmap_read_unlock (mm);
mm/gup.c renamed from mm/gup.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +42 -59
348 lines not on this page · raw message
mm/memory.c renamed from mm/memory.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -4742,7 +4742,7 @@ int __access_remote_vm(struct task_strucvoid *maddr;struct page *page =NULL ; - ret =get_user_pages_remote (tsk, mm, addr,1 , + ret =get_user_pages_remote (mm, addr,1 , gup_flags, &page, &vma,NULL );if (ret <=0 ) {#ifndef CONFIG_HAVE_IOREMAP_PROT
mm/process_vm_access.c renamed from mm/process_vm_access.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -105,7 +105,7 @@ static int process_vm_rw_single_vec(unsi* current/current->mm */ mmap_read_lock (mm); - pinned_pages =pin_user_pages_remote (task, mm, pa, pinned_pages, + pinned_pages =pin_user_pages_remote (mm, pa, pinned_pages, flags, process_pages,NULL , &locked);if (locked)
security/tomoyo/domain.c renamed from security/tomoyo/domain.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -914,7 +914,7 @@ bool tomoyo_dump_page(struct linux_binpr* (represented by bprm). 'current' is the process doing * the execve(). */ -if (get_user_pages_remote (current, bprm->mm, pos,1 , +if (get_user_pages_remote (bprm->mm, pos,1 ,FOLL_FORCE , &page,NULL ,NULL ) <=0 )return false;#else
virt/kvm/async_pf.c renamed from virt/kvm/async_pf.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -61,7 +61,7 @@ static void async_pf_execute(struct work* access remotely. */ mmap_read_lock (mm); -get_user_pages_remote (NULL , mm, addr,1 ,FOLL_WRITE ,NULL ,NULL , +get_user_pages_remote (mm, addr,1 ,FOLL_WRITE ,NULL ,NULL , &locked);if (locked)mmap_read_unlock (mm);
virt/kvm/kvm_main.c renamed from virt/kvm/kvm_main.c~mm-gup-remove-task_struct-pointer-for-all-gup-code +1 -1
@@ -1893,7 +1893,7 @@ static int hva_to_pfn_remapped(struct vm* not call the fault handler, so do it here. */ bool unlocked = false; - r =fixup_user_fault (current, current->mm, addr, + r =fixup_user_fault (current->mm, addr, (write_fault ?FAULT_FLAG_WRITE :0 ), &unlocked);if (unlocked)
_
+ asm-generic-pgalloch-use-correct-ifdef-to-enable-pud_alloc_one.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: asm-generic: pgalloc.h: use correct #ifdef to enable pud_alloc_one() has been added to the -mm tree. Its filename is…
The patch titled
Subject: asm-generic: pgalloc.h: use correct #ifdef to enable pud_alloc_one()
has been added to the -mm tree. Its filename is
asm-generic-pgalloch-use-correct-ifdef-to-enable-pud_alloc_one.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/asm-generic-pgalloch-use-correct-ifdef-to-enable-pud_alloc_one.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/asm-generic-pgalloch-use-correct-ifdef-to-enable-pud_alloc_one.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Mike Rapoport <[email protected]>
Subject: asm-generic: pgalloc.h: use correct #ifdef to enable pud_alloc_one()
The #ifdef statement that guards the generic version of pud_alloc_one() by mistake used __HAVE_ARCH_PUD_FREE instead of __HAVE_ARCH_PUD_ALLOC_ONE.
Fix it.
---
include/asm-generic/pgalloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/pgalloc.h renamed from include/asm-generic/pgalloc.h~asm-generic-pgalloch-use-correct-ifdef-to-enable-pud_alloc_one +1 -1
@@ -147,7 +147,7 @@ static inline void pmd_free(struct mm_st#if CONFIG_PGTABLE_LEVELS >3 -#ifndef __HAVE_ARCH_PUD_FREE +#ifndef __HAVE_ARCH_PUD_ALLOC_ONE/** * pud_alloc_one - allocate a page for PUD-level page table * @mm: the mm_struct of the current context
_
Patches currently in -mm which might be from [email protected] are
asm-generic-pgalloch-use-correct-ifdef-to-enable-pud_alloc_one.patch
+ exec-restore-eacces-of-s_isdir-execve.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: exec: restore EACCES of S_ISDIR execve() has been added to the -mm tree. Its filename is exec-restore-eacces-of-s_isdir-execve.patch
The patch titled
Subject: exec: restore EACCES of S_ISDIR execve()
has been added to the -mm tree. Its filename is
exec-restore-eacces-of-s_isdir-execve.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/exec-restore-eacces-of-s_isdir-execve.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/exec-restore-eacces-of-s_isdir-execve.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Kees Cook <[email protected]>
Subject: exec: restore EACCES of S_ISDIR execve()
Patch series "Fix S_ISDIR execve() errno".
Fix an errno change for execve() of directories, noticed by Marc Zyngier. Along with the fix, include a regression test to avoid seeing this return in the future.
This patch (of 2):
The return code for attempting to execute a directory has always been EACCES. Adjust the S_ISDIR exec test to reflect the old errno instead of the general EISDIR for other kinds of "open" attempts on directories.
---
fs/namei.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/namei.c renamed from fs/namei.c~exec-restore-eacces-of-s_isdir-execve +3 -1
@@ -2849,8 +2849,10 @@ static int may_open(const struct path *pcase S_IFLNK :return -ELOOP ;case S_IFDIR : -if (acc_mode & (MAY_WRITE |MAY_EXEC )) +if (acc_mode &MAY_WRITE )return -EISDIR ; +if (acc_mode &MAY_EXEC ) +return -EACCES ;break ;case S_IFBLK :case S_IFCHR :
_
Patches currently in -mm which might be from [email protected] are
exec-restore-eacces-of-s_isdir-execve.patch
selftests-exec-add-file-type-errno-tests.patch
+ selftests-exec-add-file-type-errno-tests.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: selftests/exec: add file type errno tests has been added to the -mm tree. Its filename is selftests-exec-add-file-type-errno-tests.patch
The patch titled
Subject: selftests/exec: add file type errno tests
has been added to the -mm tree. Its filename is
selftests-exec-add-file-type-errno-tests.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/selftests-exec-add-file-type-errno-tests.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/selftests-exec-add-file-type-errno-tests.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Kees Cook <[email protected]>
Subject: selftests/exec: add file type errno tests
Make sure execve() returns the expected errno values for non-regular files.
---
tools/testing/selftests/exec/.gitignore | 1 tools/testing/selftests/exec/Makefile | 5 tools/testing/selftests/exec/non-regular.c | 196 +++++++++++++++++++ 3 files changed, 200 insertions(+), 2 deletions(-)
tools/testing/selftests/exec/.gitignore renamed from tools/testing/selftests/exec/.gitignore~selftests-exec-add-file-type-errno-tests +1 -0
@@ -10,3 +10,4 @@ execveat.denatured /recursion-depth xxxxxxxx* pipe +S_I*.test
tools/testing/selftests/exec/Makefile renamed from tools/testing/selftests/exec/Makefile~selftests-exec-add-file-type-errno-tests +3 -2
@@ -3,7 +3,7 @@ CFLAGS = -Wall CFLAGS += -Wno-nonnull CFLAGS += -D_GNU_SOURCE -TEST_PROGS := binfmt_script +TEST_PROGS := binfmt_script non-regular TEST_GEN_PROGS := execveat TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir pipe # Makefile is a run-time dependency, since it's accessed by the execveat test
@@ -11,7 +11,8 @@ TEST_FILES := Makefile TEST_GEN_PROGS += recursion-depth -EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx* +EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx* \ + $(OUTPUT)/S_I*.test include ../lib.mk
tools/testing/selftests/exec/non-regular.c new file +196 -0
196 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
exec-restore-eacces-of-s_isdir-execve.patch
selftests-exec-add-file-type-errno-tests.patch
+ bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: bootconfig: fix off-by-one in xbc_node_compose_key_after() has been added to the -mm tree. Its filename is bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch
The patch titled
Subject: bootconfig: fix off-by-one in xbc_node_compose_key_after()
has been added to the -mm tree. Its filename is
bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Steven Rostedt (VMware) <[email protected]>
Subject: bootconfig: fix off-by-one in xbc_node_compose_key_after()
While reviewing some patches for bootconfig, I noticed the following code in xbc_node_compose_key_after():
ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node),
depth ? "." : "");
if (ret < 0)
return ret;
if (ret > size) {
size = 0;
} else {
size -= ret;
buf += ret;
}But snprintf() returns the number of bytes that would be written, not the number of bytes that are written (ignoring the nul terminator). This means that if the number of non null bytes written were to equal size, then the nul byte, which snprintf() always adds, will overwrite that last byte.
ret = snprintf(buf, 5, "hello");
printf("buf = '%s'", buf);
printf("ret = %d
", ret);
produces:
buf = 'hell' ret = 5
The string was truncated without ret being greater than 5. Test (ret >= size) for overwrite.
---
lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c renamed from lib/bootconfig.c~bootconfig-fix-off-by-one-in-xbc_node_compose_key_after +1 -1
@@ -248,7 +248,7 @@ int __init xbc_node_compose_key_after(st depth ? "." : "");if (ret <0 )return ret; -if (ret > size) { +if (ret >= size) { size =0 ; }else { size -= ret;
_
Patches currently in -mm which might be from [email protected] are
bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch
+ dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: dma-debug: fix debug_dma_assert_idle(), use rcu_read_lock() has been added to the -mm tree. Its filename is dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch
The patch titled
Subject: dma-debug: fix debug_dma_assert_idle(), use rcu_read_lock()
has been added to the -mm tree. Its filename is
dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Hugh Dickins <[email protected]>
Subject: dma-debug: fix debug_dma_assert_idle(), use rcu_read_lock()
Since commit 2a9127fcf229 ("mm: rewrite wait_on_page_bit_common() logic") improved unlock_page(), it has become more noticeable how cow_user_page() in a kernel with CONFIG_DMA_API_DEBUG=y can create and suffer from heavy contention on DMA debug's radix_lock in debug_dma_assert_idle().
It is only doing a lookup: use rcu_read_lock() and rcu_read_unlock() instead; though that does require the static ents[] to be moved onstack...
...but, hold on, isn't that radix_tree_gang_lookup() and loop doing quite the wrong thing: searching CACHELINES_PER_PAGE entries for an exact match with the first cacheline of the page in question? radix_tree_gang_lookup() is the right tool for the job, but we need nothing more than to check the first entry it can find, reporting if that falls anywhere within the page.
(Is RCU safe here? As safe as using the spinlock was. The entries are never freed, so don't need to be freed by RCU. They may be reused, and there is a faint chance of a race, with an offending entry reused while printing its error info; but the spinlock did not prevent that either, and I agree that it's not worth worrying about.)
---
kernel/dma/debug.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
kernel/dma/debug.c renamed from kernel/dma/debug.c~dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock +9 -18
@@ -565,11 +565,8 @@ static void active_cacheline_remove(stru*/ void debug_dma_assert_idle (struct page *page) { -static struct dma_debug_entry *ents[CACHELINES_PER_PAGE ]; -struct dma_debug_entry *entry =NULL ; -void **results = (void **) &ents; -unsigned int nents, i; -unsigned long flags; +struct dma_debug_entry *entry; +unsigned long pfn;phys_addr_t cln;if (dma_debug_disabled ())
@@ -578,20 +575,14 @@ void debug_dma_assert_idle(struct page *if (!page)return ; - cln = (phys_addr_t )page_to_pfn (page) <<CACHELINE_PER_PAGE_SHIFT ; -spin_lock_irqsave (&radix_lock, flags); - nents =radix_tree_gang_lookup (&dma_active_cacheline, results, cln, -CACHELINES_PER_PAGE ); -for (i =0 ; i < nents; i++) { -phys_addr_t ent_cln =to_cacheline_number (ents[i]); + pfn =page_to_pfn (page); + cln = (phys_addr_t ) pfn <<CACHELINE_PER_PAGE_SHIFT ; -if (ent_cln == cln) { - entry = ents[i]; -break ; - }else if (ent_cln >= cln +CACHELINES_PER_PAGE ) -break ; - } -spin_unlock_irqrestore (&radix_lock, flags); +rcu_read_lock (); +if (!radix_tree_gang_lookup (&dma_active_cacheline, (void **) &entry, + cln,1 ) || entry->pfn != pfn) + entry =NULL ; +rcu_read_unlock ();if (!entry)return ;
_
Patches currently in -mm which might be from [email protected] are
dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch
+ mailmap-add-entry-for-greg-kurz.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: mailmap: add entry for Greg Kurz has been added to the -mm tree. Its filename is mailmap-add-entry-for-greg-kurz.patch
The patch titled
Subject: mailmap: add entry for Greg Kurz
has been added to the -mm tree. Its filename is
mailmap-add-entry-for-greg-kurz.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mailmap-add-entry-for-greg-kurz.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mailmap-add-entry-for-greg-kurz.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Greg Kurz <[email protected]>
Subject: mailmap: add entry for Greg Kurz
I had stopped using [email protected] a while back already but this email address was shutdown last June when I quit IBM. It's about time to map it to [email protected].
---
.mailmap | 1 + 1 file changed, 1 insertion(+)
.mailmap renamed from .mailmap~mailmap-add-entry-for-greg-kurz +1 -0
@@ -104,6 +104,7 @@ Gerald Schaefer <[email protected] Greg Kroah-Hartman <greg@echidna.(none)> Greg Kroah-Hartman <[email protected]> Greg Kroah-Hartman <[email protected]> +Greg Kurz <[email protected]> <[email protected]> Gregory CLEMENT <[email protected]> <[email protected]> Hanjun Guo <[email protected]> <[email protected]> Heiko Carstens <[email protected]> <[email protected]>
_
Patches currently in -mm which might be from [email protected] are
mailmap-add-entry-for-greg-kurz.patch
+ mm-page_alloc-fix-core-hung-in-free_pcppages_bulk.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: mm, page_alloc: fix core hung in free_pcppages_bulk() has been added to the -mm tree. Its filename is mm-page_alloc-fix-core-hung-in-free_pcppages_bulk.patch
The patch titled
Subject: mm, page_alloc: fix core hung in free_pcppages_bulk()
has been added to the -mm tree. Its filename is
mm-page_alloc-fix-core-hung-in-free_pcppages_bulk.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-page_alloc-fix-core-hung-in-free_pcppages_bulk.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-page_alloc-fix-core-hung-in-free_pcppages_bulk.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Charan Teja Reddy <[email protected]>
Subject: mm, page_alloc: fix core hung in free_pcppages_bulk()
The following race is observed with the repeated online, offline and a delay between two successive online of memory blocks of movable zone.
P1 P2
Online the first memory block in
the movable zone. The pcp struct
values are initialized to default
values,i.e., pcp->high = 0 &pcp->batch = 1.
Allocate the pages from the movable zone.
Try to Online the second memory
block in the movable zone thus it
entered the online_pages() but yet
to call zone_pcp_update().
This process is entered into the exit path thus it tries to release the order-0 pages to pcp lists through free_unref_page_commit(). As pcp->high = 0, pcp->count = 1 proceed to call the function free_pcppages_bulk().
Update the pcp values thus the
new pcp values are like, say,pcp->high = 378, pcp->batch = 63.
Read the pcp's batch value using READ_ONCE() and pass the same to free_pcppages_bulk(), pcp values passed here are, batch = 63, count = 1.
Since num of pages in the pcp lists are less than ->batch, then it will stuck in while(list_empty(list)) loop with interrupts disabled thus a core hung.
Avoid this by ensuring free_pcppages_bulk() is called with proper count of pcp list pages.
The mentioned race is some what easily reproducible without [1] because pcp's are not updated for the first memory block online and thus there is a enough race window for P2 between alloc+free and pcp struct values update through onlining of second memory block.
With [1], the race still exists but it is very narrow as we update the pcp struct values for the first memory block online itself.
This is not limited to the movable zone, it could also happen in cases with the normal zone (e.g., hotplug to a node that only has DMA memory, or no other memory yet).
[1]: https://patchwork.kernel.org/patch/11696389/
---
mm/page_alloc.c | 5 +++++ 1 file changed, 5 insertions(+)
mm/page_alloc.c renamed from mm/page_alloc.c~mm-page_alloc-fix-core-hung-in-free_pcppages_bulk +5 -0
@@ -1301,6 +1301,11 @@ static void free_pcppages_bulk(struct zostruct page *page, *tmp;LIST_HEAD (head); +/* +* Ensure proper count is passed which otherwise would stuck in the +* below while (list_empty(list)) loop. +*/ + count =min (pcp->count, count);while (count) {struct list_head *list;
_
Patches currently in -mm which might be from [email protected] are
mm-page_alloc-fix-core-hung-in-free_pcppages_bulk.patch
+ fs-autofs-delete-repeated-words-in-comments.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: fs: autofs: delete repeated words in comments has been added to the -mm tree. Its filename is fs-autofs-delete-repeated-words-in-comments.patch
The patch titled
Subject: fs: autofs: delete repeated words in comments
has been added to the -mm tree. Its filename is
fs-autofs-delete-repeated-words-in-comments.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/fs-autofs-delete-repeated-words-in-comments.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/fs-autofs-delete-repeated-words-in-comments.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Randy Dunlap <[email protected]>
Subject: fs: autofs: delete repeated words in comments
Drop duplicated words {the, at} in comments.
---
fs/autofs/dev-ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/autofs/dev-ioctl.c renamed from fs/autofs/dev-ioctl.c~fs-autofs-delete-repeated-words-in-comments +2 -2
@@ -20,7 +20,7 @@* another mount. This situation arises when starting automount(8) * or other user space daemon which uses direct mounts or offset * mounts (used for autofs lazy mount/umount of nested mount trees), -* which have been left busy at at service shutdown. +* which have been left busy at service shutdown. */ typedef int (*ioctl_fn)(struct file *, struct autofs_sb_info *,
@@ -496,7 +496,7 @@ static int autofs_dev_ioctl_askumount(st* located path is the root of a mount we return 1 along with * the super magic of the mount or 0 otherwise. * -* In both cases the the device number (as returned by +* In both cases the device number (as returned by * new_encode_dev()) is also returned. */ static int autofs_dev_ioctl_ismountpoint(struct file *fp,
_
Patches currently in -mm which might be from [email protected] are
fs-autofs-delete-repeated-words-in-comments.patch
+ linux-next-rejects.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: linux-next-rejects has been added to the -mm tree. Its filename is linux-next-rejects.patch
The patch titled
Subject: linux-next-rejects
has been added to the -mm tree. Its filename is
linux-next-rejects.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/linux-next-rejects.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/linux-next-rejects.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: linux-next-rejects
---
.mailmap | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
.mailmap renamed from .mailmap~linux-next-rejects +4 -2
@@ -94,20 +94,22 @@ Felix Kuhling <[email protected]> Felix Moeller <[email protected]> Filipe Lautert <[email protected]> Franck Bui-Huu <[email protected]> -Frank Rowand <[email protected]> <[email protected]> Frank Rowand <[email protected]> <[email protected]> Frank Rowand <[email protected]> <[email protected]> +Frank Rowand <[email protected]> <[email protected]> Frank Zago <[email protected]> Gao Xiang <[email protected]> <[email protected]> Gao Xiang <[email protected]> <[email protected]> -Gerald Schaefer <[email protected]> <[email protected]> Gerald Schaefer <[email protected]> <[email protected]> +Gerald Schaefer <[email protected]> <[email protected]> Gerald Schaefer <[email protected]> <[email protected]> Greg Kroah-Hartman <greg@echidna.(none)> Greg Kroah-Hartman <[email protected]> Greg Kroah-Hartman <[email protected]> Greg Kurz <[email protected]> <[email protected]> Gregory CLEMENT <[email protected]> <[email protected]> +Gustavo Padovan <[email protected]> +Gustavo Padovan <[email protected]> Hanjun Guo <[email protected]> <[email protected]> Heiko Carstens <[email protected]> <[email protected]> Heiko Carstens <[email protected]> <[email protected]>
_
Patches currently in -mm which might be from [email protected] are
mm.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix-2.patch linux-next-rejects.patch mm-madvise-introduce-process_madvise-syscall-an-external-memory-hinting-api-fix.patch kernel-forkc-export-kernel_thread-to-modules.patch
[withdrawn] bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch removed from -mm tree
In reply to Andrew MortonThe patch titled Subject: bootconfig: fix off-by-one in xbc_node_compose_key_after() has been removed from the -mm tree. Its filename was bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch
The patch titled
Subject: bootconfig: fix off-by-one in xbc_node_compose_key_after()
has been removed from the -mm tree. Its filename was
bootconfig-fix-off-by-one-in-xbc_node_compose_key_after.patch
This patch was dropped because it was withdrawn
------------------------------------------------------
From: Steven Rostedt (VMware) <[email protected]>
Subject: bootconfig: fix off-by-one in xbc_node_compose_key_after()
While reviewing some patches for bootconfig, I noticed the following code in xbc_node_compose_key_after():
ret = snprintf(buf, size, "%s%s", xbc_node_get_data(node),
depth ? "." : "");
if (ret < 0)
return ret;
if (ret > size) {
size = 0;
} else {
size -= ret;
buf += ret;
}But snprintf() returns the number of bytes that would be written, not the number of bytes that are written (ignoring the nul terminator). This means that if the number of non null bytes written were to equal size, then the nul byte, which snprintf() always adds, will overwrite that last byte.
ret = snprintf(buf, 5, "hello");
printf("buf = '%s'", buf);
printf("ret = %d
", ret);
produces:
buf = 'hell' ret = 5
The string was truncated without ret being greater than 5. Test (ret >= size) for overwrite.
---
lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bootconfig.c renamed from lib/bootconfig.c~bootconfig-fix-off-by-one-in-xbc_node_compose_key_after +1 -1
@@ -248,7 +248,7 @@ int __init xbc_node_compose_key_after(st depth ? "." : "");if (ret <0 )return ret; -if (ret > size) { +if (ret >= size) { size =0 ; }else { size -= ret;
_
Patches currently in -mm which might be from [email protected] are
+ khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: khugepaged: adjust VM_BUG_ON_MM() in __khugepaged_enter() has been added to the -mm tree. Its filename is khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter.patch
The patch titled
Subject: khugepaged: adjust VM_BUG_ON_MM() in __khugepaged_enter()
has been added to the -mm tree. Its filename is
khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Hugh Dickins <[email protected]>
Subject: khugepaged: adjust VM_BUG_ON_MM() in __khugepaged_enter()
syzbot crashes on the VM_BUG_ON_MM(khugepaged_test_exit(mm), mm) in __khugepaged_enter(): yes, when one thread is about to dump core, has set core_state, and is waiting for others, another might do something calling __khugepaged_enter(), which now crashes because I lumped the core_state test (known as "mmget_still_valid") into khugepaged_test_exit(). I still think it's best to lump them together, so just in this exceptional case, check mm->mm_users directly instead of khugepaged_test_exit().
---
mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/khugepaged.c renamed from mm/khugepaged.c~khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter +1 -1
@@ -466,7 +466,7 @@ int __khugepaged_enter(struct mm_structreturn -ENOMEM ;/* __khugepaged_exit() must not run from under us */ -VM_BUG_ON_MM (khugepaged_test_exit (mm), mm); +VM_BUG_ON_MM (atomic_read (&mm->mm_users) ==0 , mm);if (unlikely (test_and_set_bit (MMF_VM_HUGEPAGE , &mm->flags))) {free_mm_slot (mm_slot);return 0 ;
_
Patches currently in -mm which might be from [email protected] are
dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter.patch
[merged] dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch removed from -mm tree
In reply to Andrew MortonThe patch titled Subject: dma-debug: fix debug_dma_assert_idle(), use rcu_read_lock() has been removed from the -mm tree. Its filename was dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch
The patch titled
Subject: dma-debug: fix debug_dma_assert_idle(), use rcu_read_lock()
has been removed from the -mm tree. Its filename was
dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Hugh Dickins <[email protected]>
Subject: dma-debug: fix debug_dma_assert_idle(), use rcu_read_lock()
Since commit 2a9127fcf229 ("mm: rewrite wait_on_page_bit_common() logic") improved unlock_page(), it has become more noticeable how cow_user_page() in a kernel with CONFIG_DMA_API_DEBUG=y can create and suffer from heavy contention on DMA debug's radix_lock in debug_dma_assert_idle().
It is only doing a lookup: use rcu_read_lock() and rcu_read_unlock() instead; though that does require the static ents[] to be moved onstack...
...but, hold on, isn't that radix_tree_gang_lookup() and loop doing quite the wrong thing: searching CACHELINES_PER_PAGE entries for an exact match with the first cacheline of the page in question? radix_tree_gang_lookup() is the right tool for the job, but we need nothing more than to check the first entry it can find, reporting if that falls anywhere within the page.
(Is RCU safe here? As safe as using the spinlock was. The entries are never freed, so don't need to be freed by RCU. They may be reused, and there is a faint chance of a race, with an offending entry reused while printing its error info; but the spinlock did not prevent that either, and I agree that it's not worth worrying about.)
---
kernel/dma/debug.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
kernel/dma/debug.c renamed from kernel/dma/debug.c~dma-debug-fix-debug_dma_assert_idle-use-rcu_read_lock +9 -18
@@ -565,11 +565,8 @@ static void active_cacheline_remove(stru*/ void debug_dma_assert_idle (struct page *page) { -static struct dma_debug_entry *ents[CACHELINES_PER_PAGE ]; -struct dma_debug_entry *entry =NULL ; -void **results = (void **) &ents; -unsigned int nents, i; -unsigned long flags; +struct dma_debug_entry *entry; +unsigned long pfn;phys_addr_t cln;if (dma_debug_disabled ())
@@ -578,20 +575,14 @@ void debug_dma_assert_idle(struct page *if (!page)return ; - cln = (phys_addr_t )page_to_pfn (page) <<CACHELINE_PER_PAGE_SHIFT ; -spin_lock_irqsave (&radix_lock, flags); - nents =radix_tree_gang_lookup (&dma_active_cacheline, results, cln, -CACHELINES_PER_PAGE ); -for (i =0 ; i < nents; i++) { -phys_addr_t ent_cln =to_cacheline_number (ents[i]); + pfn =page_to_pfn (page); + cln = (phys_addr_t ) pfn <<CACHELINE_PER_PAGE_SHIFT ; -if (ent_cln == cln) { - entry = ents[i]; -break ; - }else if (ent_cln >= cln +CACHELINES_PER_PAGE ) -break ; - } -spin_unlock_irqrestore (&radix_lock, flags); +rcu_read_lock (); +if (!radix_tree_gang_lookup (&dma_active_cacheline, (void **) &entry, + cln,1 ) || entry->pfn != pfn) + entry =NULL ; +rcu_read_unlock ();if (!entry)return ;
_
Patches currently in -mm which might be from [email protected] are
khugepaged-adjust-vm_bug_on_mm-in-__khugepaged_enter.patch
+ iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix has been added to the -mm tree. Its filename is…
The patch titled
Subject: iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix
has been added to the -mm tree. Its filename is
iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix
fix drivers/mailbox/bcm-pdc-mailbox.c
---
drivers/mailbox/bcm-pdc-mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/bcm-pdc-mailbox.c renamed from drivers/mailbox/bcm-pdc-mailbox.c~iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix +1 -1
@@ -679,7 +679,7 @@ pdc_receive(struct pdc_state *pdcs)/* read last_rx_curr from register once */ pdcs->last_rx_curr = - (ioread32 (&pdcs->rxregs_64->status0) & + (ioread32 ((const void __iomem *)&pdcs->rxregs_64->status0) &CRYPTO_D64_RS0_CD_MASK ) /RING_ENTRY_SIZE ; do {
_
Patches currently in -mm which might be from [email protected] are
mm-madvise-introduce-process_madvise-syscall-an-external-memory-hinting-api-fix.patch iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix.patch mm.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix-2.patch linux-next-rejects.patch kernel-forkc-export-kernel_thread-to-modules.patch
+ mm-replace-hpage_nr_pages-with-thp_nr_pages-fix.patch added to -mm tree
In reply to Andrew MortonThe patch titled Subject: mm-replace-hpage_nr_pages-with-thp_nr_pages-fix has been added to the -mm tree. Its filename is mm-replace-hpage_nr_pages-with-thp_nr_pages-fix.patch
The patch titled
Subject: mm-replace-hpage_nr_pages-with-thp_nr_pages-fix
has been added to the -mm tree. Its filename is
mm-replace-hpage_nr_pages-with-thp_nr_pages-fix.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mm-replace-hpage_nr_pages-with-thp_nr_pages-fix.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mm-replace-hpage_nr_pages-with-thp_nr_pages-fix.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: mm-replace-hpage_nr_pages-with-thp_nr_pages-fix
fix mm/migrate.c
---
mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c renamed from mm/migrate.c~mm-replace-hpage_nr_pages-with-thp_nr_pages-fix +1 -1
@@ -1446,7 +1446,7 @@ retry:* during migration. */ is_thp =PageTransHuge (page); - nr_subpages =hpage_nr_pages (page); + nr_subpages =thp_nr_pages (page);cond_resched ();if (PageHuge (page))
_
Patches currently in -mm which might be from [email protected] are
mm-madvise-introduce-process_madvise-syscall-an-external-memory-hinting-api-fix.patch iomap-constify-ioreadx-iomem-argument-as-in-generic-implementation-fix-fix.patch mm.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix-2.patch linux-next-rejects.patch kernel-forkc-export-kernel_thread-to-modules.patch mm-replace-hpage_nr_pages-with-thp_nr_pages-fix.patch