Re: [PATCH RFC v3 22/35] arm64: mte: Enable tag storage if CMA areas have been activated

2024-02-05 Thread Alexandru Elisei
Hi Evgenii, On Fri, Feb 02, 2024 at 02:30:00PM -0800, Evgenii Stepanov wrote: > On Thu, Jan 25, 2024 at 8:44 AM Alexandru Elisei > wrote: > > > > Before enabling MTE tag storage management, make sure that the CMA areas > > have been successfully activated. If a C

Re: [PATCH RFC v3 28/35] arm64: mte: swap: Handle tag restoring when missing tag storage

2024-02-02 Thread Alexandru Elisei
Hi Peter, On Thu, Feb 01, 2024 at 08:02:40PM -0800, Peter Collingbourne wrote: > On Thu, Jan 25, 2024 at 8:45 AM Alexandru Elisei > wrote: > > > > Linux restores tags when a page is swapped in and there are tags associated > > with the swap entry which the new page will

Re: [PATCH RFC v3 31/35] khugepaged: arm64: Don't collapse MTE enabled VMAs

2024-02-01 Thread Alexandru Elisei
On Thu, Feb 01, 2024 at 01:42:08PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > copy_user_highpage() will do memory allocation if there are saved tags for > > the destination page, and the page is missing tag storage. > > > &g

Re: [PATCH RFC v3 30/35] arm64: mte: ptrace: Handle pages with missing tag storage

2024-02-01 Thread Alexandru Elisei
Hi, On Thu, Feb 01, 2024 at 02:51:39PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > A page can end up mapped in a MTE enabled VMA without the corresponding tag > > storage block reserved. Tag accesses made by ptrace in this case can

Re: [PATCH RFC v3 13/35] mm: memory: Introduce fault-on-access mechanism for pages

2024-02-01 Thread Alexandru Elisei
Hi, On Thu, Feb 01, 2024 at 11:22:13AM +0530, Anshuman Khandual wrote: > On 1/25/24 22:12, Alexandru Elisei wrote: > > Introduce a mechanism that allows an architecture to trigger a page fault, > > and add the infrastructure to handle that fault accordingly. To use make> > &

Re: [PATCH RFC v3 12/35] mm: Call arch_swap_prepare_to_restore() before arch_swap_restore()

2024-02-01 Thread Alexandru Elisei
Hi, On Thu, Feb 01, 2024 at 09:00:23AM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > arm64 uses arch_swap_restore() to restore saved tags before the page is > > swapped in and it's called in atomic context (with the ptl lock held

Re: [PATCH RFC v3 08/35] mm: cma: Introduce cma_alloc_range()

2024-01-31 Thread Alexandru Elisei
Hi, On Wed, Jan 31, 2024 at 11:54:17AM +0530, Anshuman Khandual wrote: > > > On 1/30/24 17:05, Alexandru Elisei wrote: > > Hi, > > > > On Tue, Jan 30, 2024 at 10:50:00AM +0530, Anshuman Khandual wrote: > >> > >> On 1/25/24 22:12, Alexandru E

Re: [PATCH RFC v3 09/35] mm: cma: Introduce cma_remove_mem()

2024-01-31 Thread Alexandru Elisei
Hi, On Wed, Jan 31, 2024 at 06:49:34PM +0530, Anshuman Khandual wrote: > On 1/30/24 17:03, Alexandru Elisei wrote: > > Hi, > > > > I really appreciate the feedback you have given me so far. I believe the > > commit message isn't clear enough and there has been a con

Re: [PATCH RFC v3 06/35] mm: cma: Make CMA_ALLOC_SUCCESS/FAIL count the number of pages

2024-01-31 Thread Alexandru Elisei
Hi, On Wed, Jan 31, 2024 at 10:10:05AM +0530, Anshuman Khandual wrote: > > > On 1/30/24 17:28, Alexandru Elisei wrote: > > Hi, > > > > On Tue, Jan 30, 2024 at 10:22:11AM +0530, Anshuman Khandual wrote: > >> > >> On 1/29/24 17:21, Alexandru Elise

Re: [PATCH RFC v3 11/35] mm: Allow an arch to hook into folio allocation when VMA is known

2024-01-31 Thread Alexandru Elisei
Hi, On Wed, Jan 31, 2024 at 12:23:51PM +0530, Anshuman Khandual wrote: > > > On 1/30/24 17:04, Alexandru Elisei wrote: > > Hi, > > > > On Tue, Jan 30, 2024 at 03:25:20PM +0530, Anshuman Khandual wrote: > >> > >> On 1/25/24 22:12, Alexandru

Re: [PATCH RFC v3 06/35] mm: cma: Make CMA_ALLOC_SUCCESS/FAIL count the number of pages

2024-01-30 Thread Alexandru Elisei
Hi, On Tue, Jan 30, 2024 at 10:22:11AM +0530, Anshuman Khandual wrote: > > > On 1/29/24 17:21, Alexandru Elisei wrote: > > Hi, > > > > On Mon, Jan 29, 2024 at 02:54:20PM +0530, Anshuman Khandual wrote: > >> > >> > >> On 1/25/24 22:1

Re: [PATCH RFC v3 04/35] mm: page_alloc: Partially revert "mm: page_alloc: remove stale CMA guard code"

