Skip to content

Commit 3aaa8ce

Browse files
committed
Merge tag 'mm-hotfixes-stable-2024-03-07-16-17' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "6 hotfixes. 4 are cc:stable and the remainder pertain to post-6.7 issues or aren't considered to be needed in earlier kernel versions" * tag 'mm-hotfixes-stable-2024-03-07-16-17' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: scripts/gdb/symbols: fix invalid escape sequence warning mailmap: fix Kishon's email init/Kconfig: lower GCC version check for -Warray-bounds mm, mmap: fix vma_merge() case 7 with vma_ops->close mm: userfaultfd: fix unexpected change to src_folio when UFFDIO_MOVE fails mm, vmscan: prevent infinite loop for costly GFP_NOIO | __GFP_RETRY_MAYFAIL allocations
2 parents c381c89 + ded79af commit 3aaa8ce

File tree

9 files changed

+37
-19
lines changed

9 files changed

+37
-19
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ Kenneth W Chen <kenneth.w.chen@intel.com>
325325
Kenneth Westfield <quic_kwestfie@quicinc.com> <kwestfie@codeaurora.org>
326326
Kiran Gunda <quic_kgunda@quicinc.com> <kgunda@codeaurora.org>
327327
Kirill Tkhai <tkhai@ya.ru> <ktkhai@virtuozzo.com>
328+
Kishon Vijay Abraham I <kishon@kernel.org> <kishon@ti.com>
328329
Konstantin Khlebnikov <koct9i@gmail.com> <khlebnikov@yandex-team.ru>
329330
Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com>
330331
Koushik <raghavendra.koushik@neterion.com>

include/linux/gfp.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,15 @@ static inline bool gfp_has_io_fs(gfp_t gfp)
353353
return (gfp & (__GFP_IO | __GFP_FS)) == (__GFP_IO | __GFP_FS);
354354
}
355355

356+
/*
357+
* Check if the gfp flags allow compaction - GFP_NOIO is a really
358+
* tricky context because the migration might require IO.
359+
*/
360+
static inline bool gfp_compaction_allowed(gfp_t gfp_mask)
361+
{
362+
return IS_ENABLED(CONFIG_COMPACTION) && (gfp_mask & __GFP_IO);
363+
}
364+
356365
extern gfp_t vma_thp_gfp_mask(struct vm_area_struct *vma);
357366

358367
#ifdef CONFIG_CONTIG_ALLOC

init/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,14 +876,14 @@ config CC_IMPLICIT_FALLTHROUGH
876876
default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5)
877877
default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough)
878878

879-
# Currently, disable gcc-11+ array-bounds globally.
879+
# Currently, disable gcc-10+ array-bounds globally.
880880
# It's still broken in gcc-13, so no upper bound yet.
881-
config GCC11_NO_ARRAY_BOUNDS
881+
config GCC10_NO_ARRAY_BOUNDS
882882
def_bool y
883883

884884
config CC_NO_ARRAY_BOUNDS
885885
bool
886-
default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC11_NO_ARRAY_BOUNDS
886+
default y if CC_IS_GCC && GCC_VERSION >= 100000 && GCC10_NO_ARRAY_BOUNDS
887887

888888
# Currently, disable -Wstringop-overflow for GCC globally.
889889
config GCC_NO_STRINGOP_OVERFLOW

