From: Nicholas Piggin <npiggin@gmail•com>
To: linuxppc-dev@lists•ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail•com>
Subject: [PATCH v4 10/21] powerpc/64s/hash: improve context tracking of hash faults
Date: Sat, 2 Jan 2021 22:24:57 +1000 [thread overview]
Message-ID: <20210102122508.1950592-11-npiggin@gmail.com> (raw)
In-Reply-To: <20210102122508.1950592-1-npiggin@gmail.com>
This moves the 64s/hash context tracking from hash_page_mm() to
__do_hash_fault(), so it's no longer called by OCXL / SPU
accelerators, which was certainly the wrong thing to be doing,
because those callers are not low level interrupt handlers, so
should have entered a kernel context tracking already.
Then remain in kernel context for the duration of the fault,
rather than enter/exit for the hash fault then enter/exit for
the page fault, which is pointless.
Even still, calling exception_enter/exit in __do_hash_fault seems
questionable because that's touching per-cpu variables, tracing,
etc., which might have been interrupted by this hash fault or
themselves cause hash faults. But maybe I miss something because
hash_page_mm very deliberately calls trace_hash_fault too, for
example. So for now go with it, it's no worse than before, in this
regard.
Signed-off-by: Nicholas Piggin <npiggin@gmail•com>
---
arch/powerpc/include/asm/bug.h | 1 +
arch/powerpc/mm/book3s64/hash_utils.c | 7 ++++---
arch/powerpc/mm/fault.c | 9 +++++++++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 4220789b9a97..e048c820ca02 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -112,6 +112,7 @@
struct pt_regs;
long do_page_fault(struct pt_regs *);
+long hash__do_page_fault(struct pt_regs *);
void bad_page_fault(struct pt_regs *, int);
void __bad_page_fault(struct pt_regs *regs, int sig);
extern void _exception(int, struct pt_regs *, int, unsigned long);
diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
index 453afb9ae9b4..801d5e94cd2b 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -1289,7 +1289,6 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea,
unsigned long flags)
{
bool is_thp;
- enum ctx_state prev_state = exception_enter();
pgd_t *pgdir;
unsigned long vsid;
pte_t *ptep;
@@ -1491,7 +1490,6 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea,
DBG_LOW(" -> rc=%d\n", rc);
bail:
- exception_exit(prev_state);
return rc;
}
EXPORT_SYMBOL_GPL(hash_page_mm);
@@ -1515,6 +1513,7 @@ EXPORT_SYMBOL_GPL(hash_page);
DEFINE_INTERRUPT_HANDLER_RET(__do_hash_fault)
{
+ enum ctx_state prev_state = exception_enter();
unsigned long ea = regs->dar;
unsigned long dsisr = regs->dsisr;
unsigned long access = _PAGE_PRESENT | _PAGE_READ;
@@ -1563,9 +1562,11 @@ DEFINE_INTERRUPT_HANDLER_RET(__do_hash_fault)
err = 0;
} else if (err) {
- err = do_page_fault(regs);
+ err = hash__do_page_fault(regs);
}
+ exception_exit(prev_state);
+
return err;
}
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 81dbce473726..cc71c93cceaf 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -589,6 +589,15 @@ DEFINE_INTERRUPT_HANDLER_RET(do_page_fault)
}
NOKPROBE_SYMBOL(do_page_fault);
+#ifdef CONFIG_PPC_BOOK3S_64
+/* Same as do_page_fault but interrupt entry has already run in do_hash_fault */
+long hash__do_page_fault(struct pt_regs *regs)
+{
+ return __do_page_fault(regs);
+}
+NOKPROBE_SYMBOL(hash__do_page_fault);
+#endif
+
/*
* bad_page_fault is called when we have a bad access from the kernel.
* It is called from the DSI and ISI handlers in head.S and from some
--
2.23.0
next prev parent reply other threads:[~2021-01-02 12:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-02 12:24 [PATCH v4 00/21] powerpc: interrupt wrappers Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 01/21] powerpc/32s: Do DABR match out of handle_page_fault() Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 02/21] powerpc/64s: move the last of the page fault handling logic to C Nicholas Piggin
2021-01-02 17:56 ` Christophe Leroy
2021-01-03 9:17 ` Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 03/21] powerpc: remove arguments from fault handler functions Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 04/21] powerpc: bad_page_fault, do_break get registers from regs Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 05/21] powerpc/perf: move perf irq/nmi handling details into traps.c Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 06/21] powerpc: interrupt handler wrapper functions Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 07/21] powerpc: add interrupt wrapper entry / exit stub functions Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 08/21] powerpc: add interrupt_cond_local_irq_enable helper Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 09/21] powerpc/64: context tracking remove _TIF_NOHZ Nicholas Piggin
2021-01-02 12:24 ` Nicholas Piggin [this message]
2021-01-02 12:24 ` [PATCH v4 11/21] powerpc/64: context tracking move to interrupt wrappers Nicholas Piggin
2021-01-02 12:24 ` [PATCH v4 12/21] powerpc/64: add context tracking to asynchronous interrupts Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 13/21] powerpc: handle irq_enter/irq_exit in interrupt handler wrappers Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 14/21] powerpc/64s: move context tracking exit to interrupt exit path Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 15/21] powerpc/64s: reconcile interrupts in C Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 16/21] powerpc/64: move account_stolen_time into its own function Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 17/21] powerpc/64: entry cpu time accounting in C Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 18/21] powerpc: move NMI entry/exit code into wrapper Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 19/21] powerpc/64s: move NMI soft-mask handling to C Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 20/21] powerpc/64s: runlatch interrupt handling in C Nicholas Piggin
2021-01-02 12:25 ` [PATCH v4 21/21] powerpc/64s: power4 nap fixup " Nicholas Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210102122508.1950592-11-npiggin@gmail.com \
--to=npiggin@gmail$(echo .)com \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox