FAILED: patch "[PATCH] mm/damon/tests/core-kunit: handle alloc failres in" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 28ab2265e9422ccd81e4beafc0ace90f78de04c4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026010550-tank-repugnant-eee6@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 28ab2265e9422ccd81e4beafc0ace90f78de04c4 Mon Sep 17 00:00:00 2001
From: SeongJae Park <[email protected]>
Date: Sat, 1 Nov 2025 11:20:07 -0700
Subject: [PATCH] mm/damon/tests/core-kunit: handle alloc failres in
damon_test_new_filter()
damon_test_new_filter() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases.
mm/damon/tests/core-kunit.h +2 -0
@@ -505,6 +505,8 @@ static void damos_test_new_filter(struct kunit *test)struct damos_filter *filter; filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true, false); +if (!filter) +kunit_skip (test,"filter alloc fail" );KUNIT_EXPECT_EQ (test, filter->type,DAMOS_FILTER_TYPE_ANON );KUNIT_EXPECT_EQ (test, filter->matching, true);KUNIT_EXPECT_PTR_EQ (test, filter->list.prev, &filter->list);
Sasha Levin
maintainerPATCH 1/4 mm/damon: fixup damos_filter kernel-doc
From: SeongJae Park <[email protected]>
[ Upstream commit e20f52e8e3b7947e40bd40c6cdc69884c6df716c ]
Patch series "mm/damon: extend DAMOS filters for inclusion", v2.
DAMOS fitlers are exclusive filters. It only excludes memory of given criterias from the DAMOS action targets. This has below limitations.
First, the name is not explicitly explaining the behavior. This actually resulted in users' confusions[1]. Secondly, combined uses of multiple filters provide only restriced coverages. For example, building a DAMOS scheme that applies the action to memory that belongs to cgroup A "or" cgroup B is impossible. A workaround would be using two schemes that fitlers out memory that not belong to cgroup A and cgroup B, respectively. It is cumbersome, and difficult to control quota-like per-scheme features in an orchestration. Monitoring of filters-passed memory statistic will also be complicated.
Extend DAMOS filters to support not only exclusion (rejecting), but also inclusion (allowing) behavior. For this, add a new damos_filter struct field called 'allow' for DAMON kernel API users. The filter works as an inclusion or exclusion filter when it is set or unset, respectively. For DAMON user-space ABI users, add a DAMON sysfs file of same name under DAMOS filter sysfs directory. To prevent exposing a behavioral change to old users, set rejecting as the default behavior.
Note that allow-filters work for only inclusion, not exclusion of memory that not satisfying the criteria. And the default behavior of DAMOS for memory that no filter has involved is that the action can be applied to those memory. Also, filters-passed memory statistics are for any memory that passed through the DAMOS filters check stage. These implies installing allow-filters at the endof the filter list is useless. Refer to the design doc change of this series for more details.
[1] https://lore.kernel.org/[email protected]
This patch (of 10):
The comment is slightly wrong. DAMOS filters are not only for pages, but general bytes of memory. Also the description of 'matching' is bit confusing, since DAMOS filters do only filtering out. Update the comments to be less confusing.
Stable-dep-of: 28ab2265e942 ("mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()")
--- include/linux/damon.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
include/linux/damon.h +6 -5
@@ -327,8 +327,8 @@ enum damos_filter_type {/** * struct damos_filter - DAMOS action target memory filter. -* @type: Type of the page. -* @matching: If the matching page should filtered out or in. +* @type: Type of the target memory. +* @matching: If the @type-matching memory should be filtered out. * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. * @addr_range: Address range if @type is DAMOS_FILTER_TYPE_ADDR. * @target_idx: Index of the &struct damon_target of
@@ -337,9 +337,10 @@ enum damos_filter_type {* @list: List head for siblings. * * Before applying the &damos->action to a memory region, DAMOS checks if each -* page of the region matches to this and avoid applying the action if so. -* Support of each filter type depends on the running &struct damon_operations -* and the type. Refer to &enum damos_filter_type for more detai. +* byte of the region matches to this given condition and avoid applying the +* action if so. Support of each filter type depends on the running &struct +* damon_operations and the type. Refer to &enum damos_filter_type for more +* details. */ struct damos_filter {enum damos_filter_type type;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/4 mm/damon/core: add damos_filter->allow field
From: SeongJae Park <[email protected]>
[ Upstream commit fe6d7fdd62491524d11433b9ff8d3db5dde32700 ]
DAMOS filters work as only exclusive (reject) filters. This makes it easy to be confused, and restrictive at combining multiple filters for covering various types of memory.
Add a field named 'allow' to damos_filter. The field will be used to indicate whether the filter should work for inclusion or exclusion. To keep the old behavior, set it as 'false' (work as exclusive filter) by default, from damos_new_filter().
Following two commits will make the core and operations set layers, which handles damos_filter objects, respect the field, respectively.
Stable-dep-of: 28ab2265e942 ("mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()")
--- include/linux/damon.h | 4 +++- mm/damon/core.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
include/linux/damon.h +3 -1
@@ -328,7 +328,8 @@ enum damos_filter_type {/** * struct damos_filter - DAMOS action target memory filter. * @type: Type of the target memory. -* @matching: If the @type-matching memory should be filtered out. +* @matching: Whether this is for @type-matching memory. +* @allow: Whether to include or exclude the @matching memory. * @memcg_id: Memcg id of the question if @type is DAMOS_FILTER_MEMCG. * @addr_range: Address range if @type is DAMOS_FILTER_TYPE_ADDR. * @target_idx: Index of the &struct damon_target of
@@ -345,6 +346,7 @@ enum damos_filter_type {struct damos_filter {enum damos_filter_type type;bool matching; +bool allow;union {unsigned short memcg_id;struct damon_addr_range addr_range;
mm/damon/core.c +1 -0
@@ -275,6 +275,7 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type,return NULL ; filter->type = type; filter->matching = matching; + filter->allow = false;INIT_LIST_HEAD (&filter->list);return filter; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 3/4 mm/damon: add 'allow' argument to damos_new_filter()
In reply to Sasha LevinFrom: SeongJae Park <[email protected]>
[ Upstream commit e2fbfedad03401a38b8c3b7fd52d8fdcd039d0bc ]
DAMON API users should set damos_filter->allow manually to use a DAMOS allow-filter, since damos_new_filter() unsets the field always. It is cumbersome and easy to mistake. Add an arugment for setting the field to damos_new_filter().
Stable-dep-of: 28ab2265e942 ("mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()")
--- include/linux/damon.h | 2 +- mm/damon/core.c | 7 ++++--- mm/damon/paddr.c | 3 ++- mm/damon/reclaim.c | 2 +- mm/damon/sysfs-schemes.c | 2 +- mm/damon/tests/core-kunit.h | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-)
include/linux/damon.h +1 -1
@@ -728,7 +728,7 @@ void damon_update_region_access_rate(struct damon_region *r, bool accessed, struct damon_attrs *attrs);struct damos_filter *damos_new_filter (enum damos_filter_type type, -bool matching); +bool matching,bool allow);void damos_add_filter (struct damos *s,struct damos_filter *f);void damos_destroy_filter (struct damos_filter *f);
mm/damon/core.c +4 -3
@@ -266,7 +266,7 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, }struct damos_filter *damos_new_filter (enum damos_filter_type type, -bool matching) +bool matching,bool allow) {struct damos_filter *filter;
@@ -275,7 +275,7 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type,return NULL ; filter->type = type; filter->matching = matching; - filter->allow = false; + filter->allow = allow;INIT_LIST_HEAD (&filter->list);return filter; }
@@ -804,7 +804,8 @@ static int damos_commit_filters(struct damos *dst, struct damos *src)continue ; new_filter =damos_new_filter ( - src_filter->type, src_filter->matching); + src_filter->type, src_filter->matching, + src_filter->allow);if (!new_filter)return -ENOMEM ;damos_commit_filter_arg (new_filter, src_filter);
mm/damon/paddr.c +2 -1
@@ -258,7 +258,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s) } }if (install_young_filter) { - filter =damos_new_filter (DAMOS_FILTER_TYPE_YOUNG , true); + filter =damos_new_filter ( +DAMOS_FILTER_TYPE_YOUNG , true, false);if (!filter)return 0 ;damos_add_filter (s, filter);
mm/damon/reclaim.c +1 -1
@@ -226,7 +226,7 @@ static int damon_reclaim_apply_parameters(void) }if (skip_anon) { - filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true); + filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true, false);if (!filter) goto out;damos_add_filter (scheme, filter);
mm/damon/sysfs-schemes.c +1 -1
@@ -1919,7 +1919,7 @@ static int damon_sysfs_add_scheme_filters(struct damos *scheme, sysfs_filters->filters_arr[i];struct damos_filter *filter =damos_new_filter (sysfs_filter->type, - sysfs_filter->matching); + sysfs_filter->matching, false);int err;if (!filter)
mm/damon/tests/core-kunit.h +2 -2
@@ -411,7 +411,7 @@ static void damos_test_new_filter(struct kunit *test) {struct damos_filter *filter; - filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true); + filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true, false);KUNIT_EXPECT_EQ (test, filter->type,DAMOS_FILTER_TYPE_ANON );KUNIT_EXPECT_EQ (test, filter->matching, true);KUNIT_EXPECT_PTR_EQ (test, filter->list.prev, &filter->list);
@@ -425,7 +425,7 @@ static void damos_test_filter_out(struct kunit *test)struct damon_region *r, *r2;struct damos_filter *f; - f =damos_new_filter (DAMOS_FILTER_TYPE_ADDR , true); + f =damos_new_filter (DAMOS_FILTER_TYPE_ADDR , true, false); f->addr_range = (struct damon_addr_range ){ .start =DAMON_MIN_REGION *2 , .end =DAMON_MIN_REGION *6 };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 4/4 mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()
In reply to Sasha LevinFrom: SeongJae Park <[email protected]>
[ Upstream commit 28ab2265e9422ccd81e4beafc0ace90f78de04c4 ]
damon_test_new_filter() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases.
--- mm/damon/tests/core-kunit.h | 2 ++ 1 file changed, 2 insertions(+)
mm/damon/tests/core-kunit.h +2 -0
@@ -412,6 +412,8 @@ static void damos_test_new_filter(struct kunit *test)struct damos_filter *filter; filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true, false); +if (!filter) +kunit_skip (test,"filter alloc fail" );KUNIT_EXPECT_EQ (test, filter->type,DAMOS_FILTER_TYPE_ANON );KUNIT_EXPECT_EQ (test, filter->matching, true);KUNIT_EXPECT_PTR_EQ (test, filter->list.prev, &filter->list);
Signature · 1 line
2.51.0
SeongJae Park
maintainerPATCH 1/1 mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()
In reply to [email protected]damon_test_new_filter() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases.
--- mm/damon/tests/core-kunit.h | 2 ++ 1 file changed, 2 insertions(+)
mm/damon/tests/core-kunit.h +2 -0
@@ -412,6 +412,8 @@ static void damos_test_new_filter(struct kunit *test)struct damos_filter *filter; filter =damos_new_filter (DAMOS_FILTER_TYPE_ANON , true); +if (!filter) +kunit_skip (test,"filter alloc fail" );KUNIT_EXPECT_EQ (test, filter->type,DAMOS_FILTER_TYPE_ANON );KUNIT_EXPECT_EQ (test, filter->matching, true);KUNIT_EXPECT_PTR_EQ (test, filter->list.prev, &filter->list);
Signature · 1 line
2.47.3