2024-01-30 Thread Alexandru Elisei
Hi, On Tue, Jan 30, 2024 at 10:04:02AM +0530, Anshuman Khandual wrote: > > > On 1/29/24 17:16, Alexandru Elisei wrote: > > Hi, > > > > On Mon, Jan 29, 2024 at 02:31:23PM +0530, Anshuman Khandual wrote: > >> > >> > >> On 1/25/24 22:12, Ale

Re: [PATCH RFC v3 01/35] mm: page_alloc: Add gfp_flags parameter to arch_alloc_page()

2024-01-30 Thread Alexandru Elisei
Hi, On Tue, Jan 30, 2024 at 09:56:10AM +0530, Anshuman Khandual wrote: > > > On 1/29/24 17:11, Alexandru Elisei wrote: > > Hi, > > > > On Mon, Jan 29, 2024 at 11:18:59AM +0530, Anshuman Khandual wrote: > >> On 1/25/24 22:12, Alexandru Elise

Re: [PATCH RFC v3 23/35] arm64: mte: Try to reserve tag storage in arch_alloc_page()

2024-01-30 Thread Alexandru Elisei
Hi Peter, On Mon, Jan 29, 2024 at 04:04:18PM -0800, Peter Collingbourne wrote: > On Thu, Jan 25, 2024 at 8:45 AM Alexandru Elisei > wrote: > > > > Reserve tag storage for a page that is being allocated as tagged. This > > is a best effort approach, and failin

Re: [PATCH RFC v3 08/35] mm: cma: Introduce cma_alloc_range()

2024-01-30 Thread Alexandru Elisei
Hi, On Tue, Jan 30, 2024 at 10:50:00AM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > Today, cma_alloc() is used to allocate a contiguous memory region. The > > function allows the caller to specify the number of pages to allocate, but

Re: [PATCH RFC v3 11/35] mm: Allow an arch to hook into folio allocation when VMA is known

2024-01-30 Thread Alexandru Elisei
Hi, On Tue, Jan 30, 2024 at 03:25:20PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > arm64 uses VM_HIGH_ARCH_0 and VM_HIGH_ARCH_1 for enabling MTE for a VMA. > > When VM_HIGH_ARCH_0, which arm64 renames to VM_MTE, is set for a VMA,

Re: [PATCH RFC v3 10/35] mm: cma: Fast track allocating memory when the pages are free

2024-01-30 Thread Alexandru Elisei
Hi, On Tue, Jan 30, 2024 at 02:48:53PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > If the pages to be allocated are free, take them directly off the buddy > > allocator, instead of going through alloc_contig_range() and avoi

Re: [PATCH RFC v3 09/35] mm: cma: Introduce cma_remove_mem()

2024-01-30 Thread Alexandru Elisei
of error. Does that make more sense now? Ok Tue, Jan 30, 2024 at 11:20:56AM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > Memory is added to CMA with cma_declare_contiguous_nid() and > > cma_init_reserved_mem(). This memory is then put on

Re: [PATCH RFC v3 11/35] mm: Allow an arch to hook into folio allocation when VMA is known

2024-01-29 Thread Alexandru Elisei
Hi Peter, On Fri, Jan 26, 2024 at 12:00:36PM -0800, Peter Collingbourne wrote: > On Thu, Jan 25, 2024 at 8:43 AM Alexandru Elisei > wrote: > > > > arm64 uses VM_HIGH_ARCH_0 and VM_HIGH_ARCH_1 for enabling MTE for a VMA. > > When VM_HIGH_ARCH_0, which arm64 renames to

Re: [PATCH RFC v3 07/35] mm: cma: Add CMA_RELEASE_{SUCCESS,FAIL} events

2024-01-29 Thread Alexandru Elisei
Hi, On Mon, Jan 29, 2024 at 03:01:24PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > Similar to the two events that relate to CMA allocations, add the > > CMA_RELEASE_SUCCESS and CMA_RELEASE_FAIL events that count when CMA pages &g

Re: [PATCH RFC v3 06/35] mm: cma: Make CMA_ALLOC_SUCCESS/FAIL count the number of pages

2024-01-29 Thread Alexandru Elisei
Hi, On Mon, Jan 29, 2024 at 02:54:20PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > The CMA_ALLOC_SUCCESS, respectively CMA_ALLOC_FAIL, are increased by one > > after each cma_alloc() function call. This is done even though cma_all

Re: [PATCH RFC v3 05/35] mm: cma: Don't append newline when generating CMA area name

2024-01-29 Thread Alexandru Elisei
Hi, On Mon, Jan 29, 2024 at 02:43:08PM +0530, Anshuman Khandual wrote: > > On 1/25/24 22:12, Alexandru Elisei wrote: > > cma->name is displayed in several CMA messages. When the name is generated > > by the CMA code, don't append a newline to avoid breaking the text

Re: [PATCH RFC v3 04/35] mm: page_alloc: Partially revert "mm: page_alloc: remove stale CMA guard code"

2024-01-29 Thread Alexandru Elisei
Hi, On Mon, Jan 29, 2024 at 02:31:23PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > The patch f945116e4e19 ("mm: page_alloc: remove stale CMA guard code") > > removed the CMA filter when allocating from the MIGRATE_M

Re: [PATCH RFC v3 03/35] mm: page_alloc: Add an arch hook to filter MIGRATE_CMA allocations

2024-01-29 Thread Alexandru Elisei
Hi, On Mon, Jan 29, 2024 at 02:14:16PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > As an architecture might have specific requirements around the allocation > > of CMA pages, add an arch hook that can disable allocations

