Re: [PATCH] checkpatch: allow tags between co-developed-by and their sign-off

2023-10-24 Thread Przemek Kitszel
On 10/23/23 16:02, Sean Christopherson wrote: +Mateusz On Mon, Oct 23, 2023, Przemek Kitszel wrote: Additional tags between Co-developed-by and corresponding Signed-off-by could include Reviewed-by tags collected by Submitter, which is also a Co-developer, but should sign-off at the very end of

Re: [PATCH] checkpatch: allow tags between co-developed-by and their sign-off

2023-10-24 Thread Przemek Kitszel
On 10/23/23 16:16, Lukas Bulwahn wrote: Hi Przemek, On Mon, Oct 23, 2023 at 12:29 PM Przemek Kitszel wrote: Allow additional tags between Co-developed-by: and Signed-off-by:. Removing the "immediately" word from the doc is a great summary of the change - there is no need for the two tags to

Re: [PATCH] Documentation: security-bugs.rst: linux-distros relaxed their rules

2023-10-24 Thread Greg Kroah-Hartman
On Sun, Oct 22, 2023 at 08:31:45PM -0600, Jonathan Corbet wrote: > Willy Tarreau writes: > > > The linux-distros list relaxed their rules to try to adapt better to > > how the Linux kernel works. Let's update the Coordination part to > > explain why and when to contact them or not to and how to a

[PATCH v2 00/39] Memory allocation profiling

2023-10-24 Thread Suren Baghdasaryan
Updates since the last version [1] - Simplified allocation tagging macros; - Runtime enable/disable sysctl switch (/proc/sys/vm/mem_profiling) instead of kernel command-line option; - CONFIG_MEM_ALLOC_PROFILING_BY_DEFAULT to select default enable state; - Changed the user-facing API from debugfs to

[PATCH v2 01/39] lib/string_helpers: Add flags param to string_get_size()

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet The new flags parameter allows controlling - Whether or not the units suffix is separated by a space, for compatibility with sort -h - Whether or not to append a B suffix - we're not always printing bytes. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdas

[PATCH v2 02/39] scripts/kallysms: Always include __start and __stop symbols

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet These symbols are used to denote section boundaries: by always including them we can unify loading sections from modules with loading built-in sections, which leads to some significant cleanup. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- scripts/

[PATCH v2 03/39] fs: Convert alloc_inode_sb() to a macro

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet We're introducing alloc tagging, which tracks memory allocations by callsite. Converting alloc_inode_sb() to a macro means allocations will be tracked by its caller, which is a bit more useful. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan Cc: Alexander

[PATCH v2 04/39] nodemask: Split out include/linux/nodemask_types.h

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet sched.h, which defines task_struct, needs nodemask_t - but sched.h is a frequently used header and ideally shouldn't be pulling in any more code that it needs to. This splits out nodemask_types.h which has the definition sched.h needs, which will avoid a circular header dep

[PATCH v2 05/39] prandom: Remove unused include

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet prandom.h doesn't use percpu.h - this fixes some circular header issues. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- include/linux/prandom.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/prandom.h b/include/linux/prandom.h inde

[PATCH v2 06/39] mm: enumerate all gfp flags

2023-10-24 Thread Suren Baghdasaryan
Introduce GFP bits enumeration to let compiler track the number of used bits (which depends on the config options) instead of hardcoding them. That simplifies __GFP_BITS_SHIFT calculation. Suggested-by: Petr Tesařík Signed-off-by: Suren Baghdasaryan --- include/linux/gfp_types.h | 90 ++

[PATCH v2 07/39] mm: introduce slabobj_ext to support slab object extensions

2023-10-24 Thread Suren Baghdasaryan
Currently slab pages can store only vectors of obj_cgroup pointers in page->memcg_data. Introduce slabobj_ext structure to allow more data to be stored for each slab object. Wrap obj_cgroup into slabobj_ext to support current functionality while allowing to extend slabobj_ext in the future. Signed

[PATCH v2 08/39] mm: introduce __GFP_NO_OBJ_EXT flag to selectively prevent slabobj_ext creation

2023-10-24 Thread Suren Baghdasaryan
Introduce __GFP_NO_OBJ_EXT flag in order to prevent recursive allocations when allocating slabobj_ext on a slab. Signed-off-by: Suren Baghdasaryan --- include/linux/gfp_types.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h

[PATCH v2 10/39] mm: prevent slabobj_ext allocations for slabobj_ext and kmem_cache objects

