@@ -512,6 +512,38 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vm
512
512
}
513
513
#endif
514
514
515
+ /*
516
+ * tlb_flush_{pte|pmd|pud|p4d}_range() adjust the tlb->start and tlb->end,
517
+ * and set corresponding cleared_*.
518
+ */
519
+ static inline void tlb_flush_pte_range (struct mmu_gather * tlb ,
520
+ unsigned long address , unsigned long size )
521
+ {
522
+ __tlb_adjust_range (tlb , address , size );
523
+ tlb -> cleared_ptes = 1 ;
524
+ }
525
+
526
+ static inline void tlb_flush_pmd_range (struct mmu_gather * tlb ,
527
+ unsigned long address , unsigned long size )
528
+ {
529
+ __tlb_adjust_range (tlb , address , size );
530
+ tlb -> cleared_pmds = 1 ;
531
+ }
532
+
533
+ static inline void tlb_flush_pud_range (struct mmu_gather * tlb ,
534
+ unsigned long address , unsigned long size )
535
+ {
536
+ __tlb_adjust_range (tlb , address , size );
537
+ tlb -> cleared_puds = 1 ;
538
+ }
539
+
540
+ static inline void tlb_flush_p4d_range (struct mmu_gather * tlb ,
541
+ unsigned long address , unsigned long size )
542
+ {
543
+ __tlb_adjust_range (tlb , address , size );
544
+ tlb -> cleared_p4ds = 1 ;
545
+ }
546
+
515
547
#ifndef __tlb_remove_tlb_entry
516
548
#define __tlb_remove_tlb_entry (tlb , ptep , address ) do { } while (0)
517
549
#endif
@@ -525,19 +557,17 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vm
525
557
*/
526
558
#define tlb_remove_tlb_entry (tlb , ptep , address ) \
527
559
do { \
528
- __tlb_adjust_range(tlb, address, PAGE_SIZE); \
529
- tlb->cleared_ptes = 1; \
560
+ tlb_flush_pte_range(tlb, address, PAGE_SIZE); \
530
561
__tlb_remove_tlb_entry(tlb, ptep, address); \
531
562
} while (0)
532
563
533
564
#define tlb_remove_huge_tlb_entry (h , tlb , ptep , address ) \
534
565
do { \
535
566
unsigned long _sz = huge_page_size(h); \
536
- __tlb_adjust_range(tlb, address, _sz); \
537
567
if (_sz == PMD_SIZE) \
538
- tlb->cleared_pmds = 1; \
568
+ tlb_flush_pmd_range( tlb, address, _sz); \
539
569
else if (_sz == PUD_SIZE) \
540
- tlb->cleared_puds = 1; \
570
+ tlb_flush_pud_range( tlb, address, _sz); \
541
571
__tlb_remove_tlb_entry(tlb, ptep, address); \
542
572
} while (0)
543
573
@@ -551,8 +581,7 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vm
551
581
552
582
#define tlb_remove_pmd_tlb_entry (tlb , pmdp , address ) \
553
583
do { \
554
- __tlb_adjust_range(tlb, address, HPAGE_PMD_SIZE); \
555
- tlb->cleared_pmds = 1; \
584
+ tlb_flush_pmd_range(tlb, address, HPAGE_PMD_SIZE); \
556
585
__tlb_remove_pmd_tlb_entry(tlb, pmdp, address); \
557
586
} while (0)
558
587
@@ -566,8 +595,7 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vm
566
595
567
596
#define tlb_remove_pud_tlb_entry (tlb , pudp , address ) \
568
597
do { \
569
- __tlb_adjust_range(tlb, address, HPAGE_PUD_SIZE); \
570
- tlb->cleared_puds = 1; \
598
+ tlb_flush_pud_range(tlb, address, HPAGE_PUD_SIZE); \
571
599
__tlb_remove_pud_tlb_entry(tlb, pudp, address); \
572
600
} while (0)
573
601
@@ -592,29 +620,26 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vm
592
620
#ifndef pte_free_tlb
593
621
#define pte_free_tlb (tlb , ptep , address ) \
594
622
do { \
595
- __tlb_adjust_range (tlb, address, PAGE_SIZE); \
623
+ tlb_flush_pmd_range (tlb, address, PAGE_SIZE); \
596
624
tlb->freed_tables = 1; \
597
- tlb->cleared_pmds = 1; \
598
625
__pte_free_tlb(tlb, ptep, address); \
599
626
} while (0)
600
627
#endif
601
628
602
629
#ifndef pmd_free_tlb
603
630
#define pmd_free_tlb (tlb , pmdp , address ) \
604
631
do { \
605
- __tlb_adjust_range (tlb, address, PAGE_SIZE); \
632
+ tlb_flush_pud_range (tlb, address, PAGE_SIZE); \
606
633
tlb->freed_tables = 1; \
607
- tlb->cleared_puds = 1; \
608
634
__pmd_free_tlb(tlb, pmdp, address); \
609
635
} while (0)
610
636
#endif
611
637
612
638
#ifndef pud_free_tlb
613
639
#define pud_free_tlb (tlb , pudp , address ) \
614
640
do { \
615
- __tlb_adjust_range (tlb, address, PAGE_SIZE); \
641
+ tlb_flush_p4d_range (tlb, address, PAGE_SIZE); \
616
642
tlb->freed_tables = 1; \
617
- tlb->cleared_p4ds = 1; \
618
643
__pud_free_tlb(tlb, pudp, address); \
619
644
} while (0)
620
645
#endif
0 commit comments