Commit eaa9172a authored by Gao Xiang's avatar Gao Xiang
Browse files

erofs: get rid of ->lru usage

Currently, ->lru is a way to arrange non-LRU pages and has some
in-kernel users. In order to minimize noticable issues of page
reclaim and cache thrashing under high memory presure, limited
temporary pages were all chained with ->lru and can be reused
during the request. However, it seems that ->lru could be removed
when folio is landing.

Let's use page->private to chain temporary pages for now instead
and transform EROFS formally after the topic of the folio / file
page design is finalized.

Link: https://lore.kernel.org/r/20211022090120.14675-1-hsiangkao@linux.alibaba.com


Cc: Matthew Wilcox <willy@infradead.org>
Reviewed-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
parent 622ceadd
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ struct z_erofs_decompress_req {

struct z_erofs_decompressor {
	int (*decompress)(struct z_erofs_decompress_req *rq,
			  struct list_head *pagepool);
			  struct page **pagepool);
	char *name;
};

@@ -64,7 +64,7 @@ static inline bool z_erofs_is_shortlived_page(struct page *page)
	return true;
}

static inline bool z_erofs_put_shortlivedpage(struct list_head *pagepool,
static inline bool z_erofs_put_shortlivedpage(struct page **pagepool,
					      struct page *page)
{
	if (!z_erofs_is_shortlived_page(page))
@@ -75,8 +75,7 @@ static inline bool z_erofs_put_shortlivedpage(struct list_head *pagepool,
		put_page(page);
	} else {
		/* follow the pcluster rule above. */
		set_page_private(page, 0);
		list_add(&page->lru, pagepool);
		erofs_pagepool_add(pagepool, page);
	}
	return true;
}
@@ -89,9 +88,9 @@ static inline bool erofs_page_is_managed(const struct erofs_sb_info *sbi,
}

int z_erofs_decompress(struct z_erofs_decompress_req *rq,
		       struct list_head *pagepool);
		       struct page **pagepool);

/* prototypes for specific algorithms */
int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
			    struct list_head *pagepool);
			    struct page **pagepool);
#endif
+4 −4
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ int z_erofs_load_lz4_config(struct super_block *sb,
 * all physical pages are consecutive, which can be seen for moderate CR.
 */
static int z_erofs_lz4_prepare_dstpages(struct z_erofs_decompress_req *rq,
					struct list_head *pagepool)
					struct page **pagepool)
{
	const unsigned int nr =
		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -254,7 +254,7 @@ static int z_erofs_lz4_decompress_mem(struct z_erofs_decompress_req *rq,
}

static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq,
				  struct list_head *pagepool)
				  struct page **pagepool)
{
	const unsigned int nrpages_out =
		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -296,7 +296,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq,
}

static int z_erofs_shifted_transform(struct z_erofs_decompress_req *rq,
				     struct list_head *pagepool)
				     struct page **pagepool)
{
	const unsigned int nrpages_out =
		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
@@ -352,7 +352,7 @@ static struct z_erofs_decompressor decompressors[] = {
};

int z_erofs_decompress(struct z_erofs_decompress_req *rq,
		       struct list_head *pagepool)
		       struct page **pagepool)
{
	return decompressors[rq->alg].decompress(rq, pagepool);
}
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ int z_erofs_load_lzma_config(struct super_block *sb,
}

int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq,
			    struct list_head *pagepool)
			    struct page **pagepool)
{
	const unsigned int nrpages_out =
		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
+8 −1
Original line number Diff line number Diff line
@@ -499,7 +499,14 @@ void erofs_pcpubuf_init(void);
void erofs_pcpubuf_exit(void);

/* utils.c / zdata.c */
struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp);
struct page *erofs_allocpage(struct page **pagepool, gfp_t gfp);
static inline void erofs_pagepool_add(struct page **pagepool,
		struct page *page)
{
	set_page_private(page, (unsigned long)*pagepool);
	*pagepool = page;
}
void erofs_release_pages(struct page **pagepool);

#ifdef CONFIG_EROFS_FS_ZIP
int erofs_workgroup_put(struct erofs_workgroup *grp);
+3 −3
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ int erofs_pcpubuf_growsize(unsigned int nrpages)
{
	static DEFINE_MUTEX(pcb_resize_mutex);
	static unsigned int pcb_nrpages;
	LIST_HEAD(pagepool);
	struct page *pagepool = NULL;
	int delta, cpu, ret, i;

	mutex_lock(&pcb_resize_mutex);
@@ -102,13 +102,13 @@ int erofs_pcpubuf_growsize(unsigned int nrpages)
			vunmap(old_ptr);
free_pagearray:
		while (i)
			list_add(&oldpages[--i]->lru, &pagepool);
			erofs_pagepool_add(&pagepool, oldpages[--i]);
		kfree(oldpages);
		if (ret)
			break;
	}
	pcb_nrpages = nrpages;
	put_pages_list(&pagepool);
	erofs_release_pages(&pagepool);
out:
	mutex_unlock(&pcb_resize_mutex);
	return ret;
Loading