Re: [PATCH RFC v3 02/35] mm: page_alloc: Add an arch hook early in free_pages_prepare()

2024-01-29 Thread Alexandru Elisei
Hi, On Mon, Jan 29, 2024 at 01:49:44PM +0530, Anshuman Khandual wrote: > > > On 1/25/24 22:12, Alexandru Elisei wrote: > > The arm64 MTE code uses the PG_arch_2 page flag, which it renames to > > PG_mte_tagged, to track if a page has been mapped with tagging enabled. >

Re: [PATCH RFC v3 01/35] mm: page_alloc: Add gfp_flags parameter to arch_alloc_page()

2024-01-29 Thread Alexandru Elisei
Hi, On Mon, Jan 29, 2024 at 11:18:59AM +0530, Anshuman Khandual wrote: > > On 1/25/24 22:12, Alexandru Elisei wrote: > > Extend the usefulness of arch_alloc_page() by adding the gfp_flags > > parameter. > > Although the change here is harmless in itself, it will defini

Re: [PATCH RFC v3 19/35] arm64: mte: Discover tag storage memory

2024-01-26 Thread Alexandru Elisei
Hi Krzysztof, On Fri, Jan 26, 2024 at 09:50:58AM +0100, Krzysztof Kozlowski wrote: > On 25/01/2024 17:42, Alexandru Elisei wrote: > > Allow the kernel to get the base address, size, block size and associated > > memory node for tag storage from the device tree blob. > > &g

[PATCH RFC v3 35/35] HACK! arm64: dts: Add fake tag storage to fvp-base-revc.dts

2024-01-25 Thread Alexandru Elisei
Faking a tag storage region for FVP is useful for testing. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch, not intended to be merged. arch/arm64/boot/dts/arm/fvp-base-revc.dts | 42 +-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git

[PATCH RFC v3 34/35] arm64: mte: Enable dynamic tag storage management

2024-01-25 Thread Alexandru Elisei
Everything is in place, enable tag storage management. Signed-off-by: Alexandru Elisei --- arch/arm64/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 088e30fc6d12..95c153705a2c 100644 --- a/arch/arm64/Kconfig +++ b/arch

[PATCH RFC v3 33/35] KVM: arm64: mte: Introduce VM_MTE_KVM VMA flag

2024-01-25 Thread Alexandru Elisei
will benefit from this change because the guest image is copied after the memslot is created. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. arch/arm64/kvm/mmu.c | 77 ++- arch/arm64/mm/fault.c | 2 +- include/linux/mm.h| 2

[PATCH RFC v3 32/35] KVM: arm64: mte: Reserve tag storage for virtual machines with MTE

2024-01-25 Thread Alexandru Elisei
without tag storage in an MTE VMA are handled. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. arch/arm64/include/asm/mte_tag_storage.h | 10 ++ arch/arm64/include/asm/pgtable.h | 7 +++- arch/arm64/kvm/mmu.c | 43

[PATCH RFC v3 31/35] khugepaged: arm64: Don't collapse MTE enabled VMAs

2024-01-25 Thread Alexandru Elisei
_page_copy() -> .. -> copy_user_highpage() with the RCU lock held, which means that copy_user_highpage() can only allocate memory using GFP_ATOMIC or equivalent. Get around this by refusing to collapse pages into a transparent huge page if the VMA is MTE-enabled. Signed-off-by: Alexandru Elisei --- Changes sinc

[PATCH RFC v3 30/35] arm64: mte: ptrace: Handle pages with missing tag storage

2024-01-25 Thread Alexandru Elisei
ptrace accesses like a fault. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch, issue reported by Peter Collingbourne. arch/arm64/kernel/mte.c | 26 -- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/mte.c b/arch/arm64

[PATCH RFC v3 29/35] arm64: mte: copypage: Handle tag restoring when missing tag storage

2024-01-25 Thread Alexandru Elisei
the replacement huge page is a tag storage page. The tag storage huge page will be migrated after a fault on access, but the tags from the original pages must be copied over to the huge page that will be replacing the tag storage huge page. Signed-off-by: Alexandru Elisei --- arch/arm64/mm/copypage.c | 56

[PATCH RFC v3 28/35] arm64: mte: swap: Handle tag restoring when missing tag storage

2024-01-25 Thread Alexandru Elisei
around this issue by saving the tags in a new xarray, this time indexed by the page pfn, and then restoring them when tag storage is reserved for the page. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * Restore saved tags **before** setting the PG_tag_storage_reserved bit

[PATCH RFC v3 27/35] arm64: mte: Handle tag storage pages mapped in an MTE VMA

2024-01-25 Thread Alexandru Elisei
Tag stoarge pages cannot be tagged. When such a page is mapped in a MTE-enabled VMA, migrate it out directly and don't try to reserve tag storage for it. Signed-off-by: Alexandru Elisei --- arch/arm64/include/asm/mte_tag_storage.h | 1 + arch/arm64/kernel/mte_tag_storage.c | 15

[PATCH RFC v3 26/35] arm64: mte: Use fault-on-access to reserve missing tag storage

2024-01-25 Thread Alexandru Elisei
cannot be reserved, then the page is migrated out of the VMA. Tag storage pages (which cannot be tagged) mapped in an MTE enabled MTE will be handled in a subsequent patch. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch, loosely based on the arm64 code from the rfc v2

[PATCH RFC v3 25/35] arm64: mte: Reserve tag block for the zero page