mm/compaction.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,16 +2723,11 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
27232723
unsigned int alloc_flags, const struct alloc_context *ac,
27242724
enum compact_priority prio, struct page **capture)
27252725
{
2726-
int may_perform_io = (__force int)(gfp_mask & __GFP_IO);
27272726
struct zoneref *z;
27282727
struct zone *zone;
27292728
enum compact_result rc = COMPACT_SKIPPED;
27302729

2731-
/*
2732-
* Check if the GFP flags allow compaction - GFP_NOIO is really
2733-
* tricky context because the migration might require IO
2734-
*/
2735-
if (!may_perform_io)
2730+
if (!gfp_compaction_allowed(gfp_mask))
27362731
return COMPACT_SKIPPED;
27372732

27382733
trace_mm_compaction_try_to_compact_pages(order, gfp_mask, prio);

mm/mmap.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,13 +954,21 @@ static struct vm_area_struct
954954
} else if (merge_prev) { /* case 2 */
955955
if (curr) {
956956
vma_start_write(curr);
957-
err = dup_anon_vma(prev, curr, &anon_dup);
958957
if (end == curr->vm_end) { /* case 7 */
958+
/*
959+
* can_vma_merge_after() assumed we would not be
960+
* removing prev vma, so it skipped the check
961+
* for vm_ops->close, but we are removing curr
962+
*/
963+
if (curr->vm_ops && curr->vm_ops->close)
964+
err = -EINVAL;
959965
remove = curr;
960966
} else { /* case 5 */
961967
adjust = curr;
962968
adj_start = (end - curr->vm_start);
963969
}
970+
if (!err)
971+
err = dup_anon_vma(prev, curr, &anon_dup);
964972
}
965973
} else { /* merge_next */
966974
vma_start_write(next);

mm/page_alloc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,6 +4041,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
40414041
struct alloc_context *ac)
40424042
{
40434043
bool can_direct_reclaim = gfp_mask & __GFP_DIRECT_RECLAIM;
4044+
bool can_compact = gfp_compaction_allowed(gfp_mask);
40444045
const bool costly_order = order > PAGE_ALLOC_COSTLY_ORDER;
40454046
struct page *page = NULL;
40464047
unsigned int alloc_flags;
@@ -4111,7 +4112,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
41114112
* Don't try this for allocations that are allowed to ignore
41124113
* watermarks, as the ALLOC_NO_WATERMARKS attempt didn't yet happen.
41134114
*/
4114-
if (can_direct_reclaim &&
4115+
if (can_direct_reclaim && can_compact &&
41154116
(costly_order ||
41164117
(order > 0 && ac->migratetype != MIGRATE_MOVABLE))
41174118
&& !gfp_pfmemalloc_allowed(gfp_mask)) {
@@ -4209,9 +4210,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
42094210

42104211
/*
42114212
* Do not retry costly high order allocations unless they are
4212-
* __GFP_RETRY_MAYFAIL
4213+
* __GFP_RETRY_MAYFAIL and we can compact
42134214
*/
4214-
if (costly_order && !(gfp_mask & __GFP_RETRY_MAYFAIL))
4215+
if (costly_order && (!can_compact ||
4216+
!(gfp_mask & __GFP_RETRY_MAYFAIL)))
42154217
goto nopage;
42164218

42174219
if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
@@ -4224,7 +4226,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
42244226
* implementation of the compaction depends on the sufficient amount
42254227
* of free memory (see __compaction_suitable)
42264228
*/
4227-
if (did_some_progress > 0 &&
4229+
if (did_some_progress > 0 && can_compact &&
42284230
should_compact_retry(ac, order, alloc_flags,
42294231
compact_result, &compact_priority,
42304232
&compaction_retries))

mm/userfaultfd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,6 @@ static int move_present_pte(struct mm_struct *mm,
914914
goto out;
915915
}
916916

917-
folio_move_anon_rmap(src_folio, dst_vma);
918-
WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
919-
920917
orig_src_pte = ptep_clear_flush(src_vma, src_addr, src_pte);
921918
/* Folio got pinned from under us. Put it back and fail the move. */
922919
if (folio_maybe_dma_pinned(src_folio)) {
@@ -925,6 +922,9 @@ static int move_present_pte(struct mm_struct *mm,
925922
goto out;
926923
}
927924

925+
folio_move_anon_rmap(src_folio, dst_vma);
926+
WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
927+
928928
orig_dst_pte = mk_pte(&src_folio->page, dst_vma->vm_page_prot);
929929
/* Follow mremap() behavior and treat the entry dirty after the move */
930930
orig_dst_pte = pte_mkwrite(pte_mkdirty(orig_dst_pte), dst_vma);

mm/vmscan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5753,7 +5753,7 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
57535753
/* Use reclaim/compaction for costly allocs or under memory pressure */
57545754
static bool in_reclaim_compaction(struct scan_control *sc)
57555755
{
5756-
if (IS_ENABLED(CONFIG_COMPACTION) && sc->order &&
5756+
if (gfp_compaction_allowed(sc->gfp_mask) && sc->order &&
57575757
(sc->order > PAGE_ALLOC_COSTLY_ORDER ||
57585758
sc->priority < DEF_PRIORITY - 2))
57595759
return true;
@@ -5998,6 +5998,9 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)
59985998
{
59995999
unsigned long watermark;
60006000

6001+
if (!gfp_compaction_allowed(sc->gfp_mask))
6002+
return false;
6003+
60016004
/* Allocation can already succeed, nothing to do */
60026005
if (zone_watermark_ok(zone, sc->order, min_wmark_pages(zone),
60036006
sc->reclaim_idx, 0))

scripts/gdb/linux/symbols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _update_module_files(self):
8282
self.module_files_updated = True
8383

8484
def _get_module_file(self, module_name):
85-
module_pattern = ".*/{0}\.ko(?:.debug)?$".format(
85+
module_pattern = r".*/{0}\.ko(?:.debug)?$".format(
8686
module_name.replace("_", r"[_\-]"))
8787
for name in self.module_files:
8888
if re.match(module_pattern, name) and os.path.exists(name):

0 commit comments

Comments
 (0)