Commit 9acd7af
mm/zswap: defer zs_free() in zswap_invalidate() path
zswap_invalidate() is called on the same process exit path as
zram_slot_free_notify(). The zswap_entry_free() it calls internally
performs zs_free() which is expensive due to zsmalloc internal locking.
Unlike zram which has a trylock fallback, zswap_invalidate() executes
unconditionally, making the latency impact potentially worse.
Like zram, the expensive zs_free() here blocks the process exit path,
delaying overall memory release. Additionally, zswap_entry_free()
performs extra work beyond zs_free(): list_lru_del() (takes its own
spinlock), obj_cgroup accounting, and kmem_cache_free for the entry
itself.
Use zs_free_deferred() in zswap_invalidate() path to defer the
expensive zsmalloc handle freeing to a workqueue, allowing the exit
path to release memory faster. All other callers (zswap_load,
zswap_writeback_entry, zswap_store error paths) run in process context
and continue to use synchronous zs_free().
Signed-off-by: Wenchao Hao <[email protected]>1 parent 38f3303 commit 9acd7af
1 file changed
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
761 | 761 | | |
762 | 762 | | |
763 | 763 | | |
| 764 | + | |
| 765 | + | |
764 | 766 | | |
765 | | - | |
| 767 | + | |
766 | 768 | | |
767 | 769 | | |
768 | | - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
769 | 774 | | |
770 | 775 | | |
771 | 776 | | |
| |||
777 | 782 | | |
778 | 783 | | |
779 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
780 | 790 | | |
781 | 791 | | |
782 | 792 | | |
| |||
1648 | 1658 | | |
1649 | 1659 | | |
1650 | 1660 | | |
1651 | | - | |
| 1661 | + | |
1652 | 1662 | | |
1653 | 1663 | | |
1654 | 1664 | | |
| |||
0 commit comments