2024-01-25 Thread Alexandru Elisei
is not yet enabled. Reserve tag storage for the page immediately after tag storage management becomes enabled. Note that zeroing tags before tag storage management is enabled is safe to do because the tag storage pages are reserved at that point. Signed-off-by: Alexandru Elisei --- Changes since rfc v2

[PATCH RFC v3 24/35] arm64: mte: Perform CMOs for tag blocks

2024-01-25 Thread Alexandru Elisei
the tag storage block is being reserved, to ensure that no dirty data cache lines are present, which would trigger a writeback that could corrupt the tags stored in the block. Signed-off-by: Alexandru Elisei --- arch/arm64/include/asm/assembler.h | 10 ++ arch/arm64/include

[PATCH RFC v3 23/35] arm64: mte: Try to reserve tag storage in arch_alloc_page()

2024-01-25 Thread Alexandru Elisei
allocations. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * Based on rfc v2 patch #16 ("arm64: mte: Manage tag storage on page allocation"). * Fixed calculation of the number of associated tag storage blocks (Hyesoo Yu). * Tag storage is reserved in arch_alloc_page

[PATCH RFC v3 22/35] arm64: mte: Enable tag storage if CMA areas have been activated

2024-01-25 Thread Alexandru Elisei
for some of the memory, but not for all memory, and that would make the code unreasonably complicated. Choose to disable tag storage management altogether if a CMA area fails to be activated. Signed-off-by: Alexandru Elisei --- Changes since v2: * New patch. arch/arm64/include/asm/mte_tag_storage.h

[PATCH RFC v3 21/35] arm64: mte: Disable dynamic tag storage management if HW KASAN is enabled

2024-01-25 Thread Alexandru Elisei
use tag storage pages if HW KASAN is enabled. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * Expanded commit message (David Hildenbrand) arch/arm64/kernel/mte_tag_storage.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/kernel/mte_tag_storage.c b/arch

[PATCH RFC v3 20/35] arm64: mte: Add tag storage memory to CMA

2024-01-25 Thread Alexandru Elisei
explicitely by using their PFN (with alloc_cma_range()) when they are needed to store tags. Signed-off-by: Alexandru Elisei --- Changes since v2: * Reworked from rfc v2 patch #12 ("arm64: mte: Add tag storage pages to the MIGRATE_CMA migratetype"). * Tag storage memory is now added to the

[PATCH RFC v3 19/35] arm64: mte: Discover tag storage memory

2024-01-25 Thread Alexandru Elisei
of it for data (non-tagged) allocations. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * Reworked from rfc v2 patch #11 ("arm64: mte: Reserve tag storage memory"). * Added device tree schema (Rob Herring) * Tag storage memory is now described in the "reserved-memory&quo

[PATCH RFC v3 18/35] arm64: mte: Rename __GFP_ZEROTAGS to __GFP_TAGGED

2024-01-25 Thread Alexandru Elisei
is also zeroed (either __GFP_ZERO is set or init_on_alloc is 1). Rename it to __GFP_TAGGED, in preparation for it to be used by the page allocator to recognize when an allocation is tagged (has metadata). Signed-off-by: Alexandru Elisei --- arch/arm64/mm/fault.c | 2 +- include/linux

[PATCH RFC v3 17/35] arm64: mte: Rework naming for tag manipulation functions

2024-01-25 Thread Alexandru Elisei
for a page. Oportunistically rename MTE_TAG_SIZE to MTE_TAG_SIZE_BITS to make it clear it is measured in bits, not bytes, like the rest of the size variable from the same header file. Signed-off-by: Alexandru Elisei --- arch/arm64/include/asm/mte-def.h | 16 +- arch/arm64/include/asm/mte.h

[PATCH RFC v3 16/35] KVM: arm64: Don't deny VM_PFNMAP VMAs when kvm_has_mte()

2024-01-25 Thread Alexandru Elisei
the memslot has been created, the virtual machine will run without errors. Change kvm_arch_prepare_memory_region() to allow VM_PFNMAP VMAs when the VM has the MTE capability enabled. Signed-off-by: Alexandru Elisei --- Changes from rfc v2: * New patch. It's a fix, and can be taken independently

[PATCH RFC v3 15/35] of: fdt: Add of_flat_read_u32()

2024-01-25 Thread Alexandru Elisei
Add the function of_flat_read_u32() to return the value of a property as an u32. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch, suggested by Rob Herring. drivers/of/fdt.c | 21 + include/linux/of_fdt.h | 2 ++ 2 files changed, 23 insertions

[PATCH RFC v3 14/35] of: fdt: Return the region size in of_flat_dt_translate_address()

2024-01-25 Thread Alexandru Elisei
Alongside the base address, arm64 will also need to know the size of a tag storage region. Teach of_flat_dt_translate_address() to parse and return the size. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch, suggested by Rob Herring. arch/sh/kernel/cpu/sh2/probe.c | 2

[PATCH RFC v3 13/35] mm: memory: Introduce fault-on-access mechanism for pages

2024-01-25 Thread Alexandru Elisei
(PROT_MTE) call on a VMA with existing pages). Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. Split from patch #19 ("mm: mprotect: Introduce PAGE_FAULT_ON_ACCESS for mprotect(PROT_MTE)") (David Hildenbrand). include/linux/huge_mm.h | 4 ++-- include/linux/pgta

