Re: [PATCH v1] lib: objpool: fix head overrun on RK3588 SBC

2023-11-19 Thread Google
On Tue, 14 Nov 2023 19:51:48 +0800 "wuqiang.matt" wrote: > objpool overrun stress with test_objpool on OrangePi5+ SBC triggered the > following kernel warnings: > > WARNING: CPU: 6 PID: 3115 at lib/objpool.c:168 objpool_push+0xc0/0x100 > > This message is from objpool.c:168: > >

Re: [PATCH] ftrace: Replaces simple_strtoul in ftrace

2023-11-19 Thread Google
On Mon, 20 Nov 2023 05:46:13 +0530 Yuran Pereira wrote: > The function simple_strtoul performs no error checking in scenarios > where the input value overflows the intended output variable. > This results in this function successfully returning, even when the > output does not match the input

Re: [PATCH v6 09/12] x86/sgx: Restructure top-level EPC reclaim function

2023-11-19 Thread Huang, Kai
On Mon, 2023-10-30 at 11:20 -0700, Haitao Huang wrote: > From: Sean Christopherson > > To prepare for per-cgroup reclamation, separate the top-level reclaim > function, sgx_reclaim_epc_pages(), into two separate functions: > > - sgx_isolate_epc_pages() scans and isolates reclaimable pages from

Re: [PATCH v6 04/12] x86/sgx: Implement basic EPC misc cgroup functionality

2023-11-19 Thread Huang, Kai
> > > > > > > That's true. I was thinking no need to have them done in separate calls. > > The caller has to check the return value for epc_cg instance first, then > > check result of try_charge. But there is really only one caller, > > sgx_alloc_epc_page() below, so I don't have strong

[PATCH] ftrace: Replaces simple_strtoul in ftrace

