Re: [PATCH 30/45] vmscan: lumpy pageout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 07, 2009 at 10:50:17PM +0800, Nikita Danilov wrote:
> 2009/10/7 Wu Fengguang <fengguang.wu@xxxxxxxxx>:
> 
> [...]
> 
> > +               if (bdi_cap_writeback_dirty(mapping->backing_dev_info) &&
> > +                   !mapping->a_ops->writepages) {
> > +                       wbc.range_start = (page->index + 1) << PAGE_CACHE_SHIFT;
> > +                       wbc.nr_to_write = LUMPY_PAGEOUT_PAGES - 1;
> > +                       generic_writepages(mapping, &wbc);
> > +                       iput(inode);
> 
> I am afraid calling iput() from within pageout code is not generally
> safe: it can trigger a lot of file system activity (think
> open-unlinked file) that is not supposed to happen in the
> direct-reclaim context. Limiting pageout clustering to kswapd might be
> a better idea---this would improve direct-reclaim latency too, but
> still, file systems are not designed for re-entrant calls to iput().

Good point, thanks!

---
vmscan: lumpy pageout

When pageout a dirty page, try to piggy back more consecutive dirty
pages (up to 512KB) to improve IO efficiency.

Only ext3/reiserfs which don't have its own aops->writepages are
supported in this initial version.

CC: Dave Chinner <david@xxxxxxxxxxxxx>
CC: Nikita Danilov <danilov@xxxxxxxxx>
Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx>
---
 mm/page-writeback.c |   12 ++++++++++++
 mm/vmscan.c         |   20 ++++++++++++++++++++
 2 files changed, 32 insertions(+)

--- linux.orig/mm/vmscan.c	2009-10-07 21:39:13.000000000 +0800
+++ linux/mm/vmscan.c	2009-10-07 22:59:57.000000000 +0800
@@ -344,6 +344,8 @@ typedef enum {
 	PAGE_CLEAN,
 } pageout_t;
 
+#define LUMPY_PAGEOUT_PAGES	(512 * 1024 / PAGE_CACHE_SIZE)
+
 /*
  * pageout is called by shrink_page_list() for each dirty page.
  * Calls ->writepage().
@@ -398,6 +400,10 @@ static pageout_t pageout(struct page *pa
 			.nonblocking = 1,
 			.for_reclaim = 1,
 		};
+		struct inode *inode = NULL;
+
+		if (current_is_kswapd())
+			inode = igrab(mapping->host);
 
 		SetPageReclaim(page);
 		res = mapping->a_ops->writepage(page, &wbc);
@@ -405,10 +411,24 @@ static pageout_t pageout(struct page *pa
 			handle_write_error(mapping, page, res);
 		if (res == AOP_WRITEPAGE_ACTIVATE) {
 			ClearPageReclaim(page);
+			iput(inode);
 			return PAGE_ACTIVATE;
 		}
 
 		/*
+		 * only write_cache_pages() supports for_reclaim for now
+		 * ignore shmem for now, thanks to Nikita.
+		 */
+		if (current_is_kswapd() &&
+		    bdi_cap_writeback_dirty(mapping->backing_dev_info) &&
+		    !mapping->a_ops->writepages) {
+			wbc.range_start = (page->index + 1) << PAGE_CACHE_SHIFT;
+			wbc.nr_to_write = LUMPY_PAGEOUT_PAGES - 1;
+			generic_writepages(mapping, &wbc);
+			iput(inode);
+		}
+
+		/*
 		 * Wait on writeback if requested to. This happens when
 		 * direct reclaiming a large contiguous area and the
 		 * first attempt to free a range of pages fails.
--- linux.orig/mm/page-writeback.c	2009-10-07 21:39:13.000000000 +0800
+++ linux/mm/page-writeback.c	2009-10-07 22:57:55.000000000 +0800
@@ -805,6 +805,11 @@ int write_cache_pages(struct address_spa
 				break;
 			}
 
+			if (wbc->for_reclaim && done_index != page->index) {
+				done = 1;
+				break;
+			}
+
 			if (nr_to_write != wbc->nr_to_write &&
 			    done_index + WB_SEGMENT_DIST < page->index &&
 			    --wbc->nr_segments <= 0) {
@@ -846,6 +851,13 @@ continue_unlock:
 			if (!clear_page_dirty_for_io(page))
 				goto continue_unlock;
 
+			/*
+			 * active and unevictable pages will be checked at
+			 * rotate time
+			 */
+			if (wbc->for_reclaim)
+				SetPageReclaim(page);
+
 			ret = (*writepage)(page, wbc, data);
 			if (unlikely(ret)) {
 				if (ret == AOP_WRITEPAGE_ACTIVATE) {
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux