2020-08-06 19:35:42

by Ralph Campbell

[permalink] [raw]
Subject: [PATCH] mm/migrate: fix migrate_pgmap_owner w/o CONFIG_MMU_NOTIFIER

On x86_64, when CONFIG_MMU_NOTIFIER is not set/enabled, there is a
compiler error:

../mm/migrate.c: In function 'migrate_vma_collect':
../mm/migrate.c:2481:7: error: 'struct mmu_notifier_range' has no member
named 'migrate_pgmap_owner'
range.migrate_pgmap_owner = migrate->pgmap_owner;
^

Fixes: 998427b3ad2c ("mm/notifier: add migration invalidation type")
Signed-off-by: Ralph Campbell <[email protected]>
Reported-by: Randy Dunlap <[email protected]>
---

This is based on the latest linux and is for Andrew Morton's mm tree.
MMU_NOTIFIER is selected automatically by a number of other config
options so I missed this in my own testing. Thanks to Randy Dunlap for
finding it.

include/linux/mmu_notifier.h | 13 +++++++++++++
mm/migrate.c | 6 +++---
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
index c6f0708195cd..b8200782dede 100644
--- a/include/linux/mmu_notifier.h
+++ b/include/linux/mmu_notifier.h
@@ -521,6 +521,16 @@ static inline void mmu_notifier_range_init(struct mmu_notifier_range *range,
range->flags = flags;
}