2023-10-24 Thread Suren Baghdasaryan
Use __GFP_NO_OBJ_EXT to prevent recursions when allocating slabobj_ext objects. Also prevent slabobj_ext allocations for kmem_cache objects. Signed-off-by: Suren Baghdasaryan --- mm/slab.h| 6 ++ mm/slab_common.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/mm/slab.h b/mm/s

[PATCH v2 09/39] mm/slab: introduce SLAB_NO_OBJ_EXT to avoid obj_ext creation

2023-10-24 Thread Suren Baghdasaryan
Slab extension objects can't be allocated before slab infrastructure is initialized. Some caches, like kmem_cache and kmem_cache_node, are created before slab infrastructure is initialized. Objects from these caches can't have extension objects. Introduce SLAB_NO_OBJ_EXT slab flag to mark these cac

[PATCH v2 11/39] slab: objext: introduce objext_flags as extension to page_memcg_data_flags

2023-10-24 Thread Suren Baghdasaryan
Introduce objext_flags to store additional objext flags unrelated to memcg. Signed-off-by: Suren Baghdasaryan --- include/linux/memcontrol.h | 29 ++--- mm/slab.h | 4 +--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/linux/me

[PATCH v2 12/39] lib: code tagging framework

2023-10-24 Thread Suren Baghdasaryan
Add basic infrastructure to support code tagging which stores tag common information consisting of the module name, function, file name and line number. Provide functions to register a new code tag type and navigate between code tags. Co-developed-by: Kent Overstreet Signed-off-by: Kent Overstree

[PATCH v2 13/39] lib: code tagging module support

2023-10-24 Thread Suren Baghdasaryan
Add support for code tagging from dynamically loaded modules. Signed-off-by: Suren Baghdasaryan Co-developed-by: Kent Overstreet Signed-off-by: Kent Overstreet --- include/linux/codetag.h | 12 + kernel/module/main.c| 4 +++ lib/codetag.c | 58 +++

[PATCH v2 14/39] lib: prevent module unloading if memory is not freed

2023-10-24 Thread Suren Baghdasaryan
Skip freeing module's data section if there are non-zero allocation tags because otherwise, once these allocations are freed, the access to their code tag would cause UAF. Signed-off-by: Suren Baghdasaryan --- include/linux/codetag.h | 6 +++--- kernel/module/main.c| 23 +++-

[PATCH v2 15/39] lib: add allocation tagging support for memory allocation profiling

2023-10-24 Thread Suren Baghdasaryan
Introduce CONFIG_MEM_ALLOC_PROFILING which provides definitions to easily instrument memory allocators. It registers an "alloc_tags" codetag type with /proc/allocinfo interface to output allocation tag information when the feature is enabled. CONFIG_MEM_ALLOC_PROFILING_DEBUG is provided for debuggi

[PATCH v2 16/39] lib: introduce support for page allocation tagging

2023-10-24 Thread Suren Baghdasaryan
Introduce helper functions to easily instrument page allocators by storing a pointer to the allocation tag associated with the code that allocated the page in a page_ext field. Signed-off-by: Suren Baghdasaryan Co-developed-by: Kent Overstreet Signed-off-by: Kent Overstreet --- include/linux/p

[PATCH v2 17/39] change alloc_pages name in dma_map_ops to avoid name conflicts

2023-10-24 Thread Suren Baghdasaryan
After redefining alloc_pages, all uses of that name are being replaced. Change the conflicting names to prevent preprocessor from replacing them when it's not intended. Signed-off-by: Suren Baghdasaryan --- arch/x86/kernel/amd_gart_64.c | 2 +- drivers/iommu/dma-iommu.c | 2 +- drivers/xen/g

[PATCH v2 18/39] change alloc_pages name in ivpu_bo_ops to avoid conflicts

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet After redefining alloc_pages, all uses of that name are being replaced. Change the conflicting names to prevent preprocessor from replacing them when it's not intended. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- drivers/accel/ivpu/ivpu_gem.c | 8

[PATCH v2 20/39] mm: create new codetag references during page splitting

2023-10-24 Thread Suren Baghdasaryan
When a high-order page is split into smaller ones, each newly split page should get its codetag. The original codetag is reused for these pages but it's recorded as 0-byte allocation because original codetag already accounts for the original high-order allocated page. Signed-off-by: Suren Baghdasa

[PATCH v2 19/39] mm: enable page allocation tagging

2023-10-24 Thread Suren Baghdasaryan
Redefine page allocators to record allocation tags upon their invocation. Instrument post_alloc_hook and free_pages_prepare to modify current allocation tag. Co-developed-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan Signed-off-by: Kent Overstreet --- include/linux/alloc_tag.h | 10 ++

