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
Unified · Split
| @@ -618,12 +618,13 @@ static void cgwb_release_workfn(struct work_struct *work) · 617 unmodified lines | |||
| 618 | wb_shutdown(wb); | 618 | wb_shutdown(wb); |
| 619 | 619 | ||
| 620 | css_put(wb->memcg_css); | 620 | css_put(wb->memcg_css); |
| 621 | css_put(wb->blkcg_css); | ||
| 622 | mutex_unlock(&wb->bdi->cgwb_release_mutex); | ||
| 623 | 621 | ||
| 624 | /* triggers blkg destruction if no online users left */ | 622 | /* triggers blkg destruction if no online users left */ |
| 625 | blkcg_unpin_online(wb->blkcg_css); | 623 | blkcg_unpin_online(wb->blkcg_css); |
| 626 | 624 | ||
| 625 | css_put(wb->blkcg_css); | ||
| 626 | mutex_unlock(&wb->bdi->cgwb_release_mutex); | ||
| 627 | |||
| 627 | fprop_local_destroy_percpu(&wb->memcg_completions); | 628 | fprop_local_destroy_percpu(&wb->memcg_completions); |
| 628 | 629 | ||
| 629 | spin_lock_irq(&cgwb_lock); | 630 | spin_lock_irq(&cgwb_lock); |
| @@ -1477,6 +1477,11 @@ int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive) · 1476 unmodified lines | |||
| 1477 | int i; | 1477 | int i; |
| 1478 | int err = 0; | 1478 | int err = 0; |
| 1479 | 1479 | ||
| 1480 | for (i = 0; i < nr_ctxs; i++) { | ||
| 1481 | if (!is_power_of_2(ctxs[i]->min_region_sz)) | ||
| 1482 | return -EINVAL; | ||
| 1483 | } | ||
| 1484 | |||
| 1480 | mutex_lock(&damon_lock); | 1485 | mutex_lock(&damon_lock); |
| 1481 | if ((exclusive && nr_running_ctxs) || | 1486 | if ((exclusive && nr_running_ctxs) || |
| 1482 | (!exclusive && running_exclusive_ctxs)) { | 1487 | (!exclusive && running_exclusive_ctxs)) { |
| @@ -2384,7 +2389,8 @@ static void damos_goal_tune_esz_bp_temporal(struct damos_quota *quota) · 901 unmodified lines | |||
| 2384 | /* | 2389 | /* |
| 2385 | * Called only if quota->ms, or quota->sz are set, or quota->goals is not empty | 2390 | * Called only if quota->ms, or quota->sz are set, or quota->goals is not empty |
| 2386 | */ | 2391 | */ |
| 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) | ||
| 2388 | { | 2394 | { |
| 2389 | unsigned long throughput; | 2395 | unsigned long throughput; |
| 2390 | unsigned long esz = ULONG_MAX; | 2396 | unsigned long esz = ULONG_MAX; |
| @@ -2409,6 +2415,7 @@ static void damos_set_effective_quota(struct damos_quota *quota) · 18 unmodified lines | |||
| 2409 | else | 2415 | else |
| 2410 | throughput = PAGE_SIZE * 1024; | 2416 | throughput = PAGE_SIZE * 1024; |
| 2411 | esz = min(throughput * quota->ms, esz); | 2417 | esz = min(throughput * quota->ms, esz); |
| 2418 | esz = max(ctx->min_region_sz, esz); | ||
| 2412 | } | 2419 | } |
| 2413 | 2420 | ||
| 2414 | if (quota->sz && quota->sz < esz) | 2421 | if (quota->sz && quota->sz < esz) |
| @@ -2445,7 +2452,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) · 30 unmodified lines | |||
| 2445 | /* First charge window */ | 2452 | /* First charge window */ |
| 2446 | if (!quota->total_charged_sz && !quota->charged_from) { | 2453 | if (!quota->total_charged_sz && !quota->charged_from) { |
| 2447 | quota->charged_from = jiffies; | 2454 | quota->charged_from = jiffies; |
| 2448 | damos_set_effective_quota(quota); | 2455 | damos_set_effective_quota(quota, c); |
| 2449 | } | 2456 | } |
| 2450 | 2457 | ||
| 2451 | /* New charge window starts */ | 2458 | /* New charge window starts */ |
| @@ -2460,7 +2467,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) · 8 unmodified lines | |||
| 2460 | quota->charged_sz = 0; | 2467 | quota->charged_sz = 0; |
| 2461 | if (trace_damos_esz_enabled()) | 2468 | if (trace_damos_esz_enabled()) |
| 2462 | cached_esz = quota->esz; | 2469 | cached_esz = quota->esz; |
| 2463 | damos_set_effective_quota(quota); | 2470 | damos_set_effective_quota(quota, c); |
| 2464 | if (trace_damos_esz_enabled() && quota->esz != cached_esz) | 2471 | if (trace_damos_esz_enabled() && quota->esz != cached_esz) |
| 2465 | damos_trace_esz(c, s, quota); | 2472 | damos_trace_esz(c, s, quota); |
| 2466 | } | 2473 | } |
| @@ -228,7 +228,8 @@ void __filemap_remove_folio(struct folio *folio, void *shadow) · 227 unmodified lines | |||
| 228 | page_cache_delete(mapping, folio, shadow); | 228 | page_cache_delete(mapping, folio, shadow); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 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) | ||
| 232 | { | 233 | { |
| 233 | void (*free_folio)(struct folio *); | 234 | void (*free_folio)(struct folio *); |
| 234 | 235 | ||
| @@ -557,7 +557,6 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t *start, · 556 unmodified lines | |||
| 557 | pgoff_t end, struct folio_batch *fbatch, pgoff_t *indices); | 557 | pgoff_t end, struct folio_batch *fbatch, pgoff_t *indices); |
| 558 | unsigned find_get_entries(struct address_space *mapping, pgoff_t *start, | 558 | unsigned find_get_entries(struct address_space *mapping, pgoff_t *start, |
| 559 | pgoff_t end, struct folio_batch *fbatch, pgoff_t *indices); | 559 | pgoff_t end, struct folio_batch *fbatch, pgoff_t *indices); |
| 560 | void filemap_free_folio(struct address_space *mapping, struct folio *folio); | ||
| 561 | int truncate_inode_folio(struct address_space *mapping, struct folio *folio); | 560 | int truncate_inode_folio(struct address_space *mapping, struct folio *folio); |
| 562 | bool truncate_inode_partial_folio(struct folio *folio, loff_t start, | 561 | bool truncate_inode_partial_folio(struct folio *folio, loff_t start, |
| 563 | loff_t end); | 562 | loff_t end); |
| @@ -3788,9 +3788,11 @@ static void wi_state_free(void) · 3787 unmodified lines | |||
| 3788 | } | 3788 | } |
| 3789 | } | 3789 | } |
| 3790 | 3790 | ||
| 3791 | static struct kobj_attribute wi_auto_attr = | 3791 | static struct kobj_attribute wi_auto_attr = { |
| 3792 | __ATTR(auto, 0664, weighted_interleave_auto_show, | 3792 | .attr = { .name = "auto", .mode = 0664 }, |
| 3793 | weighted_interleave_auto_store); | 3793 | .show = weighted_interleave_auto_show, |
| 3794 | .store = weighted_interleave_auto_store, | ||
| 3795 | }; | ||
| 3794 | 3796 | ||
| 3795 | static void wi_cleanup(void) { | 3797 | static void wi_cleanup(void) { |
| 3796 | sysfs_remove_file(&wi_group->wi_kobj, &wi_auto_attr.attr); | 3798 | sysfs_remove_file(&wi_group->wi_kobj, &wi_auto_attr.attr); |
| @@ -454,7 +454,7 @@ void free_zone_device_folio(struct folio *folio) · 453 unmodified lines | |||
| 454 | if (WARN_ON_ONCE(!pgmap->ops || !pgmap->ops->folio_free)) | 454 | if (WARN_ON_ONCE(!pgmap->ops || !pgmap->ops->folio_free)) |
| 455 | break; | 455 | break; |
| 456 | pgmap->ops->folio_free(folio); | 456 | pgmap->ops->folio_free(folio); |
| 457 | percpu_ref_put_many(&folio->pgmap->ref, nr); | 457 | percpu_ref_put_many(&pgmap->ref, nr); |
| 458 | break; | 458 | break; |
| 459 | 459 | ||
| 460 | case MEMORY_DEVICE_GENERIC: | 460 | case MEMORY_DEVICE_GENERIC: |
| @@ -622,6 +622,7 @@ static int folio_launder(struct address_space *mapping, struct folio *folio) · 621 unmodified lines | |||
| 622 | int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio, | 622 | int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio, |
| 623 | gfp_t gfp) | 623 | gfp_t gfp) |
| 624 | { | 624 | { |
| 625 | void (*free_folio)(struct folio *); | ||
| 625 | int ret; | 626 | int ret; |
| 626 | 627 | ||
| 627 | VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); | 628 | VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); |
| @@ -648,9 +649,12 @@ int folio_unmap_invalidate(struct address_space *mapping, struct folio *folio, · 20 unmodified lines | |||
| 648 | xa_unlock_irq(&mapping->i_pages); | 649 | xa_unlock_irq(&mapping->i_pages); |
| 649 | if (mapping_shrinkable(mapping)) | 650 | if (mapping_shrinkable(mapping)) |
| 650 | inode_lru_list_add(mapping->host); | 651 | inode_lru_list_add(mapping->host); |
| 652 | free_folio = mapping->a_ops->free_folio; | ||
| 651 | spin_unlock(&mapping->host->i_lock); | 653 | spin_unlock(&mapping->host->i_lock); |
| 652 | 654 | ||
| 653 | filemap_free_folio(mapping, folio); | 655 | if (free_folio) |
| 656 | free_folio(folio); | ||
| 657 | folio_put_refs(folio, folio_nr_pages(folio)); | ||
| 654 | return 1; | 658 | return 1; |
| 655 | failed: | 659 | failed: |
| 656 | xa_unlock_irq(&mapping->i_pages); | 660 | xa_unlock_irq(&mapping->i_pages); |
| @@ -5416,6 +5416,7 @@ vmap_node_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) · 5415 unmodified lines | |||
| 5416 | { | 5416 | { |
| 5417 | struct vmap_node *vn; | 5417 | struct vmap_node *vn; |
| 5418 | 5418 | ||
| 5419 | guard(mutex)(&vmap_purge_lock); | ||
| 5419 | for_each_vmap_node(vn) | 5420 | for_each_vmap_node(vn) |
| 5420 | decay_va_pool_node(vn, true); | 5421 | decay_va_pool_node(vn, true); |
| 5421 | 5422 | ||