[PATCH RFC v3 12/35] mm: Call arch_swap_prepare_to_restore() before arch_swap_restore()

2024-01-25 Thread Alexandru Elisei
. This will be used by arm64 to allocate a buffer in memory where to temporarily save tags if tag storage is not available for the page being swapped in. Signed-off-by: Alexandru Elisei --- include/linux/pgtable.h | 7 +++ mm/memory.c | 4 mm/shmem.c | 9 + mm

[PATCH RFC v3 11/35] mm: Allow an arch to hook into folio allocation when VMA is known

2024-01-25 Thread Alexandru Elisei
do so. Signed-off-by: Alexandru Elisei --- arch/arm64/include/asm/page.h| 5 ++--- arch/arm64/include/asm/pgtable.h | 3 +++ arch/arm64/mm/fault.c| 19 ++- include/linux/pgtable.h | 7 +++ mm/mempolicy.c | 1 + mm/s

[PATCH RFC v3 10/35] mm: cma: Fast track allocating memory when the pages are free

2024-01-25 Thread Alexandru Elisei
long. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. Reworked from the rfc v2 patch #26 ("arm64: mte: Fast track reserving tag storage when the block is free") (David Hildenbrand). include/linux/page-flags.h | 15 -- mm/Kconfig | 5

[PATCH RFC v3 09/35] mm: cma: Introduce cma_remove_mem()

2024-01-25 Thread Alexandru Elisei
allocator. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. include/linux/cma.h | 1 + mm/cma.c| 30 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/linux/cma.h b/include/linux/cma.h index e32559da6942

[PATCH RFC v3 08/35] mm: cma: Introduce cma_alloc_range()

2024-01-25 Thread Alexandru Elisei
storage associated with a tagged page. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. include/linux/cma.h| 2 + include/trace/events/cma.h | 59 ++ mm/cma.c | 86 ++ 3 files changed

[PATCH RFC v3 07/35] mm: cma: Add CMA_RELEASE_{SUCCESS,FAIL} events

2024-01-25 Thread Alexandru Elisei
Similar to the two events that relate to CMA allocations, add the CMA_RELEASE_SUCCESS and CMA_RELEASE_FAIL events that count when CMA pages are freed. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. include/linux/vm_event_item.h | 2 ++ mm/cma.c

[PATCH RFC v3 06/35] mm: cma: Make CMA_ALLOC_SUCCESS/FAIL count the number of pages

2024-01-25 Thread Alexandru Elisei
. For users that wish to track the number of cma_alloc() calls, there are tracepoints for that already implemented. Signed-off-by: Alexandru Elisei --- mm/cma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index f49c95f8ee37..dbf7fe8cb1bd 100644

[PATCH RFC v3 05/35] mm: cma: Don't append newline when generating CMA area name

2024-01-25 Thread Alexandru Elisei
cma->name is displayed in several CMA messages. When the name is generated by the CMA code, don't append a newline to avoid breaking the text across two lines. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. This is a fix, and can be merged independently of the ot

[PATCH RFC v3 04/35] mm: page_alloc: Partially revert "mm: page_alloc: remove stale CMA guard code"

2024-01-25 Thread Alexandru Elisei
, so bring back the filter. This is a partially revert because the stale comment remains removed. Signed-off-by: Alexandru Elisei --- mm/page_alloc.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a96d47a6393e..0f

[PATCH RFC v3 03/35] mm: page_alloc: Add an arch hook to filter MIGRATE_CMA allocations

2024-01-25 Thread Alexandru Elisei
pages cannot be tagged. The filter will be used to deny using MIGRATE_CMA for __GFP_TAGGED allocations. Signed-off-by: Alexandru Elisei --- include/linux/pgtable.h | 7 +++ mm/page_alloc.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/pgtable.h b

[PATCH RFC v3 02/35] mm: page_alloc: Add an arch hook early in free_pages_prepare()

2024-01-25 Thread Alexandru Elisei
se, add an arch_free_pages_prepare() hook that is called before that page flags are cleared. The function arch_free_page() has also been considered for this purpose, but it is called after the flags are cleared. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * Expanded commit message

[PATCH RFC v3 01/35] mm: page_alloc: Add gfp_flags parameter to arch_alloc_page()

2024-01-25 Thread Alexandru Elisei
Extend the usefulness of arch_alloc_page() by adding the gfp_flags parameter. Signed-off-by: Alexandru Elisei --- Changes since rfc v2: * New patch. arch/s390/include/asm/page.h | 2 +- arch/s390/mm/page-states.c | 2 +- include/linux/gfp.h | 2 +- mm/page_alloc.c | 2

[PATCH RFC v3 00/35] Add support for arm64 MTE dynamic tag storage reuse

