[PATCH v2 00/39] Memory allocation profiling

2023-10-24 Thread Suren Baghdasaryan
xt mm: percpu: Add codetag reference into pcpuobj_ext arm64: Fix circular header dependency mm: vmalloc: Enable memory allocation profiling rhashtable: Plumb through alloc tag MAINTAINERS: Add entries for code tagging and memory allocation profiling Suren Baghdasaryan (23): mm: enumer

[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:

[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 Baghdasarya

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

2023-10-24 Thread Suren Baghdasaryan
eader dependency in the alloc tagging patch series, and as a bonus should speed up kernel build times. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan Cc: Ingo Molnar Cc: Peter Zijlstra --- include/linux/nodemask.h | 2 +- include/linux/nodemask_types.h | 9 + in

[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/pran

[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
ure. Signed-off-by: Suren Baghdasaryan --- include/linux/memcontrol.h | 20 +++-- include/linux/mm_types.h | 4 +- init/Kconfig | 4 + mm/kfence/core.c | 14 ++-- mm/kfence/kfence.h | 4 +- mm/memcontrol.c| 56 ++ mm/page_owne

[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

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

2023-10-24 Thread Suren Baghdasaryan
mark these caches and avoid creating extensions for objects allocated from these slabs. Signed-off-by: Suren Baghdasaryan --- include/linux/slab.h | 7 +++ mm/slab.c| 2 +- mm/slub.c| 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linu

[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

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

2023-10-24 Thread Suren Baghdasaryan
Overstreet Signed-off-by: Suren Baghdasaryan --- include/linux/codetag.h | 71 ++ lib/Kconfig.debug | 4 + lib/Makefile| 1 + lib/codetag.c | 199 4 files changed, 275 insertions(+) create mode 100644 include/linux

[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

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

2023-10-24 Thread Suren Baghdasaryan
fault. Co-developed-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan Signed-off-by: Kent Overstreet --- Documentation/admin-guide/sysctl/vm.rst | 16 +++ Documentation/filesystems/proc.rst | 28 + include/asm-generic/codetag.lds.h | 14 +++ include/asm-generic/vml

[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

[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 +- driver

[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_

[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:

[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
we enable it only when debugging with CONFIG_MEM_ALLOC_PROFILING_DEBUG enabled and not universally for CONFIG_MEM_ALLOC_PROFILING. Signed-off-by: Suren Baghdasaryan --- mm/page_ext.c | 9 + 1 file changed, 9 insertions(+) diff --git a/mm/page_ext.c b/mm/page_ext.c index 3c58fe8a24df

[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

[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

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

2023-10-24 Thread Suren Baghdasaryan
. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan --- include/linux/mempool.h | 73 - mm/mempool.c| 34 --- 2 files changed, 48 insertions(+), 59 deletions(-) diff --git a/include/linux/mempool.h b/include/linux

[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

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

2023-10-24 Thread Suren Baghdasaryan
patch - similarly to the previous slabobj_ext patch. Signed-off-by: Kent Overstreet Signed-off-by: Suren Baghdasaryan Cc: Andrew Morton Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: linux...@kvack.org --- mm/percpu-internal.h | 19 +-- mm/percpu.c | 30

[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

[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

[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

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

2023-10-24 Thread Suren Baghdasaryan
. Introduce CODETAG_EMPTY special codetag value to mark allocations which intentionally lack codetag to avoid these warnings. Set objext codetags to CODETAG_EMPTY before freeing to indicate that the codetag is expected to be empty. Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h

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

2023-10-24 Thread Suren Baghdasaryan
a new objext_flags flag stored in the lower bits of slab->obj_exts. When new allocation succeeds it marks all tag references in the same slabobj_ext vector as empty to avoid warnings implemented by CONFIG_MEM_ALLOC_PROFILING_DEBUG checks. Signed-off-by: Suren Baghdasaryan --- include/li

[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 2894f077

[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

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_p

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

2023-10-25 Thread Suren Baghdasaryan
On Tue, Oct 24, 2023 at 10:47 PM Petr Tesařík wrote: > > 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 t

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

2023-10-26 Thread Suren Baghdasaryan
On Wed, Oct 25, 2023 at 5:33 PM Thomas Gleixner wrote: > > On Tue, Oct 24 2023 at 06:46, Suren Baghdasaryan wrote: > > From: Kent Overstreet > > > > This avoids a circular header dependency in an upcoming patch by only > > making hrtimer.h depend on percpu-defs.h &g

Re: [PATCH v6 30/37] mm: vmalloc: Enable memory allocation profiling

2024-03-25 Thread Suren Baghdasaryan
On Mon, Mar 25, 2024 at 10:49 AM SeongJae Park wrote: > > On Mon, 25 Mar 2024 14:56:01 + Suren Baghdasaryan > wrote: > > > On Sat, Mar 23, 2024 at 6:05 PM SeongJae Park wrote: > > > > > > Hi Suren and Kent, > > > > > > On Thu, 21 Ma

Re: [PATCH v6 30/37] mm: vmalloc: Enable memory allocation profiling

2024-03-26 Thread Suren Baghdasaryan
On Mon, Mar 25, 2024 at 11:20 AM SeongJae Park wrote: > > On Mon, 25 Mar 2024 10:59:01 -0700 Suren Baghdasaryan > wrote: > > > On Mon, Mar 25, 2024 at 10:49 AM SeongJae Park wrote: > > > > > > On Mon, 25 Mar 2024 14:56:01 + Suren Baghdasaryan >

[PATCH 0/5] page allocation tag compression

2024-08-19 Thread Suren Baghdasaryan
inside page flags if they fit. Patchset applies to mm-unstable. Suren Baghdasaryan (5): alloc_tag: load module tags into separate continuous memory alloc_tag: eliminate alloc_tag_ref_set alloc_tag: introduce pgalloc_tag_ref to abstract page tag references alloc_tag: make page allocation tag

[PATCH 1/5] alloc_tag: load module tags into separate continuous memory

2024-08-19 Thread Suren Baghdasaryan
dule_alloc_tags kernel parameter is introduced to change this size. Signed-off-by: Suren Baghdasaryan --- .../admin-guide/kernel-parameters.txt | 4 + include/asm-generic/codetag.lds.h | 19 ++ include/linux/alloc_tag.h | 13 +- include/

[PATCH 2/5] alloc_tag: eliminate alloc_tag_ref_set

2024-08-19 Thread Suren Baghdasaryan
To simplify further refactoring, open-code the only two callers of alloc_tag_ref_set(). Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 25 ++--- include/linux/pgalloc_tag.h | 12 +++- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git

[PATCH 3/5] alloc_tag: introduce pgalloc_tag_ref to abstract page tag references

2024-08-19 Thread Suren Baghdasaryan
To simplify later changes to page tag references, introduce new pgalloc_tag_ref and pgtag_ref_handle types. This allows easy replacement of page_ext as a storage of page allocation tags Signed-off-by: Suren Baghdasaryan --- include/linux/pgalloc_tag.h | 144

[PATCH 4/5] alloc_tag: make page allocation tag reference size configurable

2024-08-19 Thread Suren Baghdasaryan
Introduce CONFIG_PGALLOC_TAG_REF_BITS to control the size of the page allocation tag references. When the size is configured to be less than a direct pointer, the tags are searched using an index stored as the tag reference. Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 10

[PATCH 5/5] alloc_tag: config to store page allocation tag refs in page flags

2024-08-19 Thread Suren Baghdasaryan
required to be available in the page flags to store the references. If the number of page flag bits is insufficient, the build will fail and either CONFIG_PGALLOC_TAG_REF_BITS would have to be lowered or CONFIG_PGALLOC_TAG_USE_PAGEFLAGS should be disabled. Signed-off-by: Suren Baghdasaryan --- include

Re: [PATCH 5/5] alloc_tag: config to store page allocation tag refs in page flags

2024-08-19 Thread Suren Baghdasaryan
On Mon, Aug 19, 2024 at 12:34 PM Matthew Wilcox wrote: > > On Mon, Aug 19, 2024 at 08:15:11AM -0700, Suren Baghdasaryan wrote: > > @@ -91,7 +97,7 @@ > > #endif > > > > #if ZONES_WIDTH + LRU_GEN_WIDTH + SECTIONS_WIDTH + NODES_WIDTH + \ > > -

Re: [PATCH 5/5] alloc_tag: config to store page allocation tag refs in page flags

2024-08-19 Thread Suren Baghdasaryan
On Mon, Aug 19, 2024 at 6:46 PM Andrew Morton wrote: > > On Mon, 19 Aug 2024 21:40:34 +0100 Matthew Wilcox wrote: > > > On Mon, Aug 19, 2024 at 01:39:16PM -0700, Suren Baghdasaryan wrote: > > > On Mon, Aug 19, 2024 at 12:34 PM Matthew Wilcox > > > wrote: >

Re: [PATCH 1/5] alloc_tag: load module tags into separate continuous memory

2024-08-20 Thread Suren Baghdasaryan
On Tue, Aug 20, 2024 at 12:13 AM Mike Rapoport wrote: > > On Mon, Aug 19, 2024 at 08:15:07AM -0700, Suren Baghdasaryan wrote: > > When a module gets unloaded there is a possibility that some of the > > allocations it made are still used and therefore the allocation tags > >

Re: [PATCH 1/5] alloc_tag: load module tags into separate continuous memory

2024-08-20 Thread Suren Baghdasaryan
On Tue, Aug 20, 2024 at 8:31 AM 'Liam R. Howlett' via kernel-team wrote: > > * Suren Baghdasaryan [240819 11:15]: > > When a module gets unloaded there is a possibility that some of the > > allocations it made are still used and therefore the allocation tag

[PATCH v2 6/6] alloc_tag: config to store page allocation tag refs in page flags

2024-09-01 Thread Suren Baghdasaryan
required to be available in the page flags to store the references. If the number of page flag bits is insufficient, the build will fail and either CONFIG_PGALLOC_TAG_REF_BITS would have to be lowered or CONFIG_PGALLOC_TAG_USE_PAGEFLAGS should be disabled. Signed-off-by: Suren Baghdasaryan --- include

[PATCH v2 1/6] maple_tree: add mas_for_each_rev() helper

2024-09-01 Thread Suren Baghdasaryan
Add mas_for_each_rev() function to iterate maple tree nodes in reverse order. Suggested-by: Liam R. Howlett Signed-off-by: Suren Baghdasaryan --- include/linux/maple_tree.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/include/linux/maple_tree.h b/include/linux

[PATCH v2 2/6] alloc_tag: load module tags into separate continuous memory

2024-09-01 Thread Suren Baghdasaryan
dule_alloc_tags kernel parameter is introduced to change this size. Signed-off-by: Suren Baghdasaryan --- .../admin-guide/kernel-parameters.txt | 4 + include/asm-generic/codetag.lds.h | 19 ++ include/linux/alloc_tag.h | 13 +- include/

[PATCH v2 5/6] alloc_tag: make page allocation tag reference size configurable

2024-09-01 Thread Suren Baghdasaryan
Introduce CONFIG_PGALLOC_TAG_REF_BITS to control the size of the page allocation tag references. When the size is configured to be less than a direct pointer, the tags are searched using an index stored as the tag reference. Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 10

[PATCH v2 3/6] alloc_tag: eliminate alloc_tag_ref_set

2024-09-01 Thread Suren Baghdasaryan
To simplify further refactoring, open-code the only two callers of alloc_tag_ref_set(). Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 25 ++--- include/linux/pgalloc_tag.h | 12 +++- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git

[PATCH v2 0/6] page allocation tag compression

2024-09-01 Thread Suren Baghdasaryan
configuration build, per kernel test robot [1] https://lore.kernel.org/all/20240819151512.2363698-1-sur...@google.com/ Suren Baghdasaryan (6): maple_tree: add mas_for_each_rev() helper alloc_tag: load module tags into separate continuous memory alloc_tag: eliminate alloc_tag_ref_set alloc_tag

[PATCH v2 4/6] alloc_tag: introduce pgalloc_tag_ref to abstract page tag references

2024-09-01 Thread Suren Baghdasaryan
To simplify later changes to page tag references, introduce new pgalloc_tag_ref and pgtag_ref_handle types. This allows easy replacement of page_ext as a storage of page allocation tags Signed-off-by: Suren Baghdasaryan --- include/linux/pgalloc_tag.h | 144

Re: [PATCH v2 6/6] alloc_tag: config to store page allocation tag refs in page flags

2024-09-03 Thread Suren Baghdasaryan
On Sun, Sep 1, 2024 at 10:16 PM Andrew Morton wrote: > > On Sun, 1 Sep 2024 21:41:28 -0700 Suren Baghdasaryan > wrote: > > > Add CONFIG_PGALLOC_TAG_USE_PAGEFLAGS to store allocation tag > > references directly in the page flags. This removes dependency on > >

Re: [PATCH v2 5/6] alloc_tag: make page allocation tag reference size configurable

2024-09-03 Thread Suren Baghdasaryan
On Sun, Sep 1, 2024 at 10:09 PM Andrew Morton wrote: > > On Sun, 1 Sep 2024 21:41:27 -0700 Suren Baghdasaryan > wrote: > > > Introduce CONFIG_PGALLOC_TAG_REF_BITS to control the size of the > > page allocation tag references. When the size is configured to be > &

Re: [PATCH v2 5/6] alloc_tag: make page allocation tag reference size configurable

2024-09-03 Thread Suren Baghdasaryan
On Tue, Sep 3, 2024 at 6:17 PM Kent Overstreet wrote: > > On Tue, Sep 03, 2024 at 06:07:28PM GMT, Suren Baghdasaryan wrote: > > On Sun, Sep 1, 2024 at 10:09 PM Andrew Morton > > wrote: > > > > > > On Sun, 1 Sep 2024 21:41:27 -0700 Suren Baghdasaryan

Re: [PATCH v2 6/6] alloc_tag: config to store page allocation tag refs in page flags

2024-09-04 Thread Suren Baghdasaryan
On Tue, Sep 3, 2024 at 7:06 PM 'John Hubbard' via kernel-team wrote: > > On 9/3/24 6:25 PM, John Hubbard wrote: > > On 9/3/24 11:19 AM, Suren Baghdasaryan wrote: > >> On Sun, Sep 1, 2024 at 10:16 PM Andrew Morton > >> wrote: > >>> O

Re: [PATCH v2 6/6] alloc_tag: config to store page allocation tag refs in page flags

2024-09-04 Thread Suren Baghdasaryan
On Tue, Sep 3, 2024 at 7:19 PM Matthew Wilcox wrote: > > On Tue, Sep 03, 2024 at 06:25:52PM -0700, John Hubbard wrote: > > The more I read this story, the clearer it becomes that this should be > > entirely done by the build system: set it, or don't set it, automatically. > > > > And if you can ma

Re: [PATCH v2 5/6] alloc_tag: make page allocation tag reference size configurable

2024-09-04 Thread Suren Baghdasaryan
On Wed, Sep 4, 2024 at 9:25 AM Kent Overstreet wrote: > > On Tue, Sep 03, 2024 at 07:04:51PM GMT, Suren Baghdasaryan wrote: > > On Tue, Sep 3, 2024 at 6:17 PM Kent Overstreet > > wrote: > > > > > > On Tue, Sep 03, 2024 at 06:07:28PM GMT, Suren Baghdasaryan w

Re: [PATCH v2 6/6] alloc_tag: config to store page allocation tag refs in page flags

2024-09-04 Thread Suren Baghdasaryan
On Wed, Sep 4, 2024 at 9:37 AM Kent Overstreet wrote: > > On Wed, Sep 04, 2024 at 05:35:49PM GMT, Matthew Wilcox wrote: > > On Wed, Sep 04, 2024 at 09:18:01AM -0700, Suren Baghdasaryan wrote: > > > I'm not sure I understand your suggestion, Matthew. We allocate a >

Re: [PATCH v2 6/6] alloc_tag: config to store page allocation tag refs in page flags

2024-09-04 Thread Suren Baghdasaryan
On Wed, Sep 4, 2024 at 11:58 AM 'John Hubbard' via kernel-team wrote: > > On 9/4/24 9:08 AM, Suren Baghdasaryan wrote: > > On Tue, Sep 3, 2024 at 7:06 PM 'John Hubbard' via kernel-team > > wrote: > >> On 9/3/24 6:25 PM, John Hubbard wrote: >

[PATCH 1/1] psi: do not require setsched permission from the trigger creator

2019-07-29 Thread Suren Baghdasaryan
thread's scheduling policy is an implementation detail and should not be exposed to the user level. Remove the permission check by using _nocheck version of the function. Suggested-by: Nick Kralevich Signed-off-by: Suren Baghdasaryan --- kernel/sched/psi.c | 2 +- 1 file changed, 1 insertion(

Re: [PATCH 1/1] psi: do not require setsched permission from the trigger creator

2019-07-29 Thread Suren Baghdasaryan
On Mon, Jul 29, 2019 at 12:57 PM Greg KH wrote: > > On Mon, Jul 29, 2019 at 12:42:05PM -0700, Suren Baghdasaryan wrote: > > When a process creates a new trigger by writing into /proc/pressure/* > > files, permissions to write such a file should be used to determine whether

[PATCH 1/1] psi: do not require setsched permission from the trigger creator

2019-07-29 Thread Suren Baghdasaryan
thread's scheduling policy is an implementation detail and should not be exposed to the user level. Remove the permission check by using _nocheck version of the function. Suggested-by: Nick Kralevich Signed-off-by: Suren Baghdasaryan --- kernel/sched/psi.c | 2 +- 1 file changed, 1 insertion(

Re: [PATCH 1/1] psi: do not require setsched permission from the trigger creator

2019-07-30 Thread Suren Baghdasaryan
On Tue, Jul 30, 2019 at 1:11 AM Peter Zijlstra wrote: > > On Mon, Jul 29, 2019 at 06:33:10PM -0700, Suren Baghdasaryan wrote: > > When a process creates a new trigger by writing into /proc/pressure/* > > files, permissions to write such a file should be used to determine wheth

Re: [PATCH 1/1] psi: do not require setsched permission from the trigger creator

2019-08-01 Thread Suren Baghdasaryan
things in life. I checked and your proposal to change it to FIFO-1 should still work for our purposes. Will test to make sure and reply to your patch. Couple clarifications in-line. On Thu, Aug 1, 2019 at 2:51 AM Peter Zijlstra wrote: > > On Tue, Jul 30, 2019 at 10:44:51AM -0700, Suren Baghda

Re: [PATCH 1/1] psi: do not require setsched permission from the trigger creator

2019-08-01 Thread Suren Baghdasaryan
On Thu, Aug 1, 2019 at 2:59 PM Peter Zijlstra wrote: > > On Thu, Aug 01, 2019 at 11:28:30AM -0700, Suren Baghdasaryan wrote: > > > By marking it FIFO-99 you're in effect saying that your stupid > > > statistics gathering is more important than your life. It will pre

[PATCH v5 1/7] psi: introduce state_mask to represent stalled psi states

2019-03-08 Thread Suren Baghdasaryan
into psi_group_cpu struct which results in its first cacheline-aligned part becoming 52 bytes long. Add explicit values to enumeration element counters that affect psi_group_cpu struct size. Link: http://lkml.kernel.org/r/20190124211518.244221-4-sur...@google.com Signed-off-by: Suren Baghdasaryan

[PATCH v5 3/7] psi: rename psi fields in preparation for psi trigger addition

2019-03-08 Thread Suren Baghdasaryan
Renaming psi_group structure member fields used for calculating psi totals and averages for clear distinction between them and trigger-related fields that will be added next. Signed-off-by: Suren Baghdasaryan --- include/linux/psi_types.h | 14 ++--- kernel/sched/psi.c| 41

[PATCH v5 7/7] psi: introduce psi monitor

2019-03-08 Thread Suren Baghdasaryan
/deactivations when psi signal is bouncing. Notifications to the users are rate-limited to one per tracking window. Signed-off-by: Suren Baghdasaryan Signed-off-by: Johannes Weiner --- Documentation/accounting/psi.txt | 107 +++ include/linux/psi.h | 8 + include/linux

[PATCH v5 2/7] psi: make psi_enable static

2019-03-08 Thread Suren Baghdasaryan
psi_enable is not used outside of psi.c, make it static. Suggested-by: Andrew Morton Signed-off-by: Suren Baghdasaryan --- kernel/sched/psi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 22c1505ad290..281702de9772 100644

[PATCH v5 5/7] psi: track changed states

2019-03-08 Thread Suren Baghdasaryan
Introduce changed_states parameter into collect_percpu_times to track the states changed since the last update. Signed-off-by: Suren Baghdasaryan --- kernel/sched/psi.c | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/kernel/sched/psi.c b/kernel

[PATCH v5 4/7] psi: split update_stats into parts

2019-03-08 Thread Suren Baghdasaryan
Split update_stats into collect_percpu_times and update_averages for collect_percpu_times to be reused later inside psi monitor. Signed-off-by: Suren Baghdasaryan --- kernel/sched/psi.c | 55 +++--- 1 file changed, 32 insertions(+), 23 deletions(-) diff

[PATCH v5 6/7] refactor header includes to allow kthread.h inclusion in psi_types.h

2019-03-08 Thread Suren Baghdasaryan
m the headers included from kthread.h. Signed-off-by: Suren Baghdasaryan --- include/linux/kthread.h | 3 ++- include/linux/sched.h | 1 - kernel/kthread.c| 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/kthread.h b/include/linux/kthread.h index 2c89e60

[PATCH v5 0/7] psi: pressure stall monitors v5

2019-03-08 Thread Suren Baghdasaryan
for short intervals, and hooks up write() and poll() on the pressure files. The patches were developed in collaboration with Johannes Weiner. The patches are based on 5.0-rc8 (Merge tag 'drm-next-2019-03-06'). Suren Baghdasaryan (7): psi: introduce state_mask to represent stalled psi

[PATCH 0/6] psi: pressure stall monitors

2018-12-14 Thread Suren Baghdasaryan
ed in collaboration with Johannes Weiner. The patches are based on 4.20-rc6. Johannes Weiner (3): fs: kernfs: add poll file operation kernel: cgroup: add poll file operation psi: eliminate lazy clock mode Suren Baghdasaryan (3): psi: introduce state_mask to represent stalled psi s

[PATCH 6/6] psi: introduce psi monitor

2018-12-14 Thread Suren Baghdasaryan
duration of one tracking window to avoid repeated activations/deactivations when psi signal is bouncing. Notifications to the users are rate-limited to one per tracking window. Signed-off-by: Suren Baghdasaryan --- Documentation/accounting/psi.txt | 105 +++ include/linux/psi.h | 10

[PATCH 1/6] fs: kernfs: add poll file operation

2018-12-14 Thread Suren Baghdasaryan
have per-fd trigger configurations. Signed-off-by: Johannes Weiner Signed-off-by: Suren Baghdasaryan --- fs/kernfs/file.c | 31 --- include/linux/kernfs.h | 6 ++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/fs/kernfs/file.c b/fs/kernfs

[PATCH 4/6] psi: introduce state_mask to represent stalled psi states

2018-12-14 Thread Suren Baghdasaryan
The psi monitoring patches will need to determine the same states as record_times(). To avoid calculating them twice, maintain a state mask that can be consulted cheaply. Do this in a separate patch to keep the churn in the main feature patch at a minimum. Signed-off-by: Suren Baghdasaryan

[PATCH 2/6] kernel: cgroup: add poll file operation

2018-12-14 Thread Suren Baghdasaryan
have per-fd trigger configurations. Signed-off-by: Johannes Weiner Signed-off-by: Suren Baghdasaryan --- include/linux/cgroup-defs.h | 4 kernel/cgroup/cgroup.c | 12 2 files changed, 16 insertions(+) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h

[PATCH 5/6] psi: rename psi fields in preparation for psi trigger addition

2018-12-14 Thread Suren Baghdasaryan
Renaming psi_group structure member fields used for calculating psi totals and averages for clear distinction between them and trigger-related fields that will be added next. Signed-off-by: Suren Baghdasaryan --- include/linux/psi_types.h | 15 --- kernel/sched/psi.c| 26

[PATCH 3/6] psi: eliminate lazy clock mode

2018-12-14 Thread Suren Baghdasaryan
Signed-off-by: Suren Baghdasaryan --- kernel/sched/psi.c | 55 +++--- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index fe24de3fbc93..d2b9c9a1a62f 100644 --- a/kernel/sched/psi.c +++ b/kernel/s

Re: [PATCH 3/6] psi: eliminate lazy clock mode

2018-12-17 Thread Suren Baghdasaryan
On Mon, Dec 17, 2018 at 6:58 AM Peter Zijlstra wrote: > > On Fri, Dec 14, 2018 at 09:15:05AM -0800, Suren Baghdasaryan wrote: > > Eliminate the idle mode and keep the worker doing 2s update intervals > > at all times. > > That sounds like a bad deal.. esp. so for batt

Re: [PATCH 4/6] psi: introduce state_mask to represent stalled psi states

2018-12-17 Thread Suren Baghdasaryan
On Mon, Dec 17, 2018 at 7:55 AM Peter Zijlstra wrote: > > On Fri, Dec 14, 2018 at 09:15:06AM -0800, Suren Baghdasaryan wrote: > > The psi monitoring patches will need to determine the same states as > > record_times(). To avoid calculating them twice, maintain a state ma

Re: [PATCH 6/6] psi: introduce psi monitor

2018-12-17 Thread Suren Baghdasaryan
On Mon, Dec 17, 2018 at 8:22 AM Peter Zijlstra wrote: > > On Fri, Dec 14, 2018 at 09:15:08AM -0800, Suren Baghdasaryan wrote: > > +ssize_t psi_trigger_parse(char *buf, size_t nbytes, enum psi_res res, > > + enum psi_states *state, u32 *threshold_us, u32 *win_sz_us) > >

Re: [PATCH 6/6] psi: introduce psi monitor

2018-12-17 Thread Suren Baghdasaryan
On Mon, Dec 17, 2018 at 8:37 AM Peter Zijlstra wrote: > > On Fri, Dec 14, 2018 at 09:15:08AM -0800, Suren Baghdasaryan wrote: > > @@ -358,28 +526,23 @@ static void psi_update_work(struct work_struct *work) > > { > > struct delayed_work *dwork; > >

Re: [PATCH 6/6] psi: introduce psi monitor

2018-12-18 Thread Suren Baghdasaryan
2018 at 9:30 AM Johannes Weiner wrote: > > On Tue, Dec 18, 2018 at 11:46:22AM +0100, Peter Zijlstra wrote: > > On Mon, Dec 17, 2018 at 05:21:05PM -0800, Suren Baghdasaryan wrote: > > > On Mon, Dec 17, 2018 at 8:22 AM Peter Zijlstra > > > wrote: > > > > > >

Re: [PATCH 6/6] psi: introduce psi monitor

2018-12-18 Thread Suren Baghdasaryan
On Tue, Dec 18, 2018 at 11:18 AM Joel Fernandes wrote: > > On Tue, Dec 18, 2018 at 9:58 AM 'Suren Baghdasaryan' via kernel-team > wrote: > > > > Current design supports only whole percentages and if userspace needs > > more granularity then it has to us

[PATCH v2 3/5] psi: introduce state_mask to represent stalled psi states

2019-01-10 Thread Suren Baghdasaryan
psi_group_cpu struct which results in its first cacheline-aligned part to become 52 bytes long. Add explicit values to enumeration element counters that affect psi_group_cpu struct size. Signed-off-by: Suren Baghdasaryan --- include/linux/psi_types.h | 9 ++--- kernel/sched/psi.c| 29

[PATCH v2 4/5] psi: rename psi fields in preparation for psi trigger addition

2019-01-10 Thread Suren Baghdasaryan
Renaming psi_group structure member fields used for calculating psi totals and averages for clear distinction between them and trigger-related fields that will be added next. Signed-off-by: Suren Baghdasaryan --- include/linux/psi_types.h | 15 --- kernel/sched/psi.c| 26

[PATCH v2 2/5] kernel: cgroup: add poll file operation

2019-01-10 Thread Suren Baghdasaryan
have per-fd trigger configurations. Signed-off-by: Johannes Weiner Signed-off-by: Suren Baghdasaryan --- include/linux/cgroup-defs.h | 4 kernel/cgroup/cgroup.c | 12 2 files changed, 16 insertions(+) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h

  1   2   >