Bug 25521 - anolis: mm: Set mapping unevictable if file compressed according to the new extension_list interface
Summary: anolis: mm: Set mapping unevictable if file compressed according to the new e...
Status: NEW
Alias: None
Product: ANCK 6.6 Dev
Classification: ANCK
Component: mm (show other bugs) mm
Version: unspecified
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: baolinwang
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-30 17:54 UTC by wangyaxin
Modified: 2025-09-30 17:57 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wangyaxin 2025-09-30 17:54:04 UTC
Problems:
In environments that require high-performance file access, the tmpfs is often employed.
It's important to note that the memory pages used by tmpfs are eligible to be swapped out.

A potential efficiency issue arises when the system also uses zram
and the tmpfs contains pre-compressed files (such as .gz files).

Under memory pressure, the kernel may select the memory pages belonging to these .gz files
to be swapped out into zram. However, since the data within .gz files is already compressed,
zram gains negligible benefit from compressing them a second time and can hardly reduce
their size further. This process not only fails to free up a meaningful amount of memory
but also unnecessarily consumes the limited capacity of the zram device,
resulting in a net waste of resources.

Solution:
This patch introduces a feature that marks memory pages of files with specific extensions (e.g., .gz)
in a tmpfs filesystem as Unevictable. This prevents these in-memory compressed files from being
swapped out to zram, thereby effectively mitigating the issue described above.

Usage:
This feature is controlled by a global switch that dynamically enables or disables the functionality.
It is disabled by default.
    Disable:
    echo 0 > /sys/fs/shmem/extension_list_enable
    Enable:
    echo 1 > /sys/fs/shmem/extension_list_enable
The file /sys/fs/shmem/extension_list is used to configure which file extensions are affected by this feature.
the default list of configured suffixes:
    cat /sys/fs/shmem/extension_list
    unevictable file extension: gz  bz2  xz
Add a new file extension:
    echo 'zip' > /sys/fs/shmem/extension_list
Remove a file extension:
    echo '!zip' > /sys/fs/shmem/extension_list

Signed-off-by: Chen Junlin <chen.junlin@zte.com.cn>
Comment 1 小龙 admin 2025-09-30 17:57:45 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/5838