Bug 12193 - brd: implement discard support
Summary: brd: implement discard support
Status: RESOLVED FIXED
Alias: None
Product: ANCK 6.6 Dev
Classification: ANCK
Component: drivers (show other bugs) drivers
Version: 6.6.25-2
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: shineway
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-03 14:02 UTC by shineway
Modified: 2024-12-04 10:49 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shineway 2024-12-03 14:02:21 UTC
Description of problem:
The ramdisk memory utilization can only go up when data is written to
new pages. Implement discard to provide the possibility to reduce memory
usage for pages no longer in use. Aligned discards will free the
associated pages, if any, and determinisitically return zeroed data
until written again.

See upstream:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9ead7efc6f3f2b46c4ec68209bca4888cfbd4c19

Version-Release number of selected component (if applicable):


How reproducible:
#!/bin/bash

modprobe brd rd_size=2048000

mkfs.xfs /dev/ram0
mount -o discard /dev/ram0 /mnt
echo create before
free -m
dd if=/dev/zero of=/mnt/testfile-400M oflag=direct bs=1M count=400 &> /dev/null
echo create after
free -m
rm -fr /mnt/testfile-400M
sync
echo remove after
free -m
umount /mnt


Steps to Reproduce:
1.
2.
3.

Actual results:
"used" memory will not decrease.

Expected results:
"used" memory will decrease.


Additional info:
This feature has been merged since kernel 6.8, Anolis OS can support it.
Comment 1 小龙 admin 2024-12-03 14:35:07 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/4187
Comment 2 小龙 admin 2024-12-03 15:30:40 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/4188
Comment 3 小龙 admin 2024-12-03 16:56:19 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/4190
Comment 4 shineway 2024-12-04 10:48:08 UTC
Merged.