* FAILED: patch "[PATCH] mm/damon/tests/core-kunit: handle alloc failres in" failed to apply to 6.12-stable tree
@ 2026-01-05 11:03 gregkh
2026-01-06 0:55 ` [PATCH 6.12.y 1/4] mm/damon: fixup damos_filter kernel-doc Sasha Levin
2026-01-06 1:45 ` [PATCH 6.12.y] " SeongJae Park
0 siblings, 2 replies; 6+ messages in thread
From: gregkh @ 2026-01-05 11:03 UTC (permalink / raw)
To: sj, akpm, brendan.higgins, davidgow, stable, wangkefeng.wang; +Cc: stable
The 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 <stable@vger.kernel.org>.
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 '<stable@vger.kernel.org>' --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 <sj@kernel.org>
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.
Link: https://lkml.kernel.org/r/20251101182021.74868-14-sj@kernel.org
Fixes: 2a158e956b98 ("mm/damon/core-test: add a test for damos_new_filter()")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: <stable@vger.kernel.org> [6.6+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index b9bd69a57e62..03c7ac31db5c 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -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);
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 6.12.y 1/4] mm/damon: fixup damos_filter kernel-doc 2026-01-05 11:03 FAILED: patch "[PATCH] mm/damon/tests/core-kunit: handle alloc failres in" failed to apply to 6.12-stable tree gregkh @ 2026-01-06 0:55 ` Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 2/4] mm/damon/core: add damos_filter->allow field Sasha Levin ` (2 more replies) 2026-01-06 1:45 ` [PATCH 6.12.y] " SeongJae Park 1 sibling, 3 replies; 6+ messages in thread From: Sasha Levin @ 2026-01-06 0:55 UTC (permalink / raw) To: stable; +Cc: SeongJae Park, Jonathan Corbet, Andrew Morton, Sasha Levin From: SeongJae Park <sj@kernel.org> [ 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/20240320165619.71478-1-sj@kernel.org 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. Link: https://lkml.kernel.org/r/20250109175126.57878-1-sj@kernel.org Link: https://lkml.kernel.org/r/20250109175126.57878-2-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Stable-dep-of: 28ab2265e942 ("mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- include/linux/damon.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index a67f2c4940e9..0078912823d2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -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; -- 2.51.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.12.y 2/4] mm/damon/core: add damos_filter->allow field 2026-01-06 0:55 ` [PATCH 6.12.y 1/4] mm/damon: fixup damos_filter kernel-doc Sasha Levin @ 2026-01-06 0:55 ` Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 3/4] mm/damon: add 'allow' argument to damos_new_filter() Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 4/4] mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter() Sasha Levin 2 siblings, 0 replies; 6+ messages in thread From: Sasha Levin @ 2026-01-06 0:55 UTC (permalink / raw) To: stable; +Cc: SeongJae Park, Jonathan Corbet, Andrew Morton, Sasha Levin From: SeongJae Park <sj@kernel.org> [ 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. Link: https://lkml.kernel.org/r/20250109175126.57878-3-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Stable-dep-of: 28ab2265e942 ("mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- include/linux/damon.h | 4 +++- mm/damon/core.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 0078912823d2..0da1397cd719 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -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; diff --git a/mm/damon/core.c b/mm/damon/core.c index ed2b75023181..17a9fe18c069 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -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; } -- 2.51.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.12.y 3/4] mm/damon: add 'allow' argument to damos_new_filter() 2026-01-06 0:55 ` [PATCH 6.12.y 1/4] mm/damon: fixup damos_filter kernel-doc Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 2/4] mm/damon/core: add damos_filter->allow field Sasha Levin @ 2026-01-06 0:55 ` Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 4/4] mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter() Sasha Levin 2 siblings, 0 replies; 6+ messages in thread From: Sasha Levin @ 2026-01-06 0:55 UTC (permalink / raw) To: stable; +Cc: SeongJae Park, Jonathan Corbet, Andrew Morton, Sasha Levin From: SeongJae Park <sj@kernel.org> [ 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(). Link: https://lkml.kernel.org/r/20250109175126.57878-6-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Stable-dep-of: 28ab2265e942 ("mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- 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(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 0da1397cd719..58aff70fd622 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -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); diff --git a/mm/damon/core.c b/mm/damon/core.c index 17a9fe18c069..5017ba453688 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -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); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 4120a73f4933..f9a0a6eb6630 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -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); diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 65842e6854fd..ade3ff724b24 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -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); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index d9e01648db70..5893b40dcd1f 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -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) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index cf22e09a3507..2329158c6f5d 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -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}; -- 2.51.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.12.y 4/4] mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter() 2026-01-06 0:55 ` [PATCH 6.12.y 1/4] mm/damon: fixup damos_filter kernel-doc Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 2/4] mm/damon/core: add damos_filter->allow field Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 3/4] mm/damon: add 'allow' argument to damos_new_filter() Sasha Levin @ 2026-01-06 0:55 ` Sasha Levin 2 siblings, 0 replies; 6+ messages in thread From: Sasha Levin @ 2026-01-06 0:55 UTC (permalink / raw) To: stable Cc: SeongJae Park, Brendan Higgins, David Gow, Kefeng Wang, Andrew Morton, Sasha Levin From: SeongJae Park <sj@kernel.org> [ 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. Link: https://lkml.kernel.org/r/20251101182021.74868-14-sj@kernel.org Fixes: 2a158e956b98 ("mm/damon/core-test: add a test for damos_new_filter()") Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Brendan Higgins <brendan.higgins@linux.dev> Cc: David Gow <davidgow@google.com> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: <stable@vger.kernel.org> [6.6+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- mm/damon/tests/core-kunit.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 2329158c6f5d..cd27f0e8f840 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -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); -- 2.51.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.12.y] mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter() 2026-01-05 11:03 FAILED: patch "[PATCH] mm/damon/tests/core-kunit: handle alloc failres in" failed to apply to 6.12-stable tree gregkh 2026-01-06 0:55 ` [PATCH 6.12.y 1/4] mm/damon: fixup damos_filter kernel-doc Sasha Levin @ 2026-01-06 1:45 ` SeongJae Park 1 sibling, 0 replies; 6+ messages in thread From: SeongJae Park @ 2026-01-06 1:45 UTC (permalink / raw) To: stable Cc: damon, SeongJae Park, Brendan Higgins, David Gow, Kefeng Wang, Andrew Morton 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. Link: https://lkml.kernel.org/r/20251101182021.74868-14-sj@kernel.org Fixes: 2a158e956b98 ("mm/damon/core-test: add a test for damos_new_filter()") Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Brendan Higgins <brendan.higgins@linux.dev> Cc: David Gow <davidgow@google.com> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: <stable@vger.kernel.org> [6.6+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit 28ab2265e9422ccd81e4beafc0ace90f78de04c4) Signed-off-by: SeongJae Park <sj@kernel.org> --- mm/damon/tests/core-kunit.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index cf22e09a3507..28f88cc27517 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -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); -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-06 1:45 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-05 11:03 FAILED: patch "[PATCH] mm/damon/tests/core-kunit: handle alloc failres in" failed to apply to 6.12-stable tree gregkh 2026-01-06 0:55 ` [PATCH 6.12.y 1/4] mm/damon: fixup damos_filter kernel-doc Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 2/4] mm/damon/core: add damos_filter->allow field Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 3/4] mm/damon: add 'allow' argument to damos_new_filter() Sasha Levin 2026-01-06 0:55 ` [PATCH 6.12.y 4/4] mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter() Sasha Levin 2026-01-06 1:45 ` [PATCH 6.12.y] " SeongJae Park
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox