On 2020/1/19 9:42, Matthew Wilcox wrote:
Did you read my patch series? The current code allocates pages, but does not put them in the page cache until after iomap is called. My patch series changes that to put the pages in the page cache as soon as they're allocated, and before iomap is called.
I just read you patch series again. At first, if you try to add all pages to pagecache and lock them before iomap_begin. I thought aboult it before, but I throw away the idea becacuse all other operation that will lock the page will need to wait for readahead to finish. And it might cause problem for performance overhead. And if you try to add each page to page cache and call iomap before adding the next page. Then, we are facing the same CPU overhead issure. Then, there might be a problem in your implementation. if 'use_list' is set to true here: + bool use_list = mapping->a_ops->readpages; Your code do not call add_to_page_cache_lru for the page. + if (use_list) { + page->index = page_offset; + list_add(&page->lru, &page_pool); + } else if (!add_to_page_cache_lru(page, mapping, page_offset, + gfp_mask)) { + if (nr_pages) + read_pages(mapping, filp, &page_pool, + page_offset - nr_pages, + nr_pages); + nr_pages = 0; + continue; + } And later, you replace 'iomap_next_page' with 'readahead_page' +static inline +struct page *readahead_page(struct address_space *mapping, loff_t pos) +{ + struct page *page = xa_load(&mapping->i_pages, pos / PAGE_SIZE); + VM_BUG_ON_PAGE(!PageLocked(page), page); + + return page; +} + It seems that the page will never add to page cache. Thanks! Yu Kuai