+static inline void mmu_notifier_range_init_migrate(
+ struct mmu_notifier_range *range, unsigned int flags,
+ struct vm_area_struct *vma, struct mm_struct *mm,
+ unsigned long start, unsigned long end, void *pgmap)
+{
+ mmu_notifier_range_init(range, MMU_NOTIFY_MIGRATE, flags, vma, mm,
+ start, end);
+ range->migrate_pgmap_owner = pgmap;
+}
+
#define ptep_clear_flush_young_notify(__vma, __address, __ptep) \
({ \
int __young; \
@@ -645,6 +655,9 @@ static inline void _mmu_notifier_range_init(struct mmu_notifier_range *range,

#define mmu_notifier_range_init(range,event,flags,vma,mm,start,end) \
_mmu_notifier_range_init(range, start, end)
+#define mmu_notifier_range_init_migrate(range, flags, vma, mm, start, end, \
+ pgmap) \
+ _mmu_notifier_range_init(range, start, end)

static inline bool
mmu_notifier_range_blockable(const struct mmu_notifier_range *range)
diff --git a/mm/migrate.c b/mm/migrate.c
index 4fcc465736ff..d179657f8685 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2386,9 +2386,9 @@ static void migrate_vma_collect(struct migrate_vma *migrate)
* that the registered device driver can skip invalidating device
* private page mappings that won't be migrated.
*/
- mmu_notifier_range_init(&range, MMU_NOTIFY_MIGRATE, 0, migrate->vma,
- migrate->vma->vm_mm, migrate->start, migrate->end);
- range.migrate_pgmap_owner = migrate->pgmap_owner;
+ mmu_notifier_range_init_migrate(&range, 0, migrate->vma,
+ migrate->vma->vm_mm, migrate->start, migrate->end,
+ migrate->pgmap_owner);
mmu_notifier_invalidate_range_start(&range);

walk_page_range(migrate->vma->vm_mm, migrate->start, migrate->end,
--
2.20.1


2020-08-06 23:41:54

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] mm/migrate: fix migrate_pgmap_owner w/o CONFIG_MMU_NOTIFIER

On 8/6/20 12:33 PM, Ralph Campbell wrote:
> On x86_64, when CONFIG_MMU_NOTIFIER is not set/enabled, there is a
> compiler error:
>
> ../mm/migrate.c: In function 'migrate_vma_collect':
> ../mm/migrate.c:2481:7: error: 'struct mmu_notifier_range' has no member
> named 'migrate_pgmap_owner'
> range.migrate_pgmap_owner = migrate->pgmap_owner;
> ^
>
> Fixes: 998427b3ad2c ("mm/notifier: add migration invalidation type")
> Signed-off-by: Ralph Campbell <[email protected]>
> Reported-by: Randy Dunlap <[email protected]>

Acked-by: Randy Dunlap <[email protected]> # build-tested

Thanks.


> ---
>
> This is based on the latest linux and is for Andrew Morton's mm tree.
> MMU_NOTIFIER is selected automatically by a number of other config
> options so I missed this in my own testing. Thanks to Randy Dunlap for
> finding it.
>
> include/linux/mmu_notifier.h | 13 +++++++++++++
> mm/migrate.c | 6 +++---
> 2 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
> index c6f0708195cd..b8200782dede 100644
> --- a/include/linux/mmu_notifier.h
> +++ b/include/linux/mmu_notifier.h
> @@ -521,6 +521,16 @@ static inline void mmu_notifier_range_init(struct mmu_notifier_range *range,
> range->flags = flags;
> }
>
> +static inline void mmu_notifier_range_init_migrate(
> + struct mmu_notifier_range *range, unsigned int flags,
> + struct vm_area_struct *vma, struct mm_struct *mm,
> + unsigned long start, unsigned long end, void *pgmap)
> +{
> + mmu_notifier_range_init(range, MMU_NOTIFY_MIGRATE, flags, vma, mm,
> + start, end);
> + range->migrate_pgmap_owner = pgmap;
> +}
> +
> #define ptep_clear_flush_young_notify(__vma, __address, __ptep) \
> ({ \
> int __young; \
> @@ -645,6 +655,9 @@ static inline void _mmu_notifier_range_init(struct mmu_notifier_range *range,
>
> #define mmu_notifier_range_init(range,event,flags,vma,mm,start,end) \
> _mmu_notifier_range_init(range, start, end)
> +#define mmu_notifier_range_init_migrate(range, flags, vma, mm, start, end, \
> + pgmap) \
> + _mmu_notifier_range_init(range, start, end)
>
> static inline bool
> mmu_notifier_range_blockable(const struct mmu_notifier_range *range)
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 4fcc465736ff..d179657f8685 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2386,9 +2386,9 @@ static void migrate_vma_collect(struct migrate_vma *migrate)
> * that the registered device driver can skip invalidating device
> * private page mappings that won't be migrated.
> */
> - mmu_notifier_range_init(&range, MMU_NOTIFY_MIGRATE, 0, migrate->vma,
> - migrate->vma->vm_mm, migrate->start, migrate->end);
> - range.migrate_pgmap_owner = migrate->pgmap_owner;
> + mmu_notifier_range_init_migrate(&range, 0, migrate->vma,
> + migrate->vma->vm_mm, migrate->start, migrate->end,
> + migrate->pgmap_owner);
> mmu_notifier_invalidate_range_start(&range);
>
> walk_page_range(migrate->vma->vm_mm, migrate->start, migrate->end,
>


--
~Randy

2020-08-06 23:47:30

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [PATCH] mm/migrate: fix migrate_pgmap_owner w/o CONFIG_MMU_NOTIFIER

On Thu, Aug 06, 2020 at 04:39:58PM -0700, Randy Dunlap wrote:
> On 8/6/20 12:33 PM, Ralph Campbell wrote:
> > On x86_64, when CONFIG_MMU_NOTIFIER is not set/enabled, there is a
> > compiler error:
> >
> > ../mm/migrate.c: In function 'migrate_vma_collect':
> > ../mm/migrate.c:2481:7: error: 'struct mmu_notifier_range' has no member
> > named 'migrate_pgmap_owner'
> > range.migrate_pgmap_owner = migrate->pgmap_owner;
> > ^
> >
> > Fixes: 998427b3ad2c ("mm/notifier: add migration invalidation type")
> > Signed-off-by: Ralph Campbell <[email protected]>
> > Reported-by: Randy Dunlap <[email protected]>
>
> Acked-by: Randy Dunlap <[email protected]> # build-tested

Reviewed-by: Jason Gunthorpe <[email protected]>

I thought it spent enough time in linux-next and for 0-day to catch
things like this, but I guess I was wrong.

Linus has already merged the hmm pull request.

Andrew Morton: Can you pick this fix up to forward to Linus?

Thanks,
Jason