Skip to content

Commit a92cbb8

Browse files
Hugh Dickinsakpm00
authored andcommitted
perf/core: allow pte_offset_map() to fail
In rare transient cases, not yet made possible, pte_offset_map() and pte_offet_map_lock() may not find a page table: handle appropriately. [[email protected]: __wp_page_copy_user(): don't call update_mmu_tlb() with NULL] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Hugh Dickins <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Axel Rasmussen <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: "Huang, Ying" <[email protected]> Cc: Ira Weiny <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Miaohe Lin <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Mike Rapoport (IBM) <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Peter Xu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Qi Zheng <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: SeongJae Park <[email protected]> Cc: Song Liu <[email protected]> Cc: Steven Price <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Thomas Hellström <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yang Shi <[email protected]> Cc: Yu Zhao <[email protected]> Cc: Zack Rusin <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4f8fcf4 commit a92cbb8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

kernel/events/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7490,6 +7490,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
74907490
return pud_leaf_size(pud);
74917491

74927492
pmdp = pmd_offset_lockless(pudp, pud, addr);
7493+
again:
74937494
pmd = pmdp_get_lockless(pmdp);
74947495
if (!pmd_present(pmd))
74957496
return 0;
@@ -7498,6 +7499,9 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
74987499
return pmd_leaf_size(pmd);
74997500

75007501
ptep = pte_offset_map(&pmd, addr);
7502+
if (!ptep)
7503+
goto again;
7504+
75017505
pte = ptep_get_lockless(ptep);
75027506
if (pte_present(pte))
75037507
size = pte_leaf_size(pte);

mm/memory.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src,
28432843
* Other thread has already handled the fault
28442844
* and update local tlb only
28452845
*/
2846-
update_mmu_tlb(vma, addr, vmf->pte);
2846+
if (vmf->pte)
2847+
update_mmu_tlb(vma, addr, vmf->pte);
28472848
ret = -EAGAIN;
28482849
goto pte_unlock;
28492850
}
@@ -2867,7 +2868,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src,
28672868
vmf->pte = pte_offset_map_lock(mm, vmf->pmd, addr, &vmf->ptl);
28682869
if (unlikely(!vmf->pte || !pte_same(*vmf->pte, vmf->orig_pte))) {
28692870
/* The PTE changed under us, update local tlb */
2870-
update_mmu_tlb(vma, addr, vmf->pte);
2871+
if (vmf->pte)
2872+
update_mmu_tlb(vma, addr, vmf->pte);
28712873
ret = -EAGAIN;
28722874
goto pte_unlock;
28732875
}

0 commit comments

Comments
 (0)