From: benjamin@sipsolutions.net
To: linux-um@lists.infradead.org
Cc: Benjamin Berg <benjamin.berg@intel.com>
Subject: [PATCH v2 10/12] um: remove force_flush_all from fork_handler
Date: Mon, 29 Apr 2024 15:47:57 +0200 [thread overview]
Message-ID: <20240429134759.244517-11-benjamin@sipsolutions.net> (raw)
In-Reply-To: <20240429134759.244517-1-benjamin@sipsolutions.net>
From: Benjamin Berg <benjamin.berg@intel.com>
There should be no need for this. It may be that this used to work
around another issue where after a clone the MM was in a bad state.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
---
arch/um/include/asm/mmu_context.h | 2 --
arch/um/kernel/process.c | 2 --
arch/um/kernel/tlb.c | 46 +++++++++++--------------------
3 files changed, 16 insertions(+), 34 deletions(-)
diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h
index 68e2eb9cfb47..23dcc914d44e 100644
--- a/arch/um/include/asm/mmu_context.h
+++ b/arch/um/include/asm/mmu_context.h
@@ -13,8 +13,6 @@
#include <asm/mm_hooks.h>
#include <asm/mmu.h>
-extern void force_flush_all(void);
-
#define activate_mm activate_mm
static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
{
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index ab95648e93e1..390bf711fbd1 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -139,8 +139,6 @@ void new_thread_handler(void)
/* Called magically, see new_thread_handler above */
void fork_handler(void)
{
- force_flush_all();
-
schedule_tail(current->thread.prev_sched);
/*
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
index 391c98137890..f183a9b9ff7b 100644
--- a/arch/um/kernel/tlb.c
+++ b/arch/um/kernel/tlb.c
@@ -40,17 +40,15 @@ struct host_vm_change {
int index;
struct mm_struct *mm;
void *data;
- int force;
};
-#define INIT_HVC(mm, force, userspace) \
+#define INIT_HVC(mm, userspace) \
((struct host_vm_change) \
{ .ops = { { .type = NONE } }, \
.mm = mm, \
.data = NULL, \
.userspace = userspace, \
- .index = 0, \
- .force = force })
+ .index = 0 })
void report_enomem(void)
{
@@ -234,7 +232,7 @@ static inline int update_pte_range(pmd_t *pmd, unsigned long addr,
prot = ((r ? UM_PROT_READ : 0) | (w ? UM_PROT_WRITE : 0) |
(x ? UM_PROT_EXEC : 0));
- if (hvc->force || pte_newpage(*pte)) {
+ if (pte_newpage(*pte)) {
if (pte_present(*pte)) {
if (pte_newpage(*pte))
ret = add_mmap(addr, pte_val(*pte) & PAGE_MASK,
@@ -260,7 +258,7 @@ static inline int update_pmd_range(pud_t *pud, unsigned long addr,
do {
next = pmd_addr_end(addr, end);
if (!pmd_present(*pmd)) {
- if (hvc->force || pmd_newpage(*pmd)) {
+ if (pmd_newpage(*pmd)) {
ret = add_munmap(addr, next - addr, hvc);
pmd_mkuptodate(*pmd);
}
@@ -282,7 +280,7 @@ static inline int update_pud_range(p4d_t *p4d, unsigned long addr,
do {
next = pud_addr_end(addr, end);
if (!pud_present(*pud)) {
- if (hvc->force || pud_newpage(*pud)) {
+ if (pud_newpage(*pud)) {
ret = add_munmap(addr, next - addr, hvc);
pud_mkuptodate(*pud);
}
@@ -304,7 +302,7 @@ static inline int update_p4d_range(pgd_t *pgd, unsigned long addr,
do {
next = p4d_addr_end(addr, end);
if (!p4d_present(*p4d)) {
- if (hvc->force || p4d_newpage(*p4d)) {
+ if (p4d_newpage(*p4d)) {
ret = add_munmap(addr, next - addr, hvc);
p4d_mkuptodate(*p4d);
}
@@ -315,19 +313,19 @@ static inline int update_p4d_range(pgd_t *pgd, unsigned long addr,
}
static void fix_range_common(struct mm_struct *mm, unsigned long start_addr,
- unsigned long end_addr, int force)
+ unsigned long end_addr)
{
pgd_t *pgd;
struct host_vm_change hvc;
unsigned long addr = start_addr, next;
int ret = 0, userspace = 1;
- hvc = INIT_HVC(mm, force, userspace);
+ hvc = INIT_HVC(mm, userspace);
pgd = pgd_offset(mm, addr);
do {
next = pgd_addr_end(addr, end_addr);
if (!pgd_present(*pgd)) {
- if (force || pgd_newpage(*pgd)) {
+ if (pgd_newpage(*pgd)) {
ret = add_munmap(addr, next - addr, &hvc);
pgd_mkuptodate(*pgd);
}
@@ -348,11 +346,11 @@ static int flush_tlb_kernel_range_common(unsigned long start, unsigned long end)
pmd_t *pmd;
pte_t *pte;
unsigned long addr, last;
- int updated = 0, err = 0, force = 0, userspace = 0;
+ int updated = 0, err = 0, userspace = 0;
struct host_vm_change hvc;
mm = &init_mm;
- hvc = INIT_HVC(mm, force, userspace);
+ hvc = INIT_HVC(mm, userspace);
for (addr = start; addr < end;) {
pgd = pgd_offset(mm, addr);
if (!pgd_present(*pgd)) {
@@ -536,7 +534,7 @@ void __flush_tlb_one(unsigned long addr)
}
static void fix_range(struct mm_struct *mm, unsigned long start_addr,
- unsigned long end_addr, int force)
+ unsigned long end_addr)
{
/*
* Don't bother flushing if this address space is about to be
@@ -545,7 +543,7 @@ static void fix_range(struct mm_struct *mm, unsigned long start_addr,
if (atomic_read(&mm->mm_users) == 0)
return;
- fix_range_common(mm, start_addr, end_addr, force);
+ fix_range_common(mm, start_addr, end_addr);
}
void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
@@ -553,14 +551,14 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
{
if (vma->vm_mm == NULL)
flush_tlb_kernel_range_common(start, end);
- else fix_range(vma->vm_mm, start, end, 0);
+ else fix_range(vma->vm_mm, start, end);
}
EXPORT_SYMBOL(flush_tlb_range);
void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
unsigned long end)
{
- fix_range(mm, start, end, 0);
+ fix_range(mm, start, end);
}
void flush_tlb_mm(struct mm_struct *mm)
@@ -569,17 +567,5 @@ void flush_tlb_mm(struct mm_struct *mm)
VMA_ITERATOR(vmi, mm, 0);
for_each_vma(vmi, vma)
- fix_range(mm, vma->vm_start, vma->vm_end, 0);
-}
-
-void force_flush_all(void)
-{
- struct mm_struct *mm = current->mm;
- struct vm_area_struct *vma;
- VMA_ITERATOR(vmi, mm, 0);
-
- mmap_read_lock(mm);
- for_each_vma(vmi, vma)
- fix_range(mm, vma->vm_start, vma->vm_end, 1);
- mmap_read_unlock(mm);
+ fix_range(mm, vma->vm_start, vma->vm_end);
}
--
2.44.0
next prev parent reply other threads:[~2024-04-29 13:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 13:47 [PATCH v2 00/12] Rework stub syscall and page table handling benjamin
2024-04-29 13:47 ` [PATCH v2 01/12] um: Remove stub-data.h include from common-offsets.h benjamin
2024-04-29 13:47 ` [PATCH v2 02/12] um: Create signal stack memory assignment in stub_data benjamin
2024-04-29 13:47 ` [PATCH v2 03/12] um: Add generic stub_syscall6 function benjamin
2024-04-29 13:47 ` [PATCH v2 04/12] um: Rework syscall handling benjamin
2024-04-29 13:47 ` [PATCH v2 05/12] um: compress memory related stub syscalls while adding them benjamin
2024-04-29 13:47 ` [PATCH v2 06/12] um: remove LDT support benjamin
2024-04-29 13:47 ` [PATCH v2 07/12] um: remove copy_context_skas0 benjamin
2024-04-29 13:47 ` [PATCH v2 08/12] um: Delay flushing syscalls until the thread is restarted benjamin
2024-04-29 13:47 ` [PATCH v2 09/12] um: Do not flush MM in flush_thread benjamin
2024-04-29 13:47 ` benjamin [this message]
2024-04-29 13:47 ` [PATCH v2 11/12] um: simplify and consolidate TLB updates benjamin
2024-04-29 13:47 ` [PATCH v2 12/12] um: refactor TLB update handling benjamin
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=20240429134759.244517-11-benjamin@sipsolutions.net \
--to=benjamin@sipsolutions.net \
--cc=benjamin.berg@intel.com \
--cc=linux-um@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).