Skip to content

Commit c1f49de

Browse files
committed
Merge tag 'mm-hotfixes-stable-2026-04-19-00-14' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull MM fixes from Andrew Morton: "7 hotfixes. 6 are cc:stable and all are for MM. Please see the individual changelogs for details" * tag 'mm-hotfixes-stable-2026-04-19-00-14' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: mm/damon/core: disallow non-power of two min_region_sz on damon_start() mm/vmalloc: take vmap_purge_lock in shrinker mm: call ->free_folio() directly in folio_unmap_invalidate() mm: blk-cgroup: fix use-after-free in cgwb_release_workfn() mm/zone_device: do not touch device folio after calling ->folio_free() mm/damon/core: disallow time-quota setting zero esz mm/mempolicy: fix weighted interleave auto sysfs name
2 parents 8c2bf4a + 95093e5 commit c1f49de

8 files changed

Lines changed: 27 additions & 12 deletions

File tree

mm/backing-dev.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,13 @@ static void cgwb_release_workfn(struct work_struct *work)
618618
wb_shutdown(wb);
619619

620620
css_put(wb->memcg_css);
621-
css_put(wb->blkcg_css);
622-
mutex_unlock(&wb->bdi->cgwb_release_mutex);
623621

624622
/* triggers blkg destruction if no online users left */
625623
blkcg_unpin_online(wb->blkcg_css);
626624

625+
css_put(wb->blkcg_css);
626+
mutex_unlock(&wb->bdi->cgwb_release_mutex);
627+
627628
fprop_local_destroy_percpu(&wb->memcg_completions);
628629

629630
spin_lock_irq(&cgwb_lock);

mm/damon/core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,11 @@ int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive)
14771477
int i;
14781478
int err = 0;
14791479

1480+
for (i = 0; i < nr_ctxs; i++) {
1481+
if (!is_power_of_2(ctxs[i]->min_region_sz))
1482+
return -EINVAL;
1483+
}
1484+
14801485
mutex_lock(&damon_lock);
14811486
if ((exclusive && nr_running_ctxs) ||
14821487
(!exclusive && running_exclusive_ctxs)) {
@@ -2384,7 +2389,8 @@ static void damos_goal_tune_esz_bp_temporal(struct damos_quota *quota)
23842389
/*
23852390
* Called only if quota->ms, or quota->sz are set, or quota->goals is not empty
23862391
*/
2387-
static void damos_set_effective_quota(struct damos_quota *quota)
2392+
static void damos_set_effective_quota(struct damos_quota *quota,
2393+
struct damon_ctx *ctx)
23882394
{
23892395
unsigned long throughput;
23902396
unsigned long esz = ULONG_MAX;
@@ -2409,6 +2415,7 @@ static void damos_set_effective_quota(struct damos_quota *quota)
24092415
else
24102416
throughput = PAGE_SIZE * 1024;
24112417
esz = min(throughput * quota->ms, esz);
2418+
esz = max(ctx->min_region_sz, esz);
24122419
}
24132420

24142421
if (quota->sz && quota->sz < esz)
@@ -2445,7 +2452,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
24452452
/* First charge window */
24462453
if (!quota->total_charged_sz && !quota->charged_from) {
24472454
quota->charged_from = jiffies;
2448-
damos_set_effective_quota(quota);
2455+
damos_set_effective_quota(quota, c);
24492456
}
24502457

24512458
/* New charge window starts */
@@ -2460,7 +2467,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
24602467
quota->charged_sz = 0;
24612468
if (trace_damos_esz_enabled())
24622469
cached_esz = quota->esz;
2463-
damos_set_effective_quota(quota);
2470+
damos_set_effective_quota(quota, c);
24642471
if (trace_damos_esz_enabled() && quota->esz != cached_esz)
24652472
damos_trace_esz(c, s, quota);
24662473
}

mm/filemap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ void __filemap_remove_folio(struct folio *folio, void *shadow)
228228
page_cache_delete(mapping, folio, shadow);
229229
}
230230

231-
void filemap_free_folio(struct address_space *mapping, struct folio *folio)
231+
static void filemap_free_folio(const struct address_space *mapping,
232+
struct folio *folio)
232233
{
233234
void (*free_folio)(struct folio *);
234235

mm/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t *start,
557557
pgoff_t end, struct folio_batch *fbatch, pgoff_t *indices);
558558
unsigned find_get_entries(struct address_space *mapping, pgoff_t *start,
559559
pgoff_t end, struct folio_batch *fbatch, pgoff_t *indices);
560-
void filemap_free_folio(struct address_space *mapping, struct folio *folio);
561560
int truncate_inode_folio(struct address_space *mapping, struct folio *folio);
562561
bool truncate_inode_partial_folio(struct folio *folio, loff_t start,
563562
loff_t end);

mm/mempolicy.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3788,9 +3788,11 @@ static void wi_state_free(void)
37883788
}
37893789
}
37903790

3791-
static struct kobj_attribute wi_auto_attr =
3792-
__ATTR(auto, 0664, weighted_interleave_auto_show,
3793-
weighted_interleave_auto_store);
3791+
static struct kobj_attribute wi_auto_attr = {
3792+
.attr = { .name = "auto", .mode = 0664 },
3793+
.show = weighted_interleave_auto_show,
3794+
.store = weighted_interleave_auto_store,
3795+
};
37943796

37953797
static void wi_cleanup(void) {
37963798
sysfs_remove_file(&wi_group->wi_kobj, &wi_auto_attr.attr);

mm/memremap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void free_zone_device_folio(struct folio *folio)
454454
if (WARN_ON_ONCE(!pgmap->ops || !pgmap->ops->folio_free))
455455
break;
456456
pgmap->ops->folio_free(folio);
457-
percpu_ref_put_many(&folio->pgmap->ref, nr);
457+
percpu_ref_put_many(&pgmap->ref, nr);
458458
break;
459459

460460
case MEMORY_DEVICE_GENERIC:

mm/truncate.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ static int folio_launder(struct address_space *mapping, struct folio *folio)
622622
int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio,
623623
gfp_t gfp)
624624
{
625+
void (*free_folio)(struct folio *);
625626
int ret;
626627

627628
VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
@@ -648,9 +649,12 @@ int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio,
648649
xa_unlock_irq(&mapping->i_pages);
649650
if (mapping_shrinkable(mapping))
650651
inode_lru_list_add(mapping->host);
652+
free_folio = mapping->a_ops->free_folio;
651653
spin_unlock(&mapping->host->i_lock);
652654

653-
filemap_free_folio(mapping, folio);
655+
if (free_folio)
656+
free_folio(folio);
657+
folio_put_refs(folio, folio_nr_pages(folio));
654658
return 1;
655659
failed:
656660
xa_unlock_irq(&mapping->i_pages);

mm/vmalloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5416,6 +5416,7 @@ vmap_node_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
54165416
{
54175417
struct vmap_node *vn;
54185418

5419+
guard(mutex)(&vmap_purge_lock);
54195420
for_each_vmap_node(vn)
54205421
decay_va_pool_node(vn, true);
54215422

0 commit comments

Comments
 (0)