[PATCH v2 21/39] mm/page_ext: enable early_page_ext when CONFIG_MEM_ALLOC_PROFILING_DEBUG=y

2023-10-24 Thread Suren Baghdasaryan
For all page allocations to be tagged, page_ext has to be initialized before the first page allocation. Early tasks allocate their stacks using page allocator before alloc_node_page_ext() initializes page_ext area, unless early_page_ext is enabled. Therefore these allocations will generate a warnin

[PATCH v2 22/39] lib: add codetag reference into slabobj_ext

2023-10-24 Thread Suren Baghdasaryan
To store code tag for every slab object, a codetag reference is embedded into slabobj_ext when CONFIG_MEM_ALLOC_PROFILING=y. Signed-off-by: Suren Baghdasaryan Co-developed-by: Kent Overstreet Signed-off-by: Kent Overstreet --- include/linux/memcontrol.h | 5 + lib/Kconfig.debug |

[PATCH v2 23/39] mm/slab: add allocation accounting into slab allocation and free paths

2023-10-24 Thread Suren Baghdasaryan
Account slab allocations using codetag reference embedded into slabobj_ext. Signed-off-by: Suren Baghdasaryan Co-developed-by: Kent Overstreet Signed-off-by: Kent Overstreet --- include/linux/slab_def.h | 2 +- include/linux/slub_def.h | 4 ++-- mm/slab.c| 4 +++- mm/slab.h

[PATCH v2 25/39] mm/slub: Mark slab_free_freelist_hook() __always_inline

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet It seems we need to be more forceful with the compiler on this one. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index f5e07d8802e2..222c16cef729 1

[PATCH v2 24/39] mm/slab: enable slab allocation tagging for kmalloc and friends

2023-10-24 Thread Suren Baghdasaryan
Redefine kmalloc, krealloc, kzalloc, kcalloc, etc. to record allocations and deallocations done by these functions. Signed-off-by: Suren Baghdasaryan Co-developed-by: Kent Overstreet Signed-off-by: Kent Overstreet --- include/linux/fortify-string.h | 5 +- include/linux/slab.h | 17

[PATCH v2 26/39] mempool: Hook up to memory allocation profiling

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet This adds hooks to mempools for correctly annotating mempool-backed allocations at the correct source line, so they show up correctly in /sys/kernel/debug/allocations. Various inline functions are converted to wrappers so that we can invoke alloc_hooks() in fewer places. S

[PATCH v2 27/39] xfs: Memory allocation profiling fixups

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet This adds an alloc_hooks() wrapper around kmem_alloc(), so that we can have allocations accounted to the proper callsite. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- fs/xfs/kmem.c | 4 ++-- fs/xfs/kmem.h | 10 -- 2 files changed, 6 inser

[PATCH v2 29/39] mm: percpu: Introduce pcpuobj_ext

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet Upcoming alloc tagging patches require a place to stash per-allocation metadata. We already do this when memcg is enabled, so this patch generalizes the obj_cgroup * vector in struct pcpu_chunk by creating a pcpu_obj_ext type, which we will be adding to in an upcoming patch

[PATCH v2 28/39] timekeeping: Fix a circular include dependency

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet This avoids a circular header dependency in an upcoming patch by only making hrtimer.h depend on percpu-defs.h Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan Cc: Thomas Gleixner --- include/linux/hrtimer.h| 2 +- include/linux/time_namespace.h

[PATCH v2 31/39] mm: percpu: enable per-cpu allocation tagging

2023-10-24 Thread Suren Baghdasaryan
Redefine __alloc_percpu, __alloc_percpu_gfp and __alloc_reserved_percpu to record allocations and deallocations done by these functions. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 15 + include/linux/percpu.h| 23 +-

[PATCH v2 30/39] mm: percpu: Add codetag reference into pcpuobj_ext

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet To store codetag for every per-cpu allocation, a codetag reference is embedded into pcpuobj_ext when CONFIG_MEM_ALLOC_PROFILING=y. Hooks to use the newly introduced codetag are added. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- mm/percpu-internal

[PATCH v2 32/39] arm64: Fix circular header dependency

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet Replace linux/percpu.h include with asm/percpu.h to avoid circular dependency. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- arch/arm64/include/asm/spectre.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include

[PATCH v2 35/39] lib: add memory allocations report in show_mem()

2023-10-24 Thread Suren Baghdasaryan
Include allocations in show_mem reports. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 2 ++ lib/alloc_tag.c | 37 + mm/show_mem.c | 15 +++ 3 files changed, 54 insertions(+

[PATCH v2 33/39] mm: vmalloc: Enable memory allocation profiling

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet This wrapps all external vmalloc allocation functions with the alloc_hooks() wrapper, and switches internal allocations to _noprof variants where appropriate, for the new memory allocation profiling feature. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan

[PATCH v2 34/39] rhashtable: Plumb through alloc tag

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet This gives better memory allocation profiling results; rhashtable allocations will be accounted to the code that initialized the rhashtable. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- include/linux/rhashtable-types.h | 11 +-- lib/rhashtable

[PATCH v2 36/39] codetag: debug: skip objext checking when it's for objext itself

2023-10-24 Thread Suren Baghdasaryan
objext objects are created with __GFP_NO_OBJ_EXT flag and therefore have no corresponding objext themselves (otherwise we would get an infinite recursion). When freeing these objects their codetag will be empty and when CONFIG_MEM_ALLOC_PROFILING_DEBUG is enabled this will lead to false warnings. I

[PATCH v2 38/39] codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations

2023-10-24 Thread Suren Baghdasaryan
If slabobj_ext vector allocation for a slab object fails and later on it succeeds for another object in the same slab, the slabobj_ext for the original object will be NULL and will be flagged in case when CONFIG_MEM_ALLOC_PROFILING_DEBUG is enabled. Mark failed slabobj_ext vector allocations using

[PATCH v2 39/39] MAINTAINERS: Add entries for code tagging and memory allocation profiling

2023-10-24 Thread Suren Baghdasaryan
From: Kent Overstreet The new code & libraries added are being maintained - mark them as such. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- MAINTAINERS | 16 1 file changed, 16 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 2894f0777537..2

[PATCH v2 37/39] codetag: debug: mark codetags for reserved pages as empty

2023-10-24 Thread Suren Baghdasaryan
To avoid debug warnings while freeing reserved pages which were not allocated with usual allocators, mark their codetags as empty before freeing. Maybe we can annotate reserved pages correctly and avoid this? Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 2 ++ include/linux

[RFC PATCH v3 00/39] ACPI/arm64: add support for virtual cpuhotplug

2023-10-24 Thread Russell King (Oracle)
Hi, I'm posting James' patch set updated with most of the review comments from his RFC v2 series back in September. Individual patches have a changelog attached at the bottom of the commit message. Those which I have finished updating have my S-o-b on them, those which still have outstanding revie

[PATCH 01/39] parisc: simplify smp_prepare_boot_cpu()

2023-10-24 Thread Russell King (Oracle)
smp_prepare_boot_cpu() reads the cpuid of the first CPU, printing a message to state which processor booted, and setting it online and present. This cpuid is retrieved from per_cpu(cpu_data, 0).cpuid, which is initialised in arch/parisc/kernel/processor.c:processor_probe() thusly: p = &pe

[PATCH 02/39] ACPI: Use the acpi_device_is_present() helper in more places

2023-10-24 Thread Oracle
From: James Morse acpi_device_is_present() checks the present or functional bits from the cached copy of _STA. A few places open-code this check. Use the helper instead to improve readability. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan Reviewed-by: Migue

[PATCH 03/39] ACPI: Rename acpi_scan_device_not_present() to be about enumeration

2023-10-24 Thread Oracle
From: James Morse acpi_scan_device_not_present() is called when a device in the hierarchy is not available for enumeration. Historically enumeration was only based on whether the device was present. To add support for only enumerating devices that are both present and enabled, this helper should

[PATCH 04/39] arm64, irqchip/gic-v3, ACPI: Move MADT GICC enabled check into a helper

2023-10-24 Thread Oracle
From: James Morse ACPI, irqchip and the architecture code all inspect the MADT enabled bit for a GICC entry in the MADT. The addition of an 'online capable' bit means all these sites need updating. Move the current checks behind a helper to make future updates easier. Signed-off-by: James Mors

[PATCH 06/39] drivers: base: Use present CPUs in GENERIC_CPU_DEVICES

2023-10-24 Thread Oracle
From: James Morse Three of the five ACPI architectures create sysfs entries using register_cpu() for present CPUs, whereas arm64, riscv and all GENERIC_CPU_DEVICES do this for possible CPUs. Registering a CPU is what causes them to show up in sysfs. It makes very little sense to register all po

[PATCH 08/39] drivers: base: Move cpu_dev_init() after node_dev_init()

2023-10-24 Thread Oracle
From: James Morse NUMA systems require the node descriptions to be ready before CPUs are registered. This is so that the node symlinks can be created in sysfs. Currently no NUMA platform uses GENERIC_CPU_DEVICES, meaning that CPUs are registered by arch code, instead of cpu_dev_init(). Move cpu

[PATCH 07/39] drivers: base: Allow parts of GENERIC_CPU_DEVICES to be overridden

2023-10-24 Thread Oracle
From: James Morse Architectures often have extra per-cpu work that needs doing before a CPU is registered, often to determine if a CPU is hotpluggable. To allow the ACPI architectures to use GENERIC_CPU_DEVICES, move the cpu_register() call into arch_register_cpu(), which is made __weak so archi

[PATCH 09/39] drivers: base: remove unnecessary call to register_cpu_under_node()

2023-10-24 Thread Russell King (Oracle)
Since "drivers: base: Move cpu_dev_init() after node_dev_init()", we can remove some redundant code. node_dev_init() will walk through the nodes calling register_one_node() on each. This will trickle down to __register_one_node() which walks all present CPUs, calling register_cpu_under_node() on e

[PATCH 11/39] arm64: setup: Switch over to GENERIC_CPU_DEVICES using arch_register_cpu()

2023-10-24 Thread Oracle
From: James Morse To allow ACPI's _STA value to hide CPUs that are present, but not available to online right now due to VMM or firmware policy, the register_cpu() call needs to be made by the ACPI machinery when ACPI is in use. This allows it to hide CPUs that are unavailable from sysfs. Switch

[PATCH 05/39] ACPI: Move ACPI_HOTPLUG_CPU to be disabled on arm64 and riscv

2023-10-24 Thread Oracle
From: James Morse Neither arm64 nor riscv support physical hotadd of CPUs that were not present at boot. For arm64 much of the platform description is in static tables which do not have update methods. arm64 does support HOTPLUG_CPU, which is backed by a firmware interface to turn CPUs on and off

[PATCH 12/39] ia64/topology: Switch over to GENERIC_CPU_DEVICES

2023-10-24 Thread Oracle
From: James Morse ia64 has its own arch specific data structure for cpus: struct ia64_cpu. This has one member, making ia64's cpu_devices the same as that provided be GENERIC_CPU_DEVICES. ia64 craetes a percpu struct ia64_cpu called cpu_devices, which has no users. Instead it uses the struct ia64

[PATCH 10/39] drivers: base: Print a warning instead of panic() when register_cpu() fails

2023-10-24 Thread Oracle
From: James Morse loongarch, mips, parisc, riscv and sh all print a warning if register_cpu() returns an error. Architectures that use GENERIC_CPU_DEVICES call panic() instead. Errors in this path indicate something is wrong with the firmware description of the platform, but the kernel is able t

[PATCH 18/39] ACPI: Only enumerate enabled (or functional) devices

2023-10-24 Thread Oracle
From: James Morse Today the ACPI enumeration code 'visits' all devices that are present. This is a problem for arm64, where CPUs are always present, but not always enabled. When a device-check occurs because the firmware-policy has changed and a CPU is now enabled, the following error occurs: |

[PATCH 19/39] ACPI: processor: Add support for processors described as container packages

2023-10-24 Thread Oracle
From: James Morse ACPI has two ways of describing processors in the DSDT. Either as a device object with HID ACPI0007, or as a type 'C' package inside a Processor Container. The ACPI processor driver probes CPUs described as devices, but not those described as packages. Duplicate descriptions ar

[PATCH 16/39] riscv: Switch over to GENERIC_CPU_DEVICES

2023-10-24 Thread Oracle
From: James Morse Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. This allows topology_init() to be removed. This is an intermediate step to the logic being

[PATCH 13/39] x86: intel_epb: Don't rely on link order

2023-10-24 Thread Oracle
From: James Morse intel_epb_init() is called as a subsys_initcall() to register cpuhp callbacks. The callbacks make use of get_cpu_device() which will return NULL unless register_cpu() has been called. register_cpu() is called from topology_init(), which is also a subsys_initcall(). This is frag

[PATCH 14/39] x86/topology: Switch over to GENERIC_CPU_DEVICES

2023-10-24 Thread Oracle
From: James Morse Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. x86's struct cpus come from struct x86_cpu, which has no other members or users. Remove thi

[PATCH 17/39] arch_topology: Make register_cpu_capacity_sysctl() tolerant to late CPUs

2023-10-24 Thread Oracle
From: James Morse register_cpu_capacity_sysctl() adds a property to sysfs that describes the CPUs capacity. This is done from a subsys_initcall() that assumes all possible CPUs are registered. With CPU hotplug, possible CPUs aren't registered until they become present, (or for arm64 enabled). Th

[PATCH 15/39] LoongArch: Switch over to GENERIC_CPU_DEVICES

2023-10-24 Thread Oracle
From: James Morse Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. This allows topology_init() to be removed. This is an intermediate step to the logic being

[PATCH 20/39] ACPI: processor: Register CPUs that are online, but not described in the DSDT

2023-10-24 Thread Oracle
From: James Morse ACPI has two descriptions of CPUs, one in the MADT/APIC table, the other in the DSDT. Both are required. (ACPI 6.5's 8.4 "Declaring Processors" says "Each processor in the system must be declared in the ACPI namespace"). Having two descriptions allows firmware authors to get thi

[PATCH 21/39] ACPI: processor: Register all CPUs from acpi_processor_get_info()

2023-10-24 Thread Oracle
From: James Morse To allow ACPI to skip the call to arch_register_cpu() when the _STA value indicates the CPU can't be brought online right now, move the arch_register_cpu() call into acpi_processor_get_info(). Systems can still be booted with 'acpi=off', or not include an ACPI description at al

[PATCH 23/39] drivers: base: Implement weak arch_unregister_cpu()

2023-10-24 Thread Oracle
From: James Morse Add arch_unregister_cpu() to allow the ACPI machinery to call unregister_cpu(). This is enough for arm64, riscv and loongarch, but needs to be overridden by x86 and ia64 who need to do more work. CC: Jean-Philippe Brucker Signed-off-by: James Morse --- Changes since v1: * Ad

[PATCH 24/39] ACPI: Move acpi_bus_trim_one() before acpi_scan_hot_remove()

2023-10-24 Thread Oracle
From: James Morse A subsequent patch will change acpi_scan_hot_remove() to call acpi_bus_trim_one() instead of acpi_bus_trim(), meaning it can no longer rely on the prototype in the header file. Move these functions further up the file. No change in behaviour. Signed-off-by: James Morse Review

[PATCH 25/39] ACPI: Rename acpi_processor_hotadd_init and remove pre-processor guards

2023-10-24 Thread Oracle
From: James Morse acpi_processor_hotadd_init() will make a CPU present by mapping it based on its hardware id. 'hotadd_init' is ambiguous once there are two different behaviours for cpu hotplug. This is for toggling the _STA present bit. Subsequent patches will add support for toggling the _STA

[PATCH 22/39] ACPI: Rename ACPI_HOTPLUG_CPU to include 'present'

2023-10-24 Thread Oracle
From: James Morse The code behind ACPI_HOTPLUG_CPU allows a not-present CPU to become present. This isn't the only use of HOTPLUG_CPU. On arm64 and riscv CPUs can be taken offline as a power saving measure. On arm64 an offline CPU may be disabled by firmware, preventing it from being brought bac

[PATCH 27/39] ACPI: Check _STA present bit before making CPUs not present

2023-10-24 Thread Oracle
From: James Morse When called acpi_processor_post_eject() unconditionally make a CPU not-present and unregisters it. To add support for AML events where the CPU has become disabled, but remains present, the _STA method should be checked before calling acpi_processor_remove(). Rename acpi_proces

[PATCH 26/39] ACPI: Add post_eject to struct acpi_scan_handler for cpu hotplug

2023-10-24 Thread Oracle
From: James Morse struct acpi_scan_handler has a detach callback that is used to remove a driver when a bus is changed. When interacting with an eject-request, the detach callback is called before _EJ0. This means the ACPI processor driver can't use _STA to determine if a CPU has been made not-p

[PATCH 28/39] ACPI: Warn when the present bit changes but the feature is not enabled

2023-10-24 Thread Oracle
From: James Morse ACPI firmware can trigger the events to add and remove CPUs, but the OS may not support this. Print an error message when this happens. This gives early warning on arm64 systems that don't support CONFIG_ACPI_HOTPLUG_PRESENT_CPU, as making CPUs not present has side effects for

[PATCH 29/39] LoongArch: Use the __weak version of arch_unregister_cpu()

2023-10-24 Thread Oracle
From: James Morse LoongArch provides its own arch_unregister_cpu(). This clears the hotpluggable flag, then unregisters the CPU. It isn't necessary to clear the hotpluggable flag when unregistering a cpu. unregister_cpu() writes NULL to the percpu cpu_sys_devices pointer, meaning cpu_is_hotplugg

[PATCH 35/39] ACPI: add support to register CPUs based on the _STA enabled bit

2023-10-24 Thread Oracle
From: James Morse acpi_processor_get_info() registers all present CPUs. Registering a CPU is what creates the sysfs entries and triggers the udev notifications. arm64 virtual machines that support 'virtual cpu hotplug' use the enabled bit to indicate whether the CPU can be brought online, as the

[PATCH 30/39] arm64: acpi: Move get_cpu_for_acpi_id() to a header

2023-10-24 Thread Oracle
From: James Morse ACPI identifies CPUs by UID. get_cpu_for_acpi_id() maps the ACPI UID to the linux CPU number. The helper to retrieve this mapping is only available in arm64's numa code. Move it to live next to get_acpi_id_for_cpu(). Signed-off-by: James Morse Reviewed-by: Jonathan Cameron

[PATCH 39/39] ACPI: processor: Only call arch_unregister_cpu() if HOTPLUG_CPU is selected

2023-10-24 Thread Oracle
From: James Morse The kbuild robot points out that configurations without HOTPLUG_CPU selected can try to build acpi_processor_post_eject() without success as arch_unregister_cpu() is not defined. Check this explicitly. This will be merged into: | ACPI: Add post_eject to struct acpi_scan_handler

[PATCH 38/39] cpumask: Add enabled cpumask for present CPUs that can be brought online

2023-10-24 Thread Oracle
From: James Morse The 'offline' file in sysfs shows all offline CPUs, including those that aren't present. User-space is expected to remove not-present CPUs from this list to learn which CPUs could be brought online. CPUs can be present but not-enabled. These CPUs can't be brought online until t

[PATCH 37/39] ACPI: Add _OSC bits to advertise OS support for toggling CPU present/enabled

2023-10-24 Thread Oracle
From: James Morse Platform firmware can disabled a CPU, or make it not-present by making an eject-request notification, then waiting for the os to make it offline and call _EJx. After the firmware updates _STA with the new status. Not all operating systems support this. For arm64 making CPUs not

[PATCH 31/39] ACPICA: Add new MADT GICC flags fields

2023-10-24 Thread Oracle
From: James Morse Add the new flag field to the MADT's GICC structure. 'Online Capable' indicates a disabled CPU can be enabled later. See ACPI specification 6.5 Tabel 5.37: GICC CPU Interface Flags. Signed-off-by: James Morse --- This patch probably needs to go via the upstream acpica project

[PATCH 36/39] arm64: document virtual CPU hotplug's expectations

2023-10-24 Thread Oracle
From: James Morse Add a description of physical and virtual CPU hotplug, explain the differences and elaborate on what is required in ACPI for a working virtual hotplug system. Signed-off-by: James Morse --- Documentation/arch/arm64/cpu-hotplug.rst | 79 Documentation/

[PATCH 33/39] irqchip/gic-v3: Add support for ACPI's disabled but 'online capable' CPUs

2023-10-24 Thread Oracle
From: James Morse To support virtual CPU hotplug, ACPI has added an 'online capable' bit to the MADT GICC entries. This indicates a disabled CPU entry may not be possible to online via PSCI until firmware has set enabled bit in _STA. What about the redistributor in the GICC entry? ACPI doesn't w

[PATCH 34/39] arm64: psci: Ignore DENIED CPUs

2023-10-24 Thread Oracle
From: Jean-Philippe Brucker When a CPU is marked as disabled, but online capable in the MADT, PSCI applies some firmware policy to control when it can be brought online. PSCI returns DENIED to a CPU_ON request if this is not currently permitted. The OS can learn the current policy from the _STA e

[PATCH 32/39] irqchip/gic-v3: Don't return errors from gic_acpi_match_gicc()

2023-10-24 Thread Oracle
From: James Morse gic_acpi_match_gicc() is only called via gic_acpi_count_gicr_regions(). It should only count the number of enabled redistributors, but it also tries to sanity check the GICC entry, currently returning an error if the Enabled bit is set, but the gicr_base_address is zero. Adding

Re: [PATCH 38/39] cpumask: Add enabled cpumask for present CPUs that can be brought online

2023-10-24 Thread Andy Shevchenko
On Tue, Oct 24, 2023 at 04:19:24PM +0100, Russell King wrote: > From: James Morse > > The 'offline' file in sysfs shows all offline CPUs, including those > that aren't present. User-space is expected to remove not-present CPUs > from this list to learn which CPUs could be brought online. > > CPU

Re: [PATCH 38/39] cpumask: Add enabled cpumask for present CPUs that can be brought online

2023-10-24 Thread Greg Kroah-Hartman
On Tue, Oct 24, 2023 at 04:19:24PM +0100, Russell King wrote: > From: James Morse > > The 'offline' file in sysfs shows all offline CPUs, including those > that aren't present. User-space is expected to remove not-present CPUs > from this list to learn which CPUs could be brought online. > > CPU

Re: [PATCH 38/39] cpumask: Add enabled cpumask for present CPUs that can be brought online

2023-10-24 Thread Russell King (Oracle)
On Tue, Oct 24, 2023 at 06:02:30PM +0200, Greg Kroah-Hartman wrote: > On Tue, Oct 24, 2023 at 04:19:24PM +0100, Russell King wrote: > > From: James Morse > > > > The 'offline' file in sysfs shows all offline CPUs, including those > > that aren't present. User-space is expected to remove not-prese

Re: [PATCH] Documentation: security-bugs.rst: linux-distros relaxed their rules

2023-10-24 Thread Willy Tarreau
On Tue, Oct 24, 2023 at 11:24:27AM +0200, Greg Kroah-Hartman wrote: > On Sun, Oct 22, 2023 at 08:31:45PM -0600, Jonathan Corbet wrote: > > Willy Tarreau writes: > > > > > The linux-distros list relaxed their rules to try to adapt better to > > > how the Linux kernel works. Let's update the Coordi

Re: [RFC PATCH v3 00/39] ACPI/arm64: add support for virtual cpuhotplug

2023-10-24 Thread Russell King (Oracle)
On Tue, Oct 24, 2023 at 04:15:28PM +0100, Russell King (Oracle) wrote: > Hi, > > I'm posting James' patch set updated with most of the review comments > from his RFC v2 series back in September. Individual patches have a > changelog attached at the bottom of the commit message. Those which > I hav

Re: [PATCH 18/39] ACPI: Only enumerate enabled (or functional) devices

2023-10-24 Thread Rafael J. Wysocki
On Tue, Oct 24, 2023 at 5:17 PM Russell King wrote: > > From: James Morse > > Today the ACPI enumeration code 'visits' all devices that are present. > > This is a problem for arm64, where CPUs are always present, but not > always enabled. When a device-check occurs because the firmware-policy > h

Re: [RFC PATCH v3 00/39] ACPI/arm64: add support for virtual cpuhotplug

2023-10-24 Thread Rafael J. Wysocki
On Tue, Oct 24, 2023 at 5:15 PM Russell King (Oracle) wrote: > > Hi, > > I'm posting James' patch set updated with most of the review comments > from his RFC v2 series back in September. Individual patches have a > changelog attached at the bottom of the commit message. Those which > I have finish

Re: [PATCH v2 00/39] Memory allocation profiling

2023-10-24 Thread Roman Gushchin
On Tue, Oct 24, 2023 at 06:45:57AM -0700, Suren Baghdasaryan wrote: > Updates since the last version [1] > - Simplified allocation tagging macros; > - Runtime enable/disable sysctl switch (/proc/sys/vm/mem_profiling) > instead of kernel command-line option; > - CONFIG_MEM_ALLOC_PROFILING_BY_DEFAULT

Re: [PATCH v2 00/39] Memory allocation profiling

2023-10-24 Thread Suren Baghdasaryan
On Tue, Oct 24, 2023 at 11:29 AM Roman Gushchin wrote: > > On Tue, Oct 24, 2023 at 06:45:57AM -0700, Suren Baghdasaryan wrote: > > Updates since the last version [1] > > - Simplified allocation tagging macros; > > - Runtime enable/disable sysctl switch (/proc/sys/vm/mem_profiling) > > instead of k

Re: [RFC PATCH v3 00/39] ACPI/arm64: add support for virtual cpuhotplug

2023-10-24 Thread Russell King (Oracle)
On Tue, Oct 24, 2023 at 08:26:58PM +0200, Rafael J. Wysocki wrote: > On Tue, Oct 24, 2023 at 5:15 PM Russell King (Oracle) > wrote: > > > > Hi, > > > > I'm posting James' patch set updated with most of the review comments > > from his RFC v2 series back in September. Individual patches have a > >

Re: [PATCH v2 06/39] mm: enumerate all gfp flags

2023-10-24 Thread Petr Tesařík
On Tue, 24 Oct 2023 06:46:03 -0700 Suren Baghdasaryan wrote: > Introduce GFP bits enumeration to let compiler track the number of used > bits (which depends on the config options) instead of hardcoding them. > That simplifies __GFP_BITS_SHIFT calculation. > Suggested-by: Petr Tesařík > Signed-of