Skip to content

Commit 997308f

Browse files
committed
mmu_notifier: remove the .change_pte() callback
The scope of set_pte_at_notify() has reduced more and more through the years. Initially, it was meant for when the change to the PTE was not bracketed by mmu_notifier_invalidate_range_{start,end}(). However, that has not been so for over ten years. During all this period the only implementation of .change_pte() was KVM and it had no actual functionality, because it was called after mmu_notifier_invalidate_range_start() zapped the secondary PTE. Now that this (nonfunctional) user of the .change_pte() callback is gone, the whole callback can be removed. For now, leave in place set_pte_at_notify() even though it is just a synonym for set_pte_at(). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> Message-ID: <20240405115815.3226315-4-pbonzini@redhat.com> Acked-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 5257de9 commit 997308f

2 files changed

Lines changed: 2 additions & 61 deletions

File tree

include/linux/mmu_notifier.h

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@ struct mmu_notifier_ops {
122122
struct mm_struct *mm,
123123
unsigned long address);
124124

125-
/*
126-
* change_pte is called in cases that pte mapping to page is changed:
127-
* for example, when ksm remaps pte to point to a new shared page.
128-
*/
129-
void (*change_pte)(struct mmu_notifier *subscription,
130-
struct mm_struct *mm,
131-
unsigned long address,
132-
pte_t pte);
133-
134125
/*
135126
* invalidate_range_start() and invalidate_range_end() must be
136127
* paired and are called only when the mmap_lock and/or the
@@ -392,8 +383,6 @@ extern int __mmu_notifier_clear_young(struct mm_struct *mm,
392383
unsigned long end);
393384
extern int __mmu_notifier_test_young(struct mm_struct *mm,
394385
unsigned long address);
395-
extern void __mmu_notifier_change_pte(struct mm_struct *mm,
396-
unsigned long address, pte_t pte);
397386
extern int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *r);
398387
extern void __mmu_notifier_invalidate_range_end(struct mmu_notifier_range *r);
399388
extern void __mmu_notifier_arch_invalidate_secondary_tlbs(struct mm_struct *mm,
@@ -439,13 +428,6 @@ static inline int mmu_notifier_test_young(struct mm_struct *mm,
439428
return 0;
440429
}
441430

442-
static inline void mmu_notifier_change_pte(struct mm_struct *mm,
443-
unsigned long address, pte_t pte)
444-
{
445-
if (mm_has_notifiers(mm))
446-
__mmu_notifier_change_pte(mm, address, pte);
447-
}
448-
449431
static inline void
450432
mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
451433
{
@@ -581,26 +563,6 @@ static inline void mmu_notifier_range_init_owner(
581563
__young; \
582564
})
583565

584-
/*
585-
* set_pte_at_notify() sets the pte _after_ running the notifier.
586-
* This is safe to start by updating the secondary MMUs, because the primary MMU
587-
* pte invalidate must have already happened with a ptep_clear_flush() before
588-
* set_pte_at_notify() has been invoked. Updating the secondary MMUs first is
589-
* required when we change both the protection of the mapping from read-only to
590-
* read-write and the pfn (like during copy on write page faults). Otherwise the
591-
* old page would remain mapped readonly in the secondary MMUs after the new
592-
* page is already writable by some CPU through the primary MMU.
593-
*/
594-
#define set_pte_at_notify(__mm, __address, __ptep, __pte) \
595-
({ \
596-
struct mm_struct *___mm = __mm; \
597-
unsigned long ___address = __address; \
598-
pte_t ___pte = __pte; \
599-
\
600-
mmu_notifier_change_pte(___mm, ___address, ___pte); \
601-
set_pte_at(___mm, ___address, __ptep, ___pte); \
602-
})
603-
604566
#else /* CONFIG_MMU_NOTIFIER */
605567

606568
struct mmu_notifier_range {
@@ -650,11 +612,6 @@ static inline int mmu_notifier_test_young(struct mm_struct *mm,
650612
return 0;
651613
}
652614

653-
static inline void mmu_notifier_change_pte(struct mm_struct *mm,
654-
unsigned long address, pte_t pte)
655-
{
656-
}
657-
658615
static inline void
659616
mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
660617
{
@@ -693,12 +650,13 @@ static inline void mmu_notifier_subscriptions_destroy(struct mm_struct *mm)
693650
#define ptep_clear_flush_notify ptep_clear_flush
694651
#define pmdp_huge_clear_flush_notify pmdp_huge_clear_flush
695652
#define pudp_huge_clear_flush_notify pudp_huge_clear_flush
696-
#define set_pte_at_notify set_pte_at
697653

698654
static inline void mmu_notifier_synchronize(void)
699655
{
700656
}
701657

702658
#endif /* CONFIG_MMU_NOTIFIER */
703659

660+
#define set_pte_at_notify set_pte_at
661+
704662
#endif /* _LINUX_MMU_NOTIFIER_H */

mm/mmu_notifier.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -424,23 +424,6 @@ int __mmu_notifier_test_young(struct mm_struct *mm,
424424
return young;
425425
}
426426

427-
void __mmu_notifier_change_pte(struct mm_struct *mm, unsigned long address,
428-
pte_t pte)
429-
{
430-
struct mmu_notifier *subscription;
431-
int id;
432-
433-
id = srcu_read_lock(&srcu);
434-
hlist_for_each_entry_rcu(subscription,
435-
&mm->notifier_subscriptions->list, hlist,
436-
srcu_read_lock_held(&srcu)) {
437-
if (subscription->ops->change_pte)
438-
subscription->ops->change_pte(subscription, mm, address,
439-
pte);
440-
}
441-
srcu_read_unlock(&srcu, id);
442-
}
443-
444427
static int mn_itree_invalidate(struct mmu_notifier_subscriptions *subscriptions,
445428
const struct mmu_notifier_range *range)
446429
{

0 commit comments

Comments
 (0)