From: Greg Kroah-Hartman Date: Wed, 20 Nov 2024 12:52:20 +0000 (+0100) Subject: 6.6-stable patches X-Git-Tag: v6.12.1~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6cbd708a569bdb231c8125c8fc8a8140dfa5e20;p=thirdparty%2Fkernel%2Fstable-queue.git 6.6-stable patches added patches: mm-damon-core-check-apply-interval-in-damon_do_apply_schemes.patch mm-damon-core-copy-nr_accesses-when-splitting-region.patch mm-damon-core-handle-zero-schemes-apply-interval.patch --- diff --git a/queue-6.6/mm-avoid-unsafe-vma-hook-invocation-when-error-arises-on-mmap-hook.patch b/queue-6.6/mm-avoid-unsafe-vma-hook-invocation-when-error-arises-on-mmap-hook.patch index b76b05264f9..f54114a6c96 100644 --- a/queue-6.6/mm-avoid-unsafe-vma-hook-invocation-when-error-arises-on-mmap-hook.patch +++ b/queue-6.6/mm-avoid-unsafe-vma-hook-invocation-when-error-arises-on-mmap-hook.patch @@ -4,7 +4,6 @@ Date: Fri, 15 Nov 2024 12:41:54 +0000 Subject: mm: avoid unsafe VMA hook invocation when error arises on mmap hook To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller -Message-ID: <33d70849ec62ba738ca2f8db58fe24076d5282bf.1731672733.git.lorenzo.stoakes@oracle.com> From: Lorenzo Stoakes diff --git a/queue-6.6/mm-damon-core-check-apply-interval-in-damon_do_apply_schemes.patch b/queue-6.6/mm-damon-core-check-apply-interval-in-damon_do_apply_schemes.patch new file mode 100644 index 00000000000..dd825c4983e --- /dev/null +++ b/queue-6.6/mm-damon-core-check-apply-interval-in-damon_do_apply_schemes.patch @@ -0,0 +1,64 @@ +From e9e3db69966d5e9e6f7e7d017b407c0025180fe5 Mon Sep 17 00:00:00 2001 +From: SeongJae Park +Date: Mon, 5 Feb 2024 12:13:06 -0800 +Subject: mm/damon/core: check apply interval in damon_do_apply_schemes() + +From: SeongJae Park + +commit e9e3db69966d5e9e6f7e7d017b407c0025180fe5 upstream. + +kdamond_apply_schemes() checks apply intervals of schemes and avoid +further applying any schemes if no scheme passed its apply interval. +However, the following schemes applying function, damon_do_apply_schemes() +iterates all schemes without the apply interval check. As a result, the +shortest apply interval is applied to all schemes. Fix the problem by +checking the apply interval in damon_do_apply_schemes(). + +Link: https://lkml.kernel.org/r/20240205201306.88562-1-sj@kernel.org +Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval") +Signed-off-by: SeongJae Park +Cc: [6.7.x] +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + mm/damon/core.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +--- a/mm/damon/core.c ++++ b/mm/damon/core.c +@@ -989,6 +989,9 @@ static void damon_do_apply_schemes(struc + damon_for_each_scheme(s, c) { + struct damos_quota *quota = &s->quota; + ++ if (c->passed_sample_intervals != s->next_apply_sis) ++ continue; ++ + if (!s->wmarks.activated) + continue; + +@@ -1089,10 +1092,6 @@ static void kdamond_apply_schemes(struct + if (c->passed_sample_intervals != s->next_apply_sis) + continue; + +- s->next_apply_sis += +- (s->apply_interval_us ? s->apply_interval_us : +- c->attrs.aggr_interval) / sample_interval; +- + if (!s->wmarks.activated) + continue; + +@@ -1108,6 +1107,14 @@ static void kdamond_apply_schemes(struct + damon_for_each_region_safe(r, next_r, t) + damon_do_apply_schemes(c, t, r); + } ++ ++ damon_for_each_scheme(s, c) { ++ if (c->passed_sample_intervals != s->next_apply_sis) ++ continue; ++ s->next_apply_sis += ++ (s->apply_interval_us ? s->apply_interval_us : ++ c->attrs.aggr_interval) / sample_interval; ++ } + } + + /* diff --git a/queue-6.6/mm-damon-core-copy-nr_accesses-when-splitting-region.patch b/queue-6.6/mm-damon-core-copy-nr_accesses-when-splitting-region.patch new file mode 100644 index 00000000000..11bc7c0f74d --- /dev/null +++ b/queue-6.6/mm-damon-core-copy-nr_accesses-when-splitting-region.patch @@ -0,0 +1,40 @@ +From 1f3730fd9e8d4d77fb99c60d0e6ad4b1104e7e04 Mon Sep 17 00:00:00 2001 +From: SeongJae Park +Date: Sun, 19 Nov 2023 17:15:28 +0000 +Subject: mm/damon/core: copy nr_accesses when splitting region + +From: SeongJae Park + +commit 1f3730fd9e8d4d77fb99c60d0e6ad4b1104e7e04 upstream. + +Regions split function ('damon_split_region_at()') is called at the +beginning of an aggregation interval, and when DAMOS applying the actions +and charging quota. Because 'nr_accesses' fields of all regions are reset +at the beginning of each aggregation interval, and DAMOS was applying the +action at the end of each aggregation interval, there was no need to copy +the 'nr_accesses' field to the split-out region. + +However, commit 42f994b71404 ("mm/damon/core: implement scheme-specific +apply interval") made DAMOS applies action on its own timing interval. +Hence, 'nr_accesses' should also copied to split-out regions, but the +commit didn't. Fix it by copying it. + +Link: https://lkml.kernel.org/r/20231119171529.66863-1-sj@kernel.org +Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval") +Signed-off-by: SeongJae Park +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + mm/damon/core.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/mm/damon/core.c ++++ b/mm/damon/core.c +@@ -1215,6 +1215,7 @@ static void damon_split_region_at(struct + + new->age = r->age; + new->last_nr_accesses = r->last_nr_accesses; ++ new->nr_accesses = r->nr_accesses; + + damon_insert_region(new, r, damon_next_region(r), t); + } diff --git a/queue-6.6/mm-damon-core-handle-zero-schemes-apply-interval.patch b/queue-6.6/mm-damon-core-handle-zero-schemes-apply-interval.patch new file mode 100644 index 00000000000..e691a4acb71 --- /dev/null +++ b/queue-6.6/mm-damon-core-handle-zero-schemes-apply-interval.patch @@ -0,0 +1,70 @@ +From 8e7bde615f634a82a44b1f3d293c049fd3ef9ca9 Mon Sep 17 00:00:00 2001 +From: SeongJae Park +Date: Thu, 31 Oct 2024 11:37:57 -0700 +Subject: mm/damon/core: handle zero schemes apply interval + +From: SeongJae Park + +commit 8e7bde615f634a82a44b1f3d293c049fd3ef9ca9 upstream. + +DAMON's logics to determine if this is the time to apply damos schemes +assumes next_apply_sis is always set larger than current +passed_sample_intervals. And therefore assume continuously incrementing +passed_sample_intervals will make it reaches to the next_apply_sis in +future. The logic hence does apply the scheme and update next_apply_sis +only if passed_sample_intervals is same to next_apply_sis. + +If Schemes apply interval is set as zero, however, next_apply_sis is set +same to current passed_sample_intervals, respectively. And +passed_sample_intervals is incremented before doing the next_apply_sis +check. Hence, next_apply_sis becomes larger than next_apply_sis, and the +logic says it is not the time to apply schemes and update next_apply_sis. +In other words, DAMON stops applying schemes until passed_sample_intervals +overflows. + +Based on the documents and the common sense, a reasonable behavior for +such inputs would be applying the schemes for every sampling interval. +Handle the case by removing the assumption. + +Link: https://lkml.kernel.org/r/20241031183757.49610-3-sj@kernel.org +Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval") +Signed-off-by: SeongJae Park +Cc: [6.7.x] +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + mm/damon/core.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/mm/damon/core.c ++++ b/mm/damon/core.c +@@ -989,7 +989,7 @@ static void damon_do_apply_schemes(struc + damon_for_each_scheme(s, c) { + struct damos_quota *quota = &s->quota; + +- if (c->passed_sample_intervals != s->next_apply_sis) ++ if (c->passed_sample_intervals < s->next_apply_sis) + continue; + + if (!s->wmarks.activated) +@@ -1089,7 +1089,7 @@ static void kdamond_apply_schemes(struct + bool has_schemes_to_apply = false; + + damon_for_each_scheme(s, c) { +- if (c->passed_sample_intervals != s->next_apply_sis) ++ if (c->passed_sample_intervals < s->next_apply_sis) + continue; + + if (!s->wmarks.activated) +@@ -1109,9 +1109,9 @@ static void kdamond_apply_schemes(struct + } + + damon_for_each_scheme(s, c) { +- if (c->passed_sample_intervals != s->next_apply_sis) ++ if (c->passed_sample_intervals < s->next_apply_sis) + continue; +- s->next_apply_sis += ++ s->next_apply_sis = c->passed_sample_intervals + + (s->apply_interval_us ? s->apply_interval_us : + c->attrs.aggr_interval) / sample_interval; + } diff --git a/queue-6.6/mm-refactor-arch_calc_vm_flag_bits-and-arm64-mte-handling.patch b/queue-6.6/mm-refactor-arch_calc_vm_flag_bits-and-arm64-mte-handling.patch index 1d3827fad5d..ddffd0c45e8 100644 --- a/queue-6.6/mm-refactor-arch_calc_vm_flag_bits-and-arm64-mte-handling.patch +++ b/queue-6.6/mm-refactor-arch_calc_vm_flag_bits-and-arm64-mte-handling.patch @@ -4,7 +4,6 @@ Date: Fri, 15 Nov 2024 12:41:57 +0000 Subject: mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller -Message-ID: <7c0218d03fd2119025d8cbc1b814639cf09314e0.1731672733.git.lorenzo.stoakes@oracle.com> From: Lorenzo Stoakes diff --git a/queue-6.6/mm-refactor-map_deny_write_exec.patch b/queue-6.6/mm-refactor-map_deny_write_exec.patch index 3e6ab9c0442..01059b6f3df 100644 --- a/queue-6.6/mm-refactor-map_deny_write_exec.patch +++ b/queue-6.6/mm-refactor-map_deny_write_exec.patch @@ -4,7 +4,6 @@ Date: Fri, 15 Nov 2024 12:41:56 +0000 Subject: mm: refactor map_deny_write_exec() To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller -Message-ID: From: Lorenzo Stoakes diff --git a/queue-6.6/mm-resolve-faulty-mmap_region-error-path-behaviour.patch b/queue-6.6/mm-resolve-faulty-mmap_region-error-path-behaviour.patch index 03778a50743..7d563675013 100644 --- a/queue-6.6/mm-resolve-faulty-mmap_region-error-path-behaviour.patch +++ b/queue-6.6/mm-resolve-faulty-mmap_region-error-path-behaviour.patch @@ -4,7 +4,6 @@ Date: Fri, 15 Nov 2024 12:41:58 +0000 Subject: mm: resolve faulty mmap_region() error path behaviour To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller -Message-ID: From: Lorenzo Stoakes diff --git a/queue-6.6/mm-unconditionally-close-vmas-on-error.patch b/queue-6.6/mm-unconditionally-close-vmas-on-error.patch index 5e96fd260b7..4c605096908 100644 --- a/queue-6.6/mm-unconditionally-close-vmas-on-error.patch +++ b/queue-6.6/mm-unconditionally-close-vmas-on-error.patch @@ -4,7 +4,6 @@ Date: Fri, 15 Nov 2024 12:41:55 +0000 Subject: mm: unconditionally close VMAs on error To: stable@vger.kernel.org Cc: Andrew Morton , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Peter Xu , Catalin Marinas , Will Deacon , Mark Brown , "David S . Miller" , Andreas Larsson , "James E . J . Bottomley" , Helge Deller -Message-ID: From: Lorenzo Stoakes diff --git a/queue-6.6/series b/queue-6.6/series index aa2ddefd17a..0f7659b93b2 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -77,3 +77,6 @@ mm-unconditionally-close-vmas-on-error.patch mm-refactor-map_deny_write_exec.patch mm-refactor-arch_calc_vm_flag_bits-and-arm64-mte-handling.patch mm-resolve-faulty-mmap_region-error-path-behaviour.patch +mm-damon-core-check-apply-interval-in-damon_do_apply_schemes.patch +mm-damon-core-handle-zero-schemes-apply-interval.patch +mm-damon-core-copy-nr_accesses-when-splitting-region.patch