From: David Hildenbrand <hidden> Date: 2019-01-14 12:59:28
Nothing major changed since the last version. I would be happy about
additional ACKs. If there are no further comments, can this go via the
mm-tree in one chunk?
I was recently going over all users of PG_reserved. Short story: it is
difficult and sometimes not really clear if setting/checking for
PG_reserved is only a relict from the past. Easy to break things. I
guess I now have a pretty good idea wh things are like that
nowadays and how they evolved.
I had way more cleanups in this series inititally,
but some architectures take PG_reserved as a way to apply a different
caching strategy (for MMIO pages). So I decided to only include the most
obvious changes (that are less likely to break something). So the big
chunk of manual SetPageReserved users are MMIO/DMA related things on
device buffers.
Most notably, for device memory we will hopefully soon stop setting
PG_reserved. Then the documentation has to be updated.
v1 -> v2:
- Minor speeling errors in "mm: better document PG_reserved" fixed
- Added ACKs
RFC -> v1:
- Add more details to "mm: better document PG_reserved"
- Add "arm64: kdump: No need to mark crashkernel pages manually
PG_reserved"
- Add "ia64: perfmon: Don't mark buffer pages as PG_reserved"
- Added ACKs
David Hildenbrand (9):
agp: efficeon: no need to set PG_reserved on GATT tables
s390/vdso: don't clear PG_reserved
powerpc/vdso: don't clear PG_reserved
riscv/vdso: don't clear PG_reserved
m68k/mm: use __ClearPageReserved()
arm64: kexec: no need to ClearPageReserved()
arm64: kdump: No need to mark crashkernel pages manually PG_reserved
ia64: perfmon: Don't mark buffer pages as PG_reserved
mm: better document PG_reserved
arch/arm64/kernel/machine_kexec.c | 3 +-
arch/arm64/mm/init.c | 27 --------------
arch/ia64/kernel/perfmon.c | 59 +++----------------------------
arch/m68k/mm/memory.c | 2 +-
arch/powerpc/kernel/vdso.c | 2 --
arch/riscv/kernel/vdso.c | 1 -
arch/s390/kernel/vdso.c | 2 --
drivers/char/agp/efficeon-agp.c | 2 --
include/linux/page-flags.h | 33 +++++++++++++++--
9 files changed, 37 insertions(+), 94 deletions(-)
--
2.17.2
From: David Hildenbrand <hidden> Date: 2019-01-14 12:59:32
The l1 GATT page table is kept in a special on-chip page with 64 entries.
We allocate the l2 page table pages via get_zeroed_page() and enter them
into the table. These l2 pages are modified accordingly when
inserting/removing memory via efficeon_insert_memory and
efficeon_remove_memory.
Apart from that, these pages are not exposed or ioremap'ed. We can stop
setting them reserved (propably copied from generic code).
Cc: David Airlie <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Hildenbrand <redacted>
---
drivers/char/agp/efficeon-agp.c | 2 --
1 file changed, 2 deletions(-)
From: David Hildenbrand <hidden> Date: 2019-01-14 12:59:36
The VDSO is part of the kernel image and therefore the struct pages are
marked as reserved during boot.
As we install a special mapping, the actual struct pages will never be
exposed to MM via the page tables. We can therefore leave the pages
marked as reserved.
Suggested-by: Martin Schwidefsky <redacted>
Cc: Martin Schwidefsky <redacted>
Cc: Heiko Carstens <redacted>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Rapoport <redacted>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Kees Cook <redacted>
Cc: Souptick Joarder <redacted>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: David Hildenbrand <redacted>
---
arch/s390/kernel/vdso.c | 2 --
1 file changed, 2 deletions(-)
From: David Hildenbrand <hidden> Date: 2019-01-14 12:59:40
The VDSO is part of the kernel image and therefore the struct pages are
marked as reserved during boot.
As we install a special mapping, the actual struct pages will never be
exposed to MM via the page tables. We can therefore leave the pages
marked as reserved.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <redacted>
Cc: Kees Cook <redacted>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Signed-off-by: David Hildenbrand <redacted>
---
arch/powerpc/kernel/vdso.c | 2 --
1 file changed, 2 deletions(-)
From: David Hildenbrand <hidden> Date: 2019-01-14 12:59:44
The VDSO is part of the kernel image and therefore the struct pages are
marked as reserved during boot.
As we install a special mapping, the actual struct pages will never be
exposed to MM via the page tables. We can therefore leave the pages
marked as reserved.
Cc: Palmer Dabbelt <redacted>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Tobias Klauser <tklauser@distanz.ch>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Acked-by: Palmer Dabbelt <redacted>
Signed-off-by: David Hildenbrand <redacted>
---
arch/riscv/kernel/vdso.c | 1 -
1 file changed, 1 deletion(-)
From: David Hildenbrand <hidden> Date: 2019-01-14 12:59:47
The PG_reserved flag is cleared from memory that is part of the kernel
image (and therefore marked as PG_reserved). Avoid using PG_reserved
directly.
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Hildenbrand <redacted>
---
arch/m68k/mm/memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -51,7 +51,7 @@ void __init init_pointer_table(unsigned long ptable)pr_debug("init_pointer_table: %lx, %x\n",ptable,PD_MARKBITS(dp));/* unreserve the page so it's possible to free that page */-PD_PAGE(dp)->flags&=~(1<<PG_reserved);+__ClearPageReserved(PD_PAGE(dp));init_page_count(PD_PAGE(dp));return;
From: David Hildenbrand <hidden> Date: 2019-01-14 12:59:54
This will be done by free_reserved_page().
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <redacted>
Cc: Bhupesh Sharma <redacted>
Cc: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <redacted>
Cc: Dave Kleikamp <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Acked-by: James Morse <james.morse@arm.com>
Signed-off-by: David Hildenbrand <redacted>
---
arch/arm64/kernel/machine_kexec.c | 1 -
1 file changed, 1 deletion(-)
From: David Hildenbrand <hidden> Date: 2019-01-14 13:00:07
The crashkernel is reserved via memblock_reserve(). memblock_free_all()
will call free_low_memory_core_early(), which will go over all reserved
memblocks, marking the pages as PG_reserved.
So manually marking pages as PG_reserved is not necessary, they are
already in the desired state (otherwise they would have been handed over
to the buddy as free pages and bad things would happen).
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <redacted>
Cc: James Morse <james.morse@arm.com>
Cc: Bhupesh Sharma <redacted>
Cc: David Hildenbrand <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Dave Kleikamp <redacted>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <redacted>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Laura Abbott <redacted>
Cc: Greg Hackmann <redacted>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kristina Martsenko <redacted>
Cc: CHANDAN VN <redacted>
Cc: AKASHI Takahiro <redacted>
Cc: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: David Hildenbrand <redacted>
---
arch/arm64/kernel/machine_kexec.c | 2 +-
arch/arm64/mm/init.c | 27 ---------------------------
2 files changed, 1 insertion(+), 28 deletions(-)
@@ -586,8 +561,6 @@ void __init mem_init(void)/* this will put all unused low memory onto the freelists */memblock_free_all();-kexec_reserve_crashkres_pages();-mem_init_print_info(NULL);/*
From: David Hildenbrand <hidden> Date: 2019-01-14 13:00:49
In the old days, remap_pfn_range() required pages to be marked as
PG_reserved, so they would e.g. never get swapped out. This was required
for special mappings. Nowadays, this is fully handled via the VMA
(VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP inside remap_pfn_range()
to be precise). PG_reserved is no longer required but only a relict from
the past.
So only architecture specific MM handling might require it (e.g. to
detect them as MMIO pages). As there are no architecture specific checks
for PageReserved() apart from MCA handling in ia64code, this can go. Use
simple vzalloc()/vfree() instead.
Note that before calling vzalloc(), size has already been aligned to
PAGE_SIZE, no need to align again.
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <redacted>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <redacted>
Cc: David Howells <dhowells@redhat.com>
Cc: Mike Rapoport <redacted>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: David Hildenbrand <redacted>
---
arch/ia64/kernel/perfmon.c | 59 +++-----------------------------------
1 file changed, 4 insertions(+), 55 deletions(-)
From: David Hildenbrand <hidden> Date: 2019-01-14 13:00:53
The usage of PG_reserved and how PG_reserved pages are to be treated is
buried deep down in different parts of the kernel. Let's shine some light
onto these details by documenting current users and expected
behavior.
Especially, clarify on the "Some of them might not even exist" case.
These are physical memory gaps that will never be dumped as they
are not marked as IORESOURCE_SYSRAM. PG_reserved does in general not
hinder anybody from dumping or swapping. In some cases, these pages
will not be stored in the hibernation image.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Stephen Rothwell <redacted>
Cc: Pavel Tatashin <redacted>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Alexander Duyck <redacted>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Anthony Yznaga <redacted>
Cc: Miles Chen <redacted>
Cc: yi.z.zhang@linux.intel.com
Cc: Dan Williams <redacted>
Cc: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: David Hildenbrand <redacted>
---
include/linux/page-flags.h | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
On Mon, Jan 14, 2019 at 1:59 PM David Hildenbrand [off-list ref] wrote:
The PG_reserved flag is cleared from memory that is part of the kernel
image (and therefore marked as PG_reserved). Avoid using PG_reserved
directly.
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Hildenbrand <redacted>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
BTW, it's a pity ctags doesn't know where __ClearPageReserved()
is defined.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi David,
Thanks for the patch.
On Mon, Jan 14, 2019 at 6:29 PM David Hildenbrand [off-list ref] wrote:
quoted hunk
This will be done by free_reserved_page().
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <redacted>
Cc: Bhupesh Sharma <redacted>
Cc: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <redacted>
Cc: Dave Kleikamp <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Acked-by: James Morse <james.morse@arm.com>
Signed-off-by: David Hildenbrand <redacted>
---
arch/arm64/kernel/machine_kexec.c | 1 -
1 file changed, 1 deletion(-)
Hi David,
On Mon, Jan 14, 2019 at 6:30 PM David Hildenbrand [off-list ref] wrote:
quoted hunk
The crashkernel is reserved via memblock_reserve(). memblock_free_all()
will call free_low_memory_core_early(), which will go over all reserved
memblocks, marking the pages as PG_reserved.
So manually marking pages as PG_reserved is not necessary, they are
already in the desired state (otherwise they would have been handed over
to the buddy as free pages and bad things would happen).
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <redacted>
Cc: James Morse <james.morse@arm.com>
Cc: Bhupesh Sharma <redacted>
Cc: David Hildenbrand <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Dave Kleikamp <redacted>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <redacted>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Laura Abbott <redacted>
Cc: Greg Hackmann <redacted>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kristina Martsenko <redacted>
Cc: CHANDAN VN <redacted>
Cc: AKASHI Takahiro <redacted>
Cc: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: David Hildenbrand <redacted>
---
arch/arm64/kernel/machine_kexec.c | 2 +-
arch/arm64/mm/init.c | 27 ---------------------------
2 files changed, 1 insertion(+), 28 deletions(-)
@@ -586,8 +561,6 @@ void __init mem_init(void)/* this will put all unused low memory onto the freelists */memblock_free_all();-kexec_reserve_crashkres_pages();-mem_init_print_info(NULL);/*--
From: Christoph Hellwig <hch@infradead.org> Date: 2019-01-15 15:38:45
On Mon, Jan 14, 2019 at 01:58:54PM +0100, David Hildenbrand wrote:
Nothing major changed since the last version. I would be happy about
additional ACKs. If there are no further comments, can this go via the
mm-tree in one chunk?
I was recently going over all users of PG_reserved. Short story: it is
difficult and sometimes not really clear if setting/checking for
PG_reserved is only a relict from the past. Easy to break things. I
guess I now have a pretty good idea wh things are like that
nowadays and how they evolved.
Any reason you skipped
drivers/gpu/drm/drm_pci.c:drm_pci_alloc()
and
drivers/gpu/drm/drm_scatter.c:drm_legacy_sg_alloc()
which both look completely bogus as-is?
In fact we should probably just try to kill them off as they have
very few users left.
From: David Hildenbrand <hidden> Date: 2019-01-15 15:53:20
On 15.01.19 16:38, Christoph Hellwig wrote:
On Mon, Jan 14, 2019 at 01:58:54PM +0100, David Hildenbrand wrote:
quoted
Nothing major changed since the last version. I would be happy about
additional ACKs. If there are no further comments, can this go via the
mm-tree in one chunk?
I was recently going over all users of PG_reserved. Short story: it is
difficult and sometimes not really clear if setting/checking for
PG_reserved is only a relict from the past. Easy to break things. I
guess I now have a pretty good idea wh things are like that
nowadays and how they evolved.
Any reason you skipped
drivers/gpu/drm/drm_pci.c:drm_pci_alloc()
and
drivers/gpu/drm/drm_scatter.c:drm_legacy_sg_alloc()
which both look completely bogus as-is?
In fact we should probably just try to kill them off as they have
very few users left.
I actually have patches lying around for these, however excluded them
for now as I was not 100% sure about the implications ("Easy to break
things").
Are you sure nobody in the system (especially somebody who does a
PageReserved()) relies on this to identify e.g. MMIO pages? (e.g.
ioremap on some archs, KVM code)
(I am by far no DRM expert, but when I hear DMA, I tend to be careful)
--
Thanks,
David / dhildenb
From: David Hildenbrand <hidden> Date: 2019-01-21 11:36:59
On 14.01.19 13:58, David Hildenbrand wrote:
Nothing major changed since the last version. I would be happy about
additional ACKs. If there are no further comments, can this go via the
mm-tree in one chunk?
For the time being, I will not add further patches to this series (as
discussed in response to one question, we have to be careful dropping
PG_reserved at some places). Only ACKs were added during review so far.
@Andrew, how to proceed with this?
--
Thanks,
David / dhildenb
On Mon, Jan 14, 2019 at 01:59:00PM +0100, David Hildenbrand wrote:
This will be done by free_reserved_page().
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <redacted>
Cc: Bhupesh Sharma <redacted>
Cc: James Morse <james.morse@arm.com>
Cc: Marc Zyngier <redacted>
Cc: Dave Kleikamp <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Acked-by: James Morse <james.morse@arm.com>
Signed-off-by: David Hildenbrand <redacted>
On Mon, Jan 14, 2019 at 01:59:01PM +0100, David Hildenbrand wrote:
The crashkernel is reserved via memblock_reserve(). memblock_free_all()
will call free_low_memory_core_early(), which will go over all reserved
memblocks, marking the pages as PG_reserved.
So manually marking pages as PG_reserved is not necessary, they are
already in the desired state (otherwise they would have been handed over
to the buddy as free pages and bad things would happen).
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <redacted>
Cc: James Morse <james.morse@arm.com>
Cc: Bhupesh Sharma <redacted>
Cc: David Hildenbrand <redacted>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Dave Kleikamp <redacted>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <redacted>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Laura Abbott <redacted>
Cc: Greg Hackmann <redacted>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kristina Martsenko <redacted>
Cc: CHANDAN VN <redacted>
Cc: AKASHI Takahiro <redacted>
Cc: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: David Hildenbrand <redacted>