2024-01-25 Thread Alexandru Elisei
ue - kasan_hw_tags_enabled() returns false - correct DTB node. For an example that works with FVP, have a look at patch #35 ("HACK! Add fake tag storage to fvp-base-revc.dts") Check dmesg for the message "MTE tag storage region management enabled". Alexandru Elisei (35): mm: pa

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-18 Thread Alexandru Elisei
Hi, On Thu, Dec 14, 2023 at 12:55:14PM -0600, Rob Herring wrote: > On Thu, Dec 14, 2023 at 9:45 AM Alexandru Elisei > wrote: > > > > Hi, > > > > On Wed, Dec 13, 2023 at 02:30:42PM -0600, Rob Herring wrote: > > > On Wed, Dec 13, 2023 at

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-14 Thread Alexandru Elisei
Hi, On Wed, Dec 13, 2023 at 02:30:42PM -0600, Rob Herring wrote: > On Wed, Dec 13, 2023 at 11:44 AM Alexandru Elisei > wrote: > > > > On Wed, Dec 13, 2023 at 11:22:17AM -0600, Rob Herring wrote: > > > On Wed, Dec 13, 2023 at 8:51 AM Alexandru Elisei >

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-13 Thread Alexandru Elisei
On Wed, Dec 13, 2023 at 11:22:17AM -0600, Rob Herring wrote: > On Wed, Dec 13, 2023 at 8:51 AM Alexandru Elisei > wrote: > > > > Hi, > > > > On Wed, Dec 13, 2023 at 08:06:44AM -0600, Rob Herring wrote: > > > On Wed, Dec 13, 2023 at 7:05 AM Alexandru Elis

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-13 Thread Alexandru Elisei
Hi, On Wed, Dec 13, 2023 at 08:06:44AM -0600, Rob Herring wrote: > On Wed, Dec 13, 2023 at 7:05 AM Alexandru Elisei > wrote: > > > > Hi Rob, > > > > On Tue, Dec 12, 2023 at 12:44:06PM -0600, Rob Herring wrote: > > > On Tue, Dec 12, 2023 at

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-13 Thread Alexandru Elisei
Hi Rob, On Tue, Dec 12, 2023 at 12:44:06PM -0600, Rob Herring wrote: > On Tue, Dec 12, 2023 at 10:38 AM Alexandru Elisei > wrote: > > > > Hi Rob, > > > > Thank you so much for the feedback, I'm not very familiar with device tree, > > and any comments are very

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-12 Thread Alexandru Elisei
Hi Rob, Thank you so much for the feedback, I'm not very familiar with device tree, and any comments are very useful. On Mon, Dec 11, 2023 at 11:29:40AM -0600, Rob Herring wrote: > On Sun, Nov 19, 2023 at 10:59 AM Alexandru Elisei > wrote: > > > > Allow the kernel to get the

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-11 Thread Alexandru Elisei
Hi, On Fri, Dec 08, 2023 at 02:03:44PM +0900, Hyesoo Yu wrote: > Hi, > > I'm sorry for the late response, I was on vacation. > > On Sun, Dec 03, 2023 at 12:14:30PM +0000, Alexandru Elisei wrote: > > Hi, > > > > On Wed, Nov 29, 2023 at 05:44:24PM +0

Re: [PATCH RFC v2 15/27] arm64: mte: Check that tag storage blocks are in the same zone

2023-12-11 Thread Alexandru Elisei
Hi, On Fri, Dec 08, 2023 at 02:27:39PM +0900, Hyesoo Yu wrote: > Hi~ > > On Thu, Nov 30, 2023 at 12:00:11PM +, Alexandru Elisei wrote: > > Hi, > > > > On Wed, Nov 29, 2023 at 05:57:44PM +0900, Hyesoo Yu wrote: > > > On Sun, Nov 19, 2023 at 04:5

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-12-03 Thread Alexandru Elisei
Hi, On Wed, Nov 29, 2023 at 05:44:24PM +0900, Hyesoo Yu wrote: > Hello. > > On Sun, Nov 19, 2023 at 04:57:05PM +, Alexandru Elisei wrote: > > Allow the kernel to get the size and location of the MTE tag storage > > regions from the DTB. This memory is marke

Re: [PATCH RFC v2 21/27] mm: arm64: Handle tag storage pages mapped before mprotect(PROT_MTE)

2023-11-30 Thread Alexandru Elisei
Hi Peter, On Mon, Nov 27, 2023 at 09:39:17PM -0800, Peter Collingbourne wrote: > Hi Alexandru, > > On Sun, Nov 19, 2023 at 8:59 AM Alexandru Elisei > wrote: > > > > Signed-off-by: Alexandru Elisei > > --- > > arch/arm64/include/asm/mte_tag_sto

Re: [PATCH RFC v2 19/27] mm: mprotect: Introduce PAGE_FAULT_ON_ACCESS for mprotect(PROT_MTE)