2023-11-19 Thread Yuran Pereira
The function simple_strtoul performs no error checking in scenarios where the input value overflows the intended output variable. This results in this function successfully returning, even when the output does not match the input string (aka the function returns successfully even when the result

[RFC PATCH v2 2/3] virtio/vsock: send credit update during setting SO_RCVLOWAT

2023-11-19 Thread Arseniy Krasnov
Send credit update message when SO_RCVLOWAT is updated and it is bigger than number of bytes in rx queue. It is needed, because 'poll()' will wait until number of bytes in rx queue will be not smaller than SO_RCVLOWAT, so kick sender to send more data. Otherwise mutual hungup for tx/rx is

[RFC PATCH v2 1/3] vsock: update SO_RCVLOWAT setting callback

2023-11-19 Thread Arseniy Krasnov
Do not return if transport callback for SO_RCVLOWAT is set (only in error case). In this case we don't need to set 'sk_rcvlowat' field in each transport - only in 'vsock_set_rcvlowat()'. Signed-off-by: Arseniy Krasnov --- net/vmw_vsock/af_vsock.c | 9 +++-- 1 file changed, 7 insertions(+),

[RFC PATCH v2 0/3] send credit update during setting SO_RCVLOWAT

2023-11-19 Thread Arseniy Krasnov
Hello, DESCRIPTION This patchset fixes old problem with hungup of both rx/tx sides and adds test for it. This happens due to non-default SO_RCVLOWAT value and deferred credit update in virtio/vsock. Link to previous old patchset:

[RFC PATCH v2 3/3] vsock/test: SO_RCVLOWAT + deferred credit update test

2023-11-19 Thread Arseniy Krasnov
Test which checks, that updating SO_RCVLOWAT value also sends credit update message. Otherwise mutual hungup may happen when receiver didn't send credit update and then calls 'poll()' with non default SO_RCVLOWAT value (e.g. waiting enough bytes to read), while sender waits for free space at

[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
A double digit performance decrease for Chrome startup time has been reported with the dynamic tag storage management enabled. A large part of the regression is due to lru_cache_disable(), called from __alloc_contig_migrate_range(), which IPIs all CPUs in the system. Improve the performance by

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

2023-11-19 Thread Alexandru Elisei
As long as a fatal signal is pending, alloc_contig_range() will fail with -EINTR. This makes it impossible for tag storage allocation to succeed, and the page allocator will print an OOM splat. The process is going to be killed, so return 0 (success) from reserve_tag_storage() to allow the page

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

2023-11-19 Thread Alexandru Elisei
KVM allows MTE enabled VMs to be created when the backing VMA does not have MTE enabled. Without changes to how KVM allocates memory for a VM, it is impossible at the moment to discern when the corresponding tag storage needs to be reserved. For now, disable MTE in KVM if tag storage is enabled.

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

2023-11-19 Thread Alexandru Elisei
There are several situations where copy_highpage() can end up copying tags to a page which doesn't have its tag storage reserved. One situation involves migration racing with mprotect(PROT_MTE): VMA is initially untagged, migration starts and destination page is allocated as untagged,

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

2023-11-19 Thread Alexandru Elisei
Linux restores tags when a page is swapped in and there are tags associated with the swap entry which the new page will replace. The saved tags are restored even if the page will not be mapped as tagged, to protect against cases where the page is shared between different VMAs, and is tagged in

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

2023-11-19 Thread Alexandru Elisei
Signed-off-by: Alexandru Elisei --- arch/arm64/include/asm/mte_tag_storage.h | 1 + arch/arm64/kernel/mte_tag_storage.c | 15 +++ arch/arm64/mm/fault.c| 55 include/linux/migrate.h | 8 +++- include/linux/migrate_mode.h

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

2023-11-19 Thread Alexandru Elisei
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 associated tag storage block reserved, so mark the PTEs as PAGE_FAULT_ON_ACCESS to trigger a fault next time they are accessed, and reserve the tag

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

2023-11-19 Thread Alexandru Elisei
Handle PAGE_FAULT_ON_ACCESS faults for huge pages in a similar way to regular pages. Signed-off-by: Alexandru Elisei --- arch/arm64/include/asm/mte_tag_storage.h | 1 + arch/arm64/include/asm/pgtable.h | 7 ++ arch/arm64/mm/fault.c| 81

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

2023-11-19 Thread Alexandru Elisei
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 address space. Reserve the corresponding tag block when tag storage management is being activated. Signed-off-by: Alexandru Elisei ---

[PATCH RFC v2 17/27] arm64: mte: Perform CMOs for tag blocks on tagged page allocation/free

2023-11-19 Thread Alexandru Elisei
Make sure the contents of the tag storage block is not corrupted by performing: 1. A tag dcache inval when the associated tagged pages are freed, to avoid dirty tag cache lines being evicted and corrupting the tag storage block when it's being used to store data. 2. A data cache inval when

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

2023-11-19 Thread Alexandru Elisei
Reserve tag storage for a tagged page by migrating the contents of the tag storage (if in use for data) and removing the tag storage pages from the page allocator by calling alloc_contig_range(). When all the associated tagged pages have been freed, return the tag storage pages back to the page

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

2023-11-19 Thread Alexandru Elisei
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 enabled, the kernel allocates pages, which are now tagged, in non-preemptible contexts, which can make reserving the associate tag storage impossible. Keep the tag

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

2023-11-19 Thread Alexandru Elisei
alloc_contig_range() requires that the requested pages are in the same zone. Check that this is indeed the case before initializing the tag storage blocks. Signed-off-by: Alexandru Elisei --- arch/arm64/kernel/mte_tag_storage.c | 33 + 1 file changed, 33

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

2023-11-19 Thread Alexandru Elisei
Tag storage memory requires that the tag storage pages used for data are always migratable when they need to be repurposed to store tags. If ARCH_KEEP_MEMBLOCK is enabled, kexec will scan all non-reserved memblocks to find a suitable location for copying the kernel image. The kernel image, once

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

2023-11-19 Thread Alexandru Elisei
Add the MTE tag storage pages to the MIGRATE_CMA migratetype, which allows the page allocator to manage them like regular pages. Ths migratype lends the pages some very desirable properties: * They cannot be longterm pinned, meaning they will always be migratable. * The pages can be allocated

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

2023-11-19 Thread Alexandru Elisei
Allow the kernel to get the size and location of the MTE tag storage regions from the DTB. This memory is marked as reserved for now. The DTB node for the tag storage region is defined as: tags0: tag-storage@8f800 { compatible = "arm,mte-tag-storage";

[PATCH RFC v2 10/27] mm: Call arch_swap_prepare_to_restore() before arch_swap_restore()

2023-11-19 Thread Alexandru Elisei
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). Introduce arch_swap_prepare_to_restore() that will allow an architecture to perform extra work during swap in and outside of a critical section.

[PATCH RFC v2 09/27] mm: Allow an arch to hook into folio allocation when VMA is known

2023-11-19 Thread Alexandru Elisei
An architecture might want to fixup the gfp flags based on the type of VMA where the page will be mapped. On arm64, this is currently used if the VMA is MTE enabled. When __GFP_TAGGED is set, for performance reasons, tag zeroing is performed at the same time as the data is zeroed, instead of

[PATCH RFC v2 08/27] mm: page_alloc: Partially revert "mm: page_alloc: remove stale CMA guard code"

2023-11-19 Thread Alexandru Elisei
The patch f945116e4e19 ("mm: page_alloc: remove stale CMA guard code") removed the CMA filter when allocating from the MIGRATE_MOVABLE pcp list because CMA is always allowed when __GFP_MOVABLE is set. With the introduction of the arch_alloc_cma() function, the above is not true anymore, so bring

[PATCH RFC v2 07/27] mm: page_alloc: Add an arch hook to filter MIGRATE_CMA allocations

2023-11-19 Thread Alexandru Elisei
As an architecture might have specific requirements around the allocation of CMA pages, add an arch hook that can disable allocations from MIGRATE_CMA, if the allocation was otherwise allowed. This will be used by arm64, which will put tag storage pages on the MIGRATE_CMA list, pages which have

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

2023-11-19 Thread Alexandru Elisei
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 storage pages is enabled. Signed-off-by: Alexandru Elisei --- include/linux/pgtable.h | 4 mm/page_alloc.c | 4 +++- 2 files changed, 7

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

2023-11-19 Thread Alexandru Elisei
Introduce arch_prep_new_page(), which will be used by arm64 to reserve tag storage for an allocated page. Reserving tag storage can fail, for example, if the tag storage page has a short pin on it, so allow prep_new_page() -> arch_prep_new_page() to similarly fail. arch_alloc_page(), called from

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

2023-11-19 Thread Alexandru Elisei
It might be desirable for an architecture to modify the gfp flags used to allocate the destination page for migration based on the page that it is being replaced. For example, if an architectures has metadata associated with a page (like arm64, when the memory tagging extension is implemented), it

[PATCH RFC v2 03/27] mm: cma: Make CMA_ALLOC_SUCCESS/FAIL count the number of pages

2023-11-19 Thread Alexandru Elisei
The CMA_ALLOC_SUCCESS, respectively CMA_ALLOC_FAIL, are increased by one after each cma_alloc() function call. This is done even though cma_alloc() can allocate an arbitrary number of CMA pages. When looking at /proc/vmstat, the number of successful (or failed) cma_alloc() calls doesn't tell much

[PATCH RFC v2 02/27] arm64: mte: Rename __GFP_ZEROTAGS to __GFP_TAGGED

2023-11-19 Thread Alexandru Elisei
__GFP_ZEROTAGS is used to instruct the page allocator to zero the tags at the same time as the physical frame is zeroed. The name can be slightly misleading, because it doesn't mean that the code will zero the tags unconditionally, but that the tags will be zeroed if and only if the physical frame

[PATCH RFC v2 01/27] arm64: mte: Rework naming for tag manipulation functions

2023-11-19 Thread Alexandru Elisei
The tag save/restore/copy functions could be more explicit about from where the tags are coming from and where they are being copied to. Renaming the functions to make it easier to understand what they are doing: - Rename the mte_clear_page_tags() 'addr' parameter to 'page_addr', to match the

[PATCH RFC v2 00/27] Add support for arm64 MTE dynamic tag storage reuse

2023-11-19 Thread Alexandru Elisei
The series is based on v6.7-rc1 and can be cloned with: $ git clone https://gitlab.arm.com/linux-arm/linux-ae.git \ -b arm-mte-dynamic-carveout-rfc-v2 Introduction Memory Tagging Extension (MTE) is implemented currently to have a static carve-out of the DRAM to store the

Re: EEVDF/vhost regression (bisected to 86bfbb7ce4f6 sched/fair: Add lag based placement)

2023-11-19 Thread Bagas Sanjaya
On Thu, Nov 16, 2023 at 07:58:18PM +0100, Tobias Huschle wrote: > Hi, > > when testing the EEVDF scheduler we stumbled upon a performance regression > in a uperf scenario and would like to > kindly ask for feedback on whether we are going into the right direction > with our analysis so far. > >