[PATCH v3] erofs: add sysfs node to drop internal caches

2024-11-12 Thread Chunhai Guo via Linux-erofs
Add a sysfs node to drop compression-related caches, currently used to drop in-memory pclusters and cached compressed folios. Signed-off-by: Chunhai Guo --- v2->v3: - All cached folios should be disconnected before invalidating. - Only add sysfs node when CONFIG_EROFS_FS_ZIP is enabled. v1: h

[PATCH v2] erofs: add sysfs node to drop internal caches

2024-11-12 Thread Chunhai Guo via Linux-erofs
Add a sysfs node to drop compression-related caches, currently used to drop in-memory pclusters and compressed folios. Signed-off-by: Chunhai Guo --- v1: https://lore.kernel.org/linux-erofs/fabdfe9f-9293-45c2-8cf2-3d86c248a...@linux.alibaba.com change since v1: - Change subject as suggested by

[PATCH] erofs: add sysfs node to drop all compression-related caches

2024-11-12 Thread Chunhai Guo via Linux-erofs
Add a sysfs node to drop all compression-related caches, including pclusters and attached compressed pages. Signed-off-by: Chunhai Guo --- Documentation/ABI/testing/sysfs-fs-erofs | 7 +++ fs/erofs/sysfs.c | 11 +++ 2 files changed, 18 insertions(+) diff --g

[PATCH v6] erofs: free pclusters if no cached folio is attached

2024-11-11 Thread Chunhai Guo via Linux-erofs
Once a pcluster is fully decompressed and there are no attached cached folios, its corresponding `struct z_erofs_pcluster` will be freed. This will significantly reduce the frequency of calls to erofs_shrink_scan() and the memory allocated for `struct z_erofs_pcluster`. The tables below show appro

[PATCH v5] erofs: free pclusters if no cached folio is attached

2024-11-11 Thread Chunhai Guo via Linux-erofs
Once a pcluster is fully decompressed and there are no attached cached folios, its corresponding `struct z_erofs_pcluster` will be freed. This will significantly reduce the frequency of calls to erofs_shrink_scan() and the memory allocated for `struct z_erofs_pcluster`. The tables below show appro

[PATCH] erofs: clean up the cache if cached decompression is disabled

2024-11-11 Thread Chunhai Guo via Linux-erofs
Clean up the cache when cached decompression strategy is changed to EROFS_ZIP_CACHE_DISABLED by remount. Signed-off-by: Chunhai Guo --- fs/erofs/super.c | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 320d586c3896..de2af862e65b 100644 --- a/fs/e

[PATCH v4] erofs: free pclusters if no cached folio attached

2024-11-11 Thread Chunhai Guo via Linux-erofs
Once a pcluster is fully decompressed and there are no attached cached folios, its corresponding `struct z_erofs_pcluster` will be freed. This will significantly reduce the frequency of calls to erofs_shrink_scan() and the memory allocated for `struct z_erofs_pcluster`. The tables below show appro

Re: [PATCH] erofs: add sysfs node to control cached decompression strategy

2024-11-11 Thread Chunhai Guo via Linux-erofs
在 2024/11/11 10:28, Gao Xiang 写道: > Hi Chunhai, > > On 2024/11/1 20:42, Chunhai Guo wrote: >> Add sysfs node to control cached decompression strategy, and all the >> cache will be cleaned up when the strategy is set to >> EROFS_ZIP_CACHE_DISABLED. >> >> Signed-off-by: Chunhai Guo > I guess remount

[PATCH v3] erofs: free pclusters if no cached folio attached

2024-11-11 Thread Chunhai Guo via Linux-erofs
Once a pcluster is fully decompressed and there are no attached cached folios, its corresponding `struct z_erofs_pcluster` will be freed. This will significantly reduce the frequency of calls to erofs_shrink_scan() and the memory allocated for `struct z_erofs_pcluster`. The tables below show appro

