From: Rolf Eike Beer <eb@emlix.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] mm: pagewalk: allow walk_page_range_novma() without mm
Date: Mon, 22 Aug 2022 15:03:29 +0200 [thread overview]
Message-ID: <5760214.MhkbZ0Pkbq@devpool047> (raw)
In-Reply-To: <3200642.44csPzL39Z@devpool047>
Since e47690d756a7 ("x86: mm: avoid allocating struct mm_struct on the
stack") a pgd can be passed to walk_page_range_novma(). In case it is set
no place in the pagewalk code use the walk.mm anymore, so permit to pass a
NULL mm instead. It is up to the caller to ensure proper locking on the pgd
in this case.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
mm/pagewalk.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index dc3c850cd148..f816f86588be 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -506,6 +506,8 @@ int walk_page_range(struct mm_struct *mm, unsigned long start,
* not backed by VMAs. Because 'unusual' entries may be walked this function
* will also not lock the PTEs for the pte_entry() callback. This is useful for
* walking the kernel pages tables or page tables for firmware.
+ *
+ * Either mm or pgd may be NULL, but not both.
*/
int walk_page_range_novma(struct mm_struct *mm, unsigned long start,
unsigned long end, const struct mm_walk_ops *ops,
@@ -520,10 +522,11 @@ int walk_page_range_novma(struct mm_struct *mm, unsigned long start,
.no_vma = true
};
- if (start >= end || !walk.mm)
+ if (start >= end || (!walk.mm && !walk.pgd))
return -EINVAL;
- mmap_assert_locked(walk.mm);
+ if (walk.mm)
+ mmap_assert_locked(walk.mm);
return walk_pgd_range(start, end, &walk);
}
--
2.37.2
--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055
emlix - smart embedded open source
next prev parent reply other threads:[~2022-08-22 13:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 12:59 [PATCH 0/6] Minor improvements for pagewalk code Rolf Eike Beer
2022-08-22 13:00 ` [PATCH 2/6] mm: pagewalk: don't check vma in walk_page_range_novma() Rolf Eike Beer
2022-08-22 13:01 ` [PATCH 3/6] mm: pagewalk: fix documentation of PTE hole handling Rolf Eike Beer
2022-08-22 13:02 ` [PATCH 4/6] mm: pagewalk: add api documentation for walk_page_range_novma() Rolf Eike Beer
2022-08-22 13:03 ` Rolf Eike Beer [this message]
2022-08-22 13:04 ` [PATCH 6/6] mm: pagewalk: move variables to more local scope, tweak loops Rolf Eike Beer
[not found] ` <2203731.iZASKD2KPV@devpool047>
2022-08-22 20:53 ` [PATCH 1/6] mm: pagewalk: make error checks more obvious Andrew Morton
2022-08-24 11:00 ` [PATCH 7/6] mm: pagewalk: add back missing variable initializations Rolf Eike Beer
2022-08-24 15:08 ` Nathan Chancellor
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=5760214.MhkbZ0Pkbq@devpool047 \
--to=eb@emlix.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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 NNTP newsgroup(s).