2023-11-30 Thread Alexandru Elisei
Hi, On Thu, Nov 30, 2023 at 01:49:34PM +0100, David Hildenbrand wrote: > > > > + > > > > +out_retry: > > > > + put_page(page); > > > > + if (vmf->flags & FAULT_FLAG_VMA_LOCK) > > > > + vma_end_read(vma); > > > > + if (fault_flag_allow_retry_first(vmf->flags)) { > >

Re: [PATCH RFC v2 19/27] mm: mprotect: Introduce PAGE_FAULT_ON_ACCESS for mprotect(PROT_MTE)

2023-11-30 Thread Alexandru Elisei
Hi, On Wed, Nov 29, 2023 at 06:27:25PM +0900, Hyesoo Yu wrote: > On Sun, Nov 19, 2023 at 04:57:13PM +0000, Alexandru Elisei wrote: > > To enable tagging on a memory range, userspace can use mprotect() with the > > PROT_MTE access flag. Pages already mapped in the VMA don't have the

Re: [PATCH RFC v2 11/27] arm64: mte: Reserve tag storage memory

2023-11-30 Thread Alexandru Elisei
Hi, On Wed, Nov 29, 2023 at 05:44:24PM +0900, Hyesoo Yu wrote: > Hello. > > On Sun, Nov 19, 2023 at 04:57:05PM +, Alexandru Elisei wrote: > > Allow the kernel to get the size and location of the MTE tag storage > > regions from the DTB. This memory is marke

Re: [PATCH RFC v2 18/27] arm64: mte: Reserve tag block for the zero page

2023-11-29 Thread Alexandru Elisei
Hi, On Wed, Nov 29, 2023 at 02:13:50PM +0100, David Hildenbrand wrote: > On 29.11.23 12:30, Alexandru Elisei wrote: > > On Tue, Nov 28, 2023 at 06:06:54PM +0100, David Hildenbrand wrote: > > > On 19.11.23 17:57, Alexandru Elisei wrote: > > > > On arm64, the zero p

Re: [PATCH RFC v2 16/27] arm64: mte: Manage tag storage on page allocation

2023-11-29 Thread Alexandru Elisei
Hi, On Wed, Nov 29, 2023 at 06:10:40PM +0900, Hyesoo Yu wrote: > On Sun, Nov 19, 2023 at 04:57:10PM +0000, Alexandru Elisei wrote: > > [..] > > +static int order_to_num_blocks(int order) > > +{ > > + return max((1 << order) / 32, 1); > > +} > >

Re: [PATCH RFC v2 20/27] mm: hugepage: Handle huge page fault on access

2023-11-29 Thread Alexandru Elisei
Hi, On Tue, Nov 28, 2023 at 06:56:34PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > Handle PAGE_FAULT_ON_ACCESS faults for huge pages in a similar way to > > regular pages. > > > > Signed-off-by: Alexandru Elisei > > --- >

Re: [PATCH RFC v2 19/27] mm: mprotect: Introduce PAGE_FAULT_ON_ACCESS for mprotect(PROT_MTE)

2023-11-29 Thread Alexandru Elisei
Hi, On Tue, Nov 28, 2023 at 06:55:18PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > To enable tagging on a memory range, userspace can use mprotect() with the > > PROT_MTE access flag. Pages already mapped in the VMA don't have the > > a

Re: [PATCH RFC v2 18/27] arm64: mte: Reserve tag block for the zero page

2023-11-29 Thread Alexandru Elisei
On Tue, Nov 28, 2023 at 06:06:54PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > On arm64, the zero page receives special treatment by having the tagged > > flag set on MTE initialization, not when the page is mapped in a process > > a

Re: [PATCH RFC v2 13/27] arm64: mte: Make tag storage depend on ARCH_KEEP_MEMBLOCK

2023-11-29 Thread Alexandru Elisei
Hi, On Tue, Nov 28, 2023 at 06:05:20PM +0100, David Hildenbrand wrote: > On 27.11.23 16:04, Alexandru Elisei wrote: > > Hi, > > > > On Fri, Nov 24, 2023 at 08:51:38PM +0100, David Hildenbrand wrote: > > > On 19.11.23 17:57, Alexandru Elisei wrote: > > > >

Re: [PATCH RFC v2 12/27] arm64: mte: Add tag storage pages to the MIGRATE_CMA migratetype

2023-11-29 Thread Alexandru Elisei
Hi, On Tue, Nov 28, 2023 at 06:03:52PM +0100, David Hildenbrand wrote: > On 27.11.23 16:01, Alexandru Elisei wrote: > > Hi David, > > > > On Fri, Nov 24, 2023 at 08:40:55PM +0100, David Hildenbrand wrote: > > > On 19.11.23 17:57, Alexandru Elisei wrote: > &g

Re: [PATCH RFC v2 04/27] mm: migrate/mempolicy: Add hook to modify migration target gfp

2023-11-28 Thread Alexandru Elisei
Hi, On Tue, Nov 28, 2023 at 08:49:57AM +0200, Mike Rapoport wrote: > On Mon, Nov 27, 2023 at 11:52:56AM +0000, Alexandru Elisei wrote: > > Hi Mike, > > > > I really appreciate you having a look! > > > > On Sat, Nov 25, 2023 at 12:03:22PM +0200, Mike Rapoport

Re: [PATCH RFC v2 05/27] mm: page_alloc: Add an arch hook to allow prep_new_page() to fail

2023-11-28 Thread Alexandru Elisei
Hi, On Tue, Nov 28, 2023 at 05:57:31PM +0100, David Hildenbrand wrote: > On 27.11.23 13:09, Alexandru Elisei wrote: > > Hi, > > > > Thank you so much for your comments, there are genuinely useful. > > > > On Fri, Nov 24, 2023 at 08:35:47PM +0100, David Hildenbra

Re: [PATCH RFC v2 15/27] arm64: mte: Check that tag storage blocks are in the same zone

2023-11-27 Thread Alexandru Elisei
Hi, On Fri, Nov 24, 2023 at 08:56:59PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > alloc_contig_range() requires that the requested pages are in the same > > zone. Check that this is indeed the case before initializing the tag >

Re: [PATCH RFC v2 14/27] arm64: mte: Disable dynamic tag storage management if HW KASAN is enabled

2023-11-27 Thread Alexandru Elisei
Hi, On Fri, Nov 24, 2023 at 08:54:12PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > To be able to reserve the tag storage associated with a page requires that > > the tag storage page can be migrated. > > > > When HW KASAN is en

Re: [PATCH RFC v2 13/27] arm64: mte: Make tag storage depend on ARCH_KEEP_MEMBLOCK

2023-11-27 Thread Alexandru Elisei
Hi, On Fri, Nov 24, 2023 at 08:51:38PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > Tag storage memory requires that the tag storage pages used for data are > > always migratable when they need to be repurposed to store tags. > > >

Re: [PATCH RFC v2 12/27] arm64: mte: Add tag storage pages to the MIGRATE_CMA migratetype

2023-11-27 Thread Alexandru Elisei
Hi David, On Fri, Nov 24, 2023 at 08:40:55PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > Add the MTE tag storage pages to the MIGRATE_CMA migratetype, which allows > > the page allocator to manage them like regular pages. > > > > Th

Re: [PATCH RFC v2 06/27] mm: page_alloc: Allow an arch to hook early into free_pages_prepare()

2023-11-27 Thread Alexandru Elisei
Hi, On Fri, Nov 24, 2023 at 08:36:52PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > Add arch_free_pages_prepare() hook that is called before that page flags > > are cleared. This will be used by arm64 when explicit management of tag > > sto

Re: [PATCH RFC v2 05/27] mm: page_alloc: Add an arch hook to allow prep_new_page() to fail

2023-11-27 Thread Alexandru Elisei
Hi, Thank you so much for your comments, there are genuinely useful. On Fri, Nov 24, 2023 at 08:35:47PM +0100, David Hildenbrand wrote: > On 19.11.23 17:56, Alexandru Elisei wrote: > > Introduce arch_prep_new_page(), which will be used by arm64 to reserve tag > > storage for an

Re: [PATCH RFC v2 04/27] mm: migrate/mempolicy: Add hook to modify migration target gfp

2023-11-27 Thread Alexandru Elisei
Hi Mike, I really appreciate you having a look! On Sat, Nov 25, 2023 at 12:03:22PM +0200, Mike Rapoport wrote: > On Sun, Nov 19, 2023 at 04:56:58PM +0000, Alexandru Elisei wrote: > > It might be desirable for an architecture to modify the gfp flags used to > > allocate the d

Re: [PATCH RFC v2 20/27] mm: hugepage: Handle huge page fault on access

2023-11-22 Thread Alexandru Elisei
Hi Peter, On Tue, Nov 21, 2023 at 05:28:49PM -0800, Peter Collingbourne wrote: > On Sun, Nov 19, 2023 at 8:59 AM Alexandru Elisei > wrote: > > > > Handle PAGE_FAULT_ON_ACCESS faults for huge pages in a similar way to > > regular pages. > > > > Signed-off-by:

Re: [PATCH RFC 20/37] mm: compaction: Reserve metadata storage in compaction_alloc()

2023-11-21 Thread Alexandru Elisei
Hi Peter, On Mon, Nov 20, 2023 at 08:49:32PM -0800, Peter Collingbourne wrote: > Hi Alexandru, > > On Wed, Aug 23, 2023 at 6:16 AM Alexandru Elisei > wrote: > > > > If the source page being migrated has metadata associated with it, make > > sure to reserve the

[PATCH RFC v2 27/27] arm64: mte: Enable dynamic tag storage reuse

2023-11-19 Thread Alexandru Elisei
Everything is in place, enable tag storage management. Signed-off-by: Alexandru Elisei --- arch/arm64/kernel/mte_tag_storage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/mte_tag_storage.c b/arch/arm64/kernel/mte_tag_storage.c index 11961587382d..9f60e952a814

[PATCH RFC v2 26/27] arm64: mte: Fast track reserving tag storage when the block is free

2023-11-19 Thread Alexandru Elisei
by taking the storage block directly from the freelist if it's free, thus sidestepping the costly function call. Note that at the moment this is implemented only when the block size is 1 (the block is one page); larger block sizes could be added later if necessary. Signed-off-by: Alexandru Elisei

[PATCH RFC v2 24/27] arm64: mte: Handle fatal signal in reserve_tag_storage()

2023-11-19 Thread Alexandru Elisei
allocator to make progress. set_pte_at() will map it with PAGE_FAULT_ON_ACCESS and subsequent accesses from different threads will cause a fault until the signal is delivered. Signed-off-by: Alexandru Elisei --- arch/arm64/kernel/mte_tag_storage.c | 17 + arch/arm64/mm/fault.c

[PATCH RFC v2 25/27] KVM: arm64: Disable MTE if tag storage is enabled

2023-11-19 Thread Alexandru Elisei
. Signed-off-by: Alexandru Elisei --- arch/arm64/kvm/arm.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e5f75f1f1085..5b33c532c62a 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -29,6 +29,7 @@ #include

[PATCH RFC v2 23/27] arm64: mte: copypage: Handle tag restoring when missing tag storage

2023-11-19 Thread Alexandru Elisei
the replacement huge page is a tag storage page. The tag storage huge page will be migrated after a fault on access, but the tags from the original pages must be copied over to the huge page that will be replacing the tag storage huge page. Signed-off-by: Alexandru Elisei --- arch/arm64/mm/copypage.c | 59

[PATCH RFC v2 22/27] arm64: mte: swap: Handle tag restoring when missing tag storage

2023-11-19 Thread Alexandru Elisei
around this issue by saving the tags in a new xarray, this time indexed by the page pfn, and then restoring them when tag storage is reserved for the page. Signed-off-by: Alexandru Elisei --- arch/arm64/include/asm/mte_tag_storage.h | 9 ++ arch/arm64/include/asm/pgtable.h | 11

  1   2   3   >