@@ -1653,13 +1653,15 @@ static void smp_flush_tlb_all(void)
1653
1653
local_ops -> tlb_all ();
1654
1654
}
1655
1655
1656
+ static bool any_other_mm_cpus (struct mm_struct * mm )
1657
+ {
1658
+ return cpumask_any_but (mm_cpumask (mm ), smp_processor_id ()) < nr_cpu_ids ;
1659
+ }
1660
+
1656
1661
static void smp_flush_cache_mm (struct mm_struct * mm )
1657
1662
{
1658
1663
if (mm -> context != NO_CONTEXT ) {
1659
- cpumask_t cpu_mask ;
1660
- cpumask_copy (& cpu_mask , mm_cpumask (mm ));
1661
- cpumask_clear_cpu (smp_processor_id (), & cpu_mask );
1662
- if (!cpumask_empty (& cpu_mask ))
1664
+ if (any_other_mm_cpus (mm ))
1663
1665
xc1 (local_ops -> cache_mm , (unsigned long )mm );
1664
1666
local_ops -> cache_mm (mm );
1665
1667
}
@@ -1668,10 +1670,7 @@ static void smp_flush_cache_mm(struct mm_struct *mm)
1668
1670
static void smp_flush_tlb_mm (struct mm_struct * mm )
1669
1671
{
1670
1672
if (mm -> context != NO_CONTEXT ) {
1671
- cpumask_t cpu_mask ;
1672
- cpumask_copy (& cpu_mask , mm_cpumask (mm ));
1673
- cpumask_clear_cpu (smp_processor_id (), & cpu_mask );
1674
- if (!cpumask_empty (& cpu_mask )) {
1673
+ if (any_other_mm_cpus (mm )) {
1675
1674
xc1 (local_ops -> tlb_mm , (unsigned long )mm );
1676
1675
if (atomic_read (& mm -> mm_users ) == 1 && current -> active_mm == mm )
1677
1676
cpumask_copy (mm_cpumask (mm ),
@@ -1688,10 +1687,7 @@ static void smp_flush_cache_range(struct vm_area_struct *vma,
1688
1687
struct mm_struct * mm = vma -> vm_mm ;
1689
1688
1690
1689
if (mm -> context != NO_CONTEXT ) {
1691
- cpumask_t cpu_mask ;
1692
- cpumask_copy (& cpu_mask , mm_cpumask (mm ));
1693
- cpumask_clear_cpu (smp_processor_id (), & cpu_mask );
1694
- if (!cpumask_empty (& cpu_mask ))
1690
+ if (any_other_mm_cpus (mm ))
1695
1691
xc3 (local_ops -> cache_range , (unsigned long )vma , start ,
1696
1692
end );
1697
1693
local_ops -> cache_range (vma , start , end );
@@ -1705,10 +1701,7 @@ static void smp_flush_tlb_range(struct vm_area_struct *vma,
1705
1701
struct mm_struct * mm = vma -> vm_mm ;
1706
1702
1707
1703
if (mm -> context != NO_CONTEXT ) {
1708
- cpumask_t cpu_mask ;
1709
- cpumask_copy (& cpu_mask , mm_cpumask (mm ));
1710
- cpumask_clear_cpu (smp_processor_id (), & cpu_mask );
1711
- if (!cpumask_empty (& cpu_mask ))
1704
+ if (any_other_mm_cpus (mm ))
1712
1705
xc3 (local_ops -> tlb_range , (unsigned long )vma , start ,
1713
1706
end );
1714
1707
local_ops -> tlb_range (vma , start , end );
@@ -1720,10 +1713,7 @@ static void smp_flush_cache_page(struct vm_area_struct *vma, unsigned long page)
1720
1713
struct mm_struct * mm = vma -> vm_mm ;
1721
1714
1722
1715
if (mm -> context != NO_CONTEXT ) {
1723
- cpumask_t cpu_mask ;
1724
- cpumask_copy (& cpu_mask , mm_cpumask (mm ));
1725
- cpumask_clear_cpu (smp_processor_id (), & cpu_mask );
1726
- if (!cpumask_empty (& cpu_mask ))
1716
+ if (any_other_mm_cpus (mm ))
1727
1717
xc2 (local_ops -> cache_page , (unsigned long )vma , page );
1728
1718
local_ops -> cache_page (vma , page );
1729
1719
}
@@ -1734,10 +1724,7 @@ static void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
1734
1724
struct mm_struct * mm = vma -> vm_mm ;
1735
1725
1736
1726
if (mm -> context != NO_CONTEXT ) {
1737
- cpumask_t cpu_mask ;
1738
- cpumask_copy (& cpu_mask , mm_cpumask (mm ));
1739
- cpumask_clear_cpu (smp_processor_id (), & cpu_mask );
1740
- if (!cpumask_empty (& cpu_mask ))
1727
+ if (any_other_mm_cpus (mm ))
1741
1728
xc2 (local_ops -> tlb_page , (unsigned long )vma , page );
1742
1729
local_ops -> tlb_page (vma , page );
1743
1730
}
@@ -1759,10 +1746,7 @@ static void smp_flush_page_to_ram(unsigned long page)
1759
1746
1760
1747
static void smp_flush_sig_insns (struct mm_struct * mm , unsigned long insn_addr )
1761
1748
{
1762
- cpumask_t cpu_mask ;
1763
- cpumask_copy (& cpu_mask , mm_cpumask (mm ));
1764
- cpumask_clear_cpu (smp_processor_id (), & cpu_mask );
1765
- if (!cpumask_empty (& cpu_mask ))
1749
+ if (any_other_mm_cpus (mm ))
1766
1750
xc2 (local_ops -> sig_insns , (unsigned long )mm , insn_addr );
1767
1751
local_ops -> sig_insns (mm , insn_addr );
1768
1752
}
0 commit comments