mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 10:31:33 -04:00
misc: sgi-gru: remove interrupt-context page-table walks
The GRU TLB miss handler walks a process's page tables without holding
page-table locks or a reference to the mapped page. It also uses a kernel
page-table accessor on user page tables and supports only PMD-level large
mappings on x86-64.
Remove the direct walker. Send interrupt faults directly to user polling
mode so the existing call-OS fallback retries them in process context.
Remove the mmap-lock failure statistic that can no longer be incremented.
Fixes: 142586409c ("GRU Driver: page faults & exceptions")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@arm.com>
Link: https://patch.msgid.link/20260730111316.3672672-2-usama.anjum@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
facd8463a5
commit
928a8e9f52
@@ -166,13 +166,8 @@ static void get_clear_fault_map(struct gru_state *gru,
|
||||
}
|
||||
|
||||
/*
|
||||
* Atomic (interrupt context) & non-atomic (user context) functions to
|
||||
* convert a vaddr into a physical address. The size of the page
|
||||
* is returned in pageshift.
|
||||
* returns:
|
||||
* 0 - successful
|
||||
* < 0 - error code
|
||||
* 1 - (atomic only) try again in non-atomic context
|
||||
* Convert a user virtual address to a physical address in process context.
|
||||
* The size of the page is returned in pageshift.
|
||||
*/
|
||||
static int non_atomic_pte_lookup(struct vm_area_struct *vma,
|
||||
unsigned long vaddr, int write,
|
||||
@@ -192,87 +187,25 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* atomic_pte_lookup
|
||||
*
|
||||
* Convert a user virtual address to a physical address
|
||||
* Only supports Intel large pages (2MB only) on x86_64.
|
||||
* ZZZ - hugepage support is incomplete
|
||||
*
|
||||
* NOTE: mmap_lock is already held on entry to this function. This
|
||||
* guarantees existence of the page tables.
|
||||
*/
|
||||
static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
|
||||
int write, unsigned long *paddr, int *pageshift)
|
||||
{
|
||||
pgd_t *pgdp;
|
||||
p4d_t *p4dp;
|
||||
pud_t *pudp;
|
||||
pmd_t *pmdp;
|
||||
pte_t pte;
|
||||
|
||||
pgdp = pgd_offset(vma->vm_mm, vaddr);
|
||||
if (unlikely(pgd_none(*pgdp)))
|
||||
goto err;
|
||||
|
||||
p4dp = p4d_offset(pgdp, vaddr);
|
||||
if (unlikely(p4d_none(*p4dp)))
|
||||
goto err;
|
||||
|
||||
pudp = pud_offset(p4dp, vaddr);
|
||||
if (unlikely(pud_none(*pudp)))
|
||||
goto err;
|
||||
|
||||
pmdp = pmd_offset(pudp, vaddr);
|
||||
if (unlikely(pmd_none(*pmdp)))
|
||||
goto err;
|
||||
#ifdef CONFIG_X86_64
|
||||
if (unlikely(pmd_leaf(*pmdp)))
|
||||
pte = ptep_get((pte_t *)pmdp);
|
||||
else
|
||||
#endif
|
||||
pte = *pte_offset_kernel(pmdp, vaddr);
|
||||
|
||||
if (unlikely(!pte_present(pte) ||
|
||||
(write && (!pte_write(pte) || !pte_dirty(pte)))))
|
||||
return 1;
|
||||
|
||||
*paddr = pte_pfn(pte) << PAGE_SHIFT;
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
|
||||
#else
|
||||
*pageshift = PAGE_SHIFT;
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr,
|
||||
int write, int atomic, unsigned long *gpa, int *pageshift)
|
||||
{
|
||||
struct mm_struct *mm = gts->ts_mm;
|
||||
struct vm_area_struct *vma;
|
||||
unsigned long paddr;
|
||||
int ret, ps;
|
||||
int ps;
|
||||
|
||||
vma = find_vma(mm, vaddr);
|
||||
if (!vma)
|
||||
goto inval;
|
||||
|
||||
/*
|
||||
* Atomic lookup is faster & usually works even if called in non-atomic
|
||||
* context.
|
||||
*/
|
||||
rmb(); /* Must/check ms_range_active before loading PTEs */
|
||||
ret = atomic_pte_lookup(vma, vaddr, write, &paddr, &ps);
|
||||
if (ret) {
|
||||
if (atomic)
|
||||
goto upm;
|
||||
if (non_atomic_pte_lookup(vma, vaddr, write, &paddr, &ps))
|
||||
goto inval;
|
||||
}
|
||||
if (atomic)
|
||||
goto upm;
|
||||
|
||||
/* Order the caller's ms_range_active check before loading PTEs. */
|
||||
rmb();
|
||||
if (non_atomic_pte_lookup(vma, vaddr, write, &paddr, &ps))
|
||||
goto inval;
|
||||
if (is_gru_paddr(paddr))
|
||||
goto inval;
|
||||
paddr = paddr & ~((1UL << ps) - 1);
|
||||
@@ -569,19 +502,9 @@ static irqreturn_t gru_intr(int chiplet, int blade)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is running in interrupt context. Trylock the mmap_lock.
|
||||
* If it fails, retry the fault in user context.
|
||||
*/
|
||||
/* Address translation may sleep, so retry the fault in user context. */
|
||||
gts->ustats.fmm_tlbmiss++;
|
||||
if (!gts->ts_force_cch_reload &&
|
||||
mmap_read_trylock(gts->ts_mm)) {
|
||||
gru_try_dropin(gru, gts, tfh, NULL);
|
||||
mmap_read_unlock(gts->ts_mm);
|
||||
} else {
|
||||
tfh_user_polling_mode(tfh);
|
||||
STAT(intr_mm_lock_failed);
|
||||
}
|
||||
tfh_user_polling_mode(tfh);
|
||||
}
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ static int statistics_show(struct seq_file *s, void *p)
|
||||
printstat(s, intr_cbr);
|
||||
printstat(s, intr_tfh);
|
||||
printstat(s, intr_spurious);
|
||||
printstat(s, intr_mm_lock_failed);
|
||||
printstat(s, call_os);
|
||||
printstat(s, call_os_wait_queue);
|
||||
printstat(s, user_flush_tlb);
|
||||
|
||||
@@ -182,7 +182,6 @@ struct gru_stats_s {
|
||||
atomic_long_t intr_cbr;
|
||||
atomic_long_t intr_tfh;
|
||||
atomic_long_t intr_spurious;
|
||||
atomic_long_t intr_mm_lock_failed;
|
||||
atomic_long_t call_os;
|
||||
atomic_long_t call_os_wait_queue;
|
||||
atomic_long_t user_flush_tlb;
|
||||
|
||||
Reference in New Issue
Block a user