[PATCH] erofs: add sysfs node to control cached decompression strategy

2024-11-01 Thread Chunhai Guo via Linux-erofs
Add sysfs node to control cached decompression strategy, and all the cache will be cleaned up when the strategy is set to EROFS_ZIP_CACHE_DISABLED. Signed-off-by: Chunhai Guo --- Documentation/ABI/testing/sysfs-fs-erofs | 14 ++ fs/erofs/sysfs.c | 8

[PATCH v2] erofs: free pclusters if no cached folio attached

2024-10-31 Thread Chunhai Guo via Linux-erofs
Once a pcluster is fully decompressed and there are no attached cached folios, its corresponding `struct z_erofs_pcluster` will be freed. This will significantly reduce the frequency of calls to erofs_shrink_scan() and the memory allocated for `struct z_erofs_pcluster`. The tables below show appro

Re: [PATCH 1/3] erofs: get rid of erofs_{find,insert}_workgroup

2024-10-17 Thread Chunhai Guo via Linux-erofs
> @@ -789,7 +798,16 @@ static int z_erofs_pcluster_begin(struct > z_erofs_decompress_frontend *fe) > DBG_BUGON(fe->owned_head == Z_EROFS_PCLUSTER_NIL); > > if (!(map->m_flags & EROFS_MAP_META)) { > - grp = erofs_find_workgroup(sb, blknr); > + while (1) { > +

[PATCH] erofs: free pcluster right after decompression if possible

2024-09-30 Thread Chunhai Guo via Linux-erofs
Once a pcluster is fully decompressed and there are no attached cached pages, its corresponding struct z_erofs_pcluster will be freed. This will significantly reduce the frequency of calls to erofs_shrink_scan() and the memory allocated for struct z_erofs_pcluster. The tables below show approximat

[PATCH] erofs: allocate more short-lived pages from reserved pool first

2024-09-06 Thread Chunhai Guo via Linux-erofs
This patch aims to allocate bvpages and short-lived compressed pages from the reserved pool first. After applying this patch, there are three benefits. 1. It reduces the page allocation time. The bvpages and short-lived compressed pages account for about 4% of the pages allocated from the system

Re: [PATCH] erofs: fix out-of-bound access when z_erofs_gbuf_growsize() partially fails

2024-08-20 Thread Chunhai Guo via Linux-erofs
在 2024/8/20 17:27, Gao Xiang 写道: > Hi Chunhai, > > On 2024/8/20 17:25, Chunhai Guo wrote: >> 在 2024/8/20 16:42, Gao Xiang 写道: >>> If z_erofs_gbuf_growsize() partially fails on a global buffer due to >>> memory allocation failure or fault injection (as reported by syzbot >>> [1]), >>> new pages nee

Re: [PATCH] erofs: fix out-of-bound access when z_erofs_gbuf_growsize() partially fails

2024-08-20 Thread Chunhai Guo via Linux-erofs
在 2024/8/20 16:42, Gao Xiang 写道: > If z_erofs_gbuf_growsize() partially fails on a global buffer due to > memory allocation failure or fault injection (as reported by syzbot [1]), > new pages need to be freed by comparing to the existing pages to avoid > memory leaks. > > However, the old gbuf->pag

Re: [PATCH] erofs: allocate extra bvec pages from reserved buffer pool first by default

2024-08-16 Thread Chunhai Guo via Linux-erofs
在 2024/8/16 1:33, Sandeep Dhavale 写道: >> I do not have a good number for it now. While the modification is minor >> and without any side effects. I suggest that we make the change. >> >> Thanks, > Hi Chunhai, > Even though it may not be easily visible in comprehensive tests like > app launch in and

Re: [PATCH] erofs: free pcluster right after decompression if cache decompression is disabled

2024-08-14 Thread Chunhai Guo via Linux-erofs
在 2024/8/14 14:19, Gao Xiang 写道: > > On 2024/8/13 18:28, Chunhai Guo wrote: >> When the erofs cache decompression is disabled >> (EROFS_ZIP_CACHE_DISABLED), all pages in pcluster are freed right after >> decompression. There is no need to cache the pcluster as well and it can >> be freed. >> >> Sig

Re: [PATCH] erofs: allocate extra bvec pages from reserved buffer pool first by default

2024-08-14 Thread Chunhai Guo via Linux-erofs
在 2024/8/14 10:35, Gao Xiang 写道: > Hi Chunhai, > > On 2024/8/13 18:27, Chunhai Guo wrote: >> As the extra bvec pages are allocated and freed in a short time, it can > It'd be better to just simplify the subject > erofs: allocate bvpages from reserved buffer pool first Got it. I will change it. >>

[PATCH] erofs: free pcluster right after decompression if cache decompression is disabled

2024-08-13 Thread Chunhai Guo via Linux-erofs
When the erofs cache decompression is disabled (EROFS_ZIP_CACHE_DISABLED), all pages in pcluster are freed right after decompression. There is no need to cache the pcluster as well and it can be freed. Signed-off-by: Chunhai Guo --- fs/erofs/internal.h | 3 ++- fs/erofs/zdata.c| 4 ++-- fs

[PATCH] erofs: allocate extra bvec pages from reserved buffer pool first by default

2024-08-13 Thread Chunhai Guo via Linux-erofs
As the extra bvec pages are allocated and freed in a short time, it can reduce the page allocation time by first allocating pages from the reserved buffer pool [1]. [1] The reserved buffer pool and its benefits are detailed in commit 0f6273ab4637 ("erofs: add a reserved buffer pool for lz4 decompr

[PATCH] erofs: allocate compressed page from reserved buffer pool first if cache decompression is disabled

2024-08-13 Thread Chunhai Guo via Linux-erofs
When erofs cache decompression is disabled (EROFS_ZIP_CACHE_DISABLED), pages allocated for compressed clusters are freed soon after decompression. This can reduce the page allocation time by first allocating pages from the reserved buffer pool [1]. [1] The reserved buffer pool and its benefits are

Re: [PATCH] erofs: fix race in z_erofs_get_gbuf()

2024-07-22 Thread Chunhai Guo via Linux-erofs
在 2024/7/22 11:51, Gao Xiang 写道: > In z_erofs_get_gbuf(), the current task may be migrated to another > CPU between `z_erofs_gbuf_id()` and `spin_lock(&gbuf->lock)`. > > Therefore, z_erofs_put_gbuf() will trigger the following issue > which was found by stress test: > > <2>[772156.434168] kernel BU

[PATCH v2] erofs: add a reserved buffer pool for lz4 decompression

2024-04-02 Thread Chunhai Guo via Linux-erofs
This adds a special global buffer pool (in the end) for reserved pages. Using a reserved pool for LZ4 decompression significantly reduces the time spent on extra temporary page allocation for the extreme cases in low memory scenarios. The table below shows the reduction in time spent on page allo

[PATCH v2] erofs: rename per-CPU buffers to global buffer pool and make it configurable

2024-04-02 Thread Chunhai Guo via Linux-erofs
It will cost more time if compressed buffers are allocated on demand for low-latency algorithms (like lz4) so EROFS uses per-CPU buffers to keep compressed data if in-place decompression is unfulfilled. While it is kind of wasteful of memory for a device with hundreds of CPUs, and only a small num

Re: [PATCH v2] erofs: do not use pagepool in z_erofs_gbuf_growsize()

2024-04-02 Thread Chunhai Guo via Linux-erofs
在 2024/4/2 17:22, Gao Xiang 写道: > > On 2024/4/2 17:27, Chunhai Guo wrote: >> Let's use alloc_pages_bulk_array() for simplicity and get rid of >> unnecessary pagepool. >> >> Signed-off-by: Chunhai Guo >> --- > Would you mind adding a changelog here next time? no > matter how short the text is. > >

[PATCH v2] erofs: do not use pagepool in z_erofs_gbuf_growsize()

2024-04-02 Thread Chunhai Guo via Linux-erofs
Let's use alloc_pages_bulk_array() for simplicity and get rid of unnecessary pagepool. Signed-off-by: Chunhai Guo --- fs/erofs/zutil.c | 67 ++-- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c index

[PATCH] erofs: add a reserved buffer pool for lz4 decompression

2024-04-02 Thread Chunhai Guo via Linux-erofs
This adds a special global buffer pool (in the end) for reserved pages. Using a reserved pool for LZ4 decompression significantly reduces the time spent on extra temporary page allocation for the extreme cases in low memory scenarios. The table below shows the reduction in time spent on page allo

[PATCH] erofs: do not use pagepool in z_erofs_gbuf_growsize()

2024-04-02 Thread Chunhai Guo via Linux-erofs
Let's use alloc_pages_bulk_array() for simplicity and get rid of unnecessary pagepool. Signed-off-by: Chunhai Guo --- fs/erofs/zutil.c | 64 +++- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c index

[PATCH 2/2] erofs: rename per CPU buffer to global buffer pool and make it configurable

2024-04-01 Thread Chunhai Guo via Linux-erofs
It will cost more time if compressed buffers are allocated on demand for low-latency algorithms (like lz4) so EROFS uses per-CPU buffers to keep compressed data if in-place decompression is unfulfilled. While it is kind of wasteful of memory for a device with hundreds of CPUs, and only a small num

[PATCH 1/2] erofs: rename utils.c to zutil.c

2024-04-01 Thread Chunhai Guo via Linux-erofs
Currently, utils.c is only useful if CONFIG_EROFS_FS_ZIP is on. So let's rename as zutil.c as well as avoid its inclusion if CONFIG_EROFS_FS_ZIP is explicitly disabled. Signed-off-by: Chunhai Guo Suggested-by: Gao Xiang --- fs/erofs/Makefile | 4 ++-- fs/erofs/{utils.c => zutil.c}

[PATCH v3] erofs: rename per CPU buffer to global buffer pool and make it configurable

2024-03-22 Thread Chunhai Guo via Linux-erofs
It will cost more time if compressed buffers are allocated on demand for low-latency algorithms (like lz4) so EROFS uses per-CPU buffers to keep compressed data if in-place decompression is unfulfilled. While it is kind of wasteful of memory for a device with hundreds of CPUs, and only a small num

[PATCH v2] erofs: rename per CPU buffer to global buffer pool and make it configurable

2024-03-22 Thread Chunhai Guo via Linux-erofs
It will cost more time if compressed buffers are allocated on demand for low-latency algorithms (like lz4) so EROFS uses per-CPU buffers to keep compressed data if in-place decompression is unfulfilled. While it is kind of wasteful of memory for a device with hundreds of CPUs, and only a small num

Re: [PATCH] erofs: rename per-CPU buffers to global buffer pool and make it configurable

2024-03-22 Thread Chunhai Guo via Linux-erofs
Got it. I will send patch v2 as your suggestion. Thanks, 在 2024/3/22 12:10, Gao Xiang 写道: > > On 2024/3/22 11:47, Chunhai Guo wrote: >> It will cost more time if compressed buffers are allocated on demand for >> low-latency algorithms (like lz4) so EROFS uses per-CPU buffers to keep >> compressed

[PATCH] erofs: rename per-CPU buffers to global buffer pool and make it configurable

2024-03-21 Thread Chunhai Guo via Linux-erofs
It will cost more time if compressed buffers are allocated on demand for low-latency algorithms (like lz4) so EROFS uses per-CPU buffers to keep compressed data if in-place decompression is unfulfilled. While it is kind of wasteful of memory for a device with hundreds of CPUs, and only a small num

答复: [PATCH v2] erofs: relaxed temporary buffers allocation on readahead

2024-01-25 Thread Chunhai Guo via Linux-erofs
> -邮件原件- > 发件人: Gao Xiang > 发送时间: 2024年1月26日 11:50 > 收件人: Chunhai Guo ; xi...@kernel.org > 抄送: c...@kernel.org; huy...@coolpad.com; jeffl...@linux.alibaba.com; > linux-erofs@lists.ozlabs.org > 主题: Re: [PATCH v2] erofs: relaxed temporary buffers allocation on readahead > > [你通常不会收到来自 hsi

Re: [PATCH v2] erofs: relaxed temporary buffers allocation on readahead

2024-01-25 Thread Chunhai Guo via Linux-erofs
On 2024/1/26 10:47, Gao Xiang wrote: > [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 > https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要] > > On 2024/1/26 10:41, Chunhai Guo wrote: >> On 2024/1/22 15:42, Chunhai Guo wrote: >>> On 2024/1/22 12:37, Gao Xiang wrote: [你通常不会收到来自 hsiang

Re: [PATCH v2] erofs: relaxed temporary buffers allocation on readahead

2024-01-25 Thread Chunhai Guo via Linux-erofs
On 2024/1/22 15:42, Chunhai Guo wrote: > On 2024/1/22 12:37, Gao Xiang wrote: >> [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 >> https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要] >> >> On 2024/1/22 11:49, Chunhai Guo wrote: >>> On 2024/1/22 10:07, Gao Xiang wrote: [你通常不会收到来自 hsi

Re: [PATCH v2] erofs: relaxed temporary buffers allocation on readahead

2024-01-21 Thread Chunhai Guo via Linux-erofs
On 2024/1/22 12:37, Gao Xiang wrote: > [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 > https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要] > > On 2024/1/22 11:49, Chunhai Guo wrote: >> On 2024/1/22 10:07, Gao Xiang wrote: >>> [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 >>> https:/

Re: [PATCH v2] erofs: relaxed temporary buffers allocation on readahead

2024-01-21 Thread Chunhai Guo via Linux-erofs
On 2024/1/22 10:07, Gao Xiang wrote: > [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 > https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要] > > On 2024/1/20 22:55, Chunhai Guo wrote: >> Even with inplace decompression, sometimes extra temporary buffers are >> still needed for decompressi

[PATCH v2] erofs: relaxed temporary buffers allocation on readahead

2024-01-20 Thread Chunhai Guo via Linux-erofs
Even with inplace decompression, sometimes extra temporary buffers are still needed for decompression. In low-memory scenarios, it would be better to try to allocate with GFP_NOWAIT on readahead first. That can help reduce the time spent on page allocation under memory pressure. There is an avera

[PATCH] erofs: alloc readahead page with __GFP_NOFAIL flag during decompression

2024-01-19 Thread Chunhai Guo via Linux-erofs
During decompression, it is better to allocate readahead pages with the GFP_NOWAIT flag, which can help reduce the time spent on page allocation in low memory scenarios. >From the result of multi-app launch benchmarks on ARM64 Android devices running the 5.15 kernel with an 8-core CPU and 8GB of m

Re: [PATCH v2] erofs: add a global page pool for lz4 decompression

2024-01-11 Thread Chunhai Guo via Linux-erofs
On 2024/1/10 14:45, Chunhai Guo wrote: > On 2024/1/9 21:08, Gao Xiang wrote: >> [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 >> https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要] >> >> Hi Chunhai, >> >> On 2024/1/9 15:41, Chunhai Guo wrote: >>> Using a global page pool for LZ4 decompr

Re: [PATCH v2] erofs: add a global page pool for lz4 decompression

2024-01-09 Thread Chunhai Guo via Linux-erofs
On 2024/1/9 21:08, Gao Xiang wrote: > [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 > https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要] > > Hi Chunhai, > > On 2024/1/9 15:41, Chunhai Guo wrote: >> Using a global page pool for LZ4 decompression significantly reduces the >> time spent o

[PATCH v2] erofs: add a global page pool for lz4 decompression

2024-01-08 Thread Chunhai Guo via Linux-erofs
Using a global page pool for LZ4 decompression significantly reduces the time spent on page allocation in low memory scenarios. The table below shows the reduction in time spent on page allocation for LZ4 decompression when using a global page pool. The results were obtained from multi-app launch

[PATCH v4] erofs: make erofs_err() and erofs_info() support NULL sb parameter

2024-01-03 Thread Chunhai Guo via Linux-erofs
Make erofs_err() and erofs_info() support NULL sb parameter for more general usage. Suggested-by: Gao Xiang Signed-off-by: Chunhai Guo --- V3 -> V4: remove unnecessary '\n' V2 -> V3: convert pr_err() to erofs_err() in erofs codebase V1 -> V2: add erofs_info() --- fs/erofs/decompressor_deflate.c

[PATCH v3] erofs: make erofs_err() and erofs_info() support NULL sb parameter

2024-01-03 Thread Chunhai Guo via Linux-erofs
Make erofs_err() and erofs_info() support NULL sb parameter for more general usage. Suggested-by: Gao Xiang Signed-off-by: Chunhai Guo --- V2 -> V3: convert pr_err() to erofs_err() in erofs codebase V1 -> V2: add erofs_info() --- fs/erofs/decompressor_deflate.c | 2 +- fs/erofs/super.c

[PATCH v2] erofs: make erofs_err() and erofs_info() support NULL sb parameter

2024-01-02 Thread Chunhai Guo via Linux-erofs
Make erofs_err() and erofs_info() support NULL sb parameter for more general usage. Suggested-by: Gao Xiang Signed-off-by: Chunhai Guo --- fs/erofs/super.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 3789d6224513..5f60

[PATCH] erofs: make erofs_err() and erofs_info() support NULL sb parameter

2024-01-02 Thread Chunhai Guo via Linux-erofs
Make erofs_err() and erofs_info() support NULL sb parameter for more general usage. Suggested-by: Gao Xiang Signed-off-by: Chunhai Guo --- fs/erofs/super.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 3789d6224513..96a

[PATCH] erofs: make erofs_err() support NULL sb parameter

2024-01-02 Thread Chunhai Guo via Linux-erofs
Make erofs_err() support NULL sb parameter for more general usage. Suggested-by: Gao Xiang Signed-off-by: Chunhai Guo --- fs/erofs/super.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 3789d6224513..f20dcfacdcc5 100644 --- a/f

Re: [PATCH] erofs: add a global page pool for lz4 decompression

2024-01-01 Thread Chunhai Guo via Linux-erofs
On 2023/12/31 9:09, Gao Xiang wrote: > [你通常不会收到来自 hsiang...@linux.alibaba.com 的电子邮件。请访问 > https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要] > > On 2023/12/29 12:48, Chunhai Guo wrote: >>> Hi Chunhai, >>> >>> On 2023/12/28 21:00, Chunhai Guo wrote: Using a global page pool for LZ4 d

Re: [PATCH] erofs: add a global page pool for lz4 decompression

2023-12-28 Thread Chunhai Guo via Linux-erofs
> Hi Chunhai, > > On 2023/12/28 21:00, Chunhai Guo wrote: > > Using a global page pool for LZ4 decompression significantly reduces > > the time spent on page allocation in low memory scenarios. > > > > The table below shows the reduction in time spent on page allocation > > for > > LZ4 decompres

[PATCH] erofs: add a global page pool for lz4 decompression

2023-12-28 Thread Chunhai Guo via Linux-erofs
Using a global page pool for LZ4 decompression significantly reduces the time spent on page allocation in low memory scenarios. The table below shows the reduction in time spent on page allocation for LZ4 decompression when using a global page pool. The results were obtained from multi-app launch