linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
@ 2013-11-22  1:09 Chao Yu
  2013-11-22  9:10 ` Jaegeuk Kim
  2013-11-24  4:26 ` Jaegeuk Kim
  0 siblings, 2 replies; 6+ messages in thread
From: Chao Yu @ 2013-11-22  1:09 UTC (permalink / raw)
  To: ???; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, 谭姝

Previously we read sit entries page one by one, this method lost the chance 
of reading contiguous page together. So we read pages as contiguous as 
possible for better mount performance.

change log:
 o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng 
   suggested.
 o add mark_page_accessed() before release page to delay VM reclaiming.
 o remove '*order' for simplification of function as Jaegeuk Kim suggested.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/segment.c |  103 +++++++++++++++++++++++++++++++++++++++--------------
 fs/f2fs/segment.h |    2 ++
 2 files changed, 78 insertions(+), 27 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8149eba..998e7d3 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -14,6 +14,7 @@
 #include <linux/blkdev.h>
 #include <linux/prefetch.h>
 #include <linux/vmalloc.h>
+#include <linux/swap.h>
 
 #include "f2fs.h"
 #include "segment.h"
@@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
 	return restore_curseg_summaries(sbi);
 }
 
+static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
+{
+	struct address_space *mapping = sbi->meta_inode->i_mapping;
+	struct page *page;
+	block_t blk_addr, prev_blk_addr = 0;
+	int sit_blk_cnt = SIT_BLK_CNT(sbi);
+	int blkno = start;
+
+	for (; blkno < start + nrpages && blkno < sit_blk_cnt; blkno++) {
+
+		blk_addr = current_sit_addr(sbi, start * SIT_ENTRY_PER_BLOCK);
+
+		if (blkno != start && prev_blk_addr + 1 != blk_addr)
+			break;
+		prev_blk_addr = blk_addr;
+repeat:
+		page = grab_cache_page(mapping, blk_addr);
+		if (!page) {
+			cond_resched();
+			goto repeat;
+		}
+		if (PageUptodate(page)) {
+			mark_page_accessed(page);
+			f2fs_put_page(page, 1);
+			continue;
+		}
+
+		submit_read_page(sbi, page, blk_addr, READ_SYNC);
+
+		mark_page_accessed(page);
+		f2fs_put_page(page, 0);
+	}
+
+	f2fs_submit_read_bio(sbi, READ_SYNC);
+	return blkno - start;
+}
+
 static void build_sit_entries(struct f2fs_sb_info *sbi)
 {
 	struct sit_info *sit_i = SIT_I(sbi);
 	struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA);
 	struct f2fs_summary_block *sum = curseg->sum_blk;
-	unsigned int start;
-
-	for (start = 0; start < TOTAL_SEGS(sbi); start++) {
-		struct seg_entry *se = &sit_i->sentries[start];
-		struct f2fs_sit_block *sit_blk;
-		struct f2fs_sit_entry sit;
-		struct page *page;
-		int i;
-
-		mutex_lock(&curseg->curseg_mutex);
-		for (i = 0; i < sits_in_cursum(sum); i++) {
-			if (le32_to_cpu(segno_in_journal(sum, i)) == start) {
-				sit = sit_in_journal(sum, i);
-				mutex_unlock(&curseg->curseg_mutex);
-				goto got_it;
+	int sit_blk_cnt = SIT_BLK_CNT(sbi);
+	unsigned int i, start, end;
+	unsigned int readed, start_blk = 0;
+	int nrpages = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+	
+	do {
+		readed = ra_sit_pages(sbi, start_blk, nrpages);
+
+		start = start_blk * sit_i->sents_per_block;
+		end = (start_blk + readed) * sit_i->sents_per_block;
+
+		for (; start < end && start < TOTAL_SEGS(sbi); start++) {
+			struct seg_entry *se = &sit_i->sentries[start];
+			struct f2fs_sit_block *sit_blk;
+			struct f2fs_sit_entry sit;
+			struct page *page;
+
+			mutex_lock(&curseg->curseg_mutex);
+			for (i = 0; i < sits_in_cursum(sum); i++) {
+				if (le32_to_cpu(segno_in_journal(sum, i)) == start) {
+					sit = sit_in_journal(sum, i);
+					mutex_unlock(&curseg->curseg_mutex);
+					goto got_it;
+				}
 			}
-		}
-		mutex_unlock(&curseg->curseg_mutex);
-		page = get_current_sit_page(sbi, start);
-		sit_blk = (struct f2fs_sit_block *)page_address(page);
-		sit = sit_blk->entries[SIT_ENTRY_OFFSET(sit_i, start)];
-		f2fs_put_page(page, 1);
+			mutex_unlock(&curseg->curseg_mutex);
+
+			page = get_current_sit_page(sbi, start);
+			sit_blk = (struct f2fs_sit_block *)page_address(page);
+			sit = sit_blk->entries[SIT_ENTRY_OFFSET(sit_i, start)];
+			f2fs_put_page(page, 1);
 got_it:
-		check_block_count(sbi, start, &sit);
-		seg_info_from_raw_sit(se, &sit);
-		if (sbi->segs_per_sec > 1) {
-			struct sec_entry *e = get_sec_entry(sbi, start);
-			e->valid_blocks += se->valid_blocks;
+			check_block_count(sbi, start, &sit);
+			seg_info_from_raw_sit(se, &sit);
+			if (sbi->segs_per_sec > 1) {
+				struct sec_entry *e = get_sec_entry(sbi, start);
+				e->valid_blocks += se->valid_blocks;
+			}
 		}
-	}
+		start_blk += readed;
+	} while (start_blk < sit_blk_cnt);
 }
 
 static void init_free_segmap(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 269f690..ad5b9f1 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -83,6 +83,8 @@
 	(segno / SIT_ENTRY_PER_BLOCK)
 #define	START_SEGNO(sit_i, segno)		\
 	(SIT_BLOCK_OFFSET(sit_i, segno) * SIT_ENTRY_PER_BLOCK)
+#define SIT_BLK_CNT(sbi)			\
+	((TOTAL_SEGS(sbi) + SIT_ENTRY_PER_BLOCK - 1) / SIT_ENTRY_PER_BLOCK)
 #define f2fs_bitmap_size(nr)			\
 	(BITS_TO_LONGS(nr) * sizeof(unsigned long))
 #define TOTAL_SEGS(sbi)	(SM_I(sbi)->main_segments)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
  2013-11-22  1:09 [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance Chao Yu
@ 2013-11-22  9:10 ` Jaegeuk Kim
  2013-11-23  2:53   ` Chao Yu
  2013-11-24  4:26 ` Jaegeuk Kim
  1 sibling, 1 reply; 6+ messages in thread
From: Jaegeuk Kim @ 2013-11-22  9:10 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, 谭姝

Hi,

Just one niptick.

2013-11-22 (금), 09:09 +0800, Chao Yu:
> Previously we read sit entries page one by one, this method lost the chance 
> of reading contiguous page together. So we read pages as contiguous as 
> possible for better mount performance.
> 
> change log:
>  o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng 
>    suggested.
>  o add mark_page_accessed() before release page to delay VM reclaiming.
>  o remove '*order' for simplification of function as Jaegeuk Kim suggested.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>  fs/f2fs/segment.c |  103 +++++++++++++++++++++++++++++++++++++++--------------
>  fs/f2fs/segment.h |    2 ++
>  2 files changed, 78 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 8149eba..998e7d3 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -14,6 +14,7 @@
>  #include <linux/blkdev.h>
>  #include <linux/prefetch.h>
>  #include <linux/vmalloc.h>
> +#include <linux/swap.h>
>  
>  #include "f2fs.h"
>  #include "segment.h"
> @@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
>  	return restore_curseg_summaries(sbi);
>  }
>  
> +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
> +{
> +	struct address_space *mapping = sbi->meta_inode->i_mapping;
> +	struct page *page;
> +	block_t blk_addr, prev_blk_addr = 0;
> +	int sit_blk_cnt = SIT_BLK_CNT(sbi);

Can we remove SIT_BLK_CNT by replacing with sit_i->sit_blocks?

-- 
Jaegeuk Kim
Samsung


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
  2013-11-22  9:10 ` Jaegeuk Kim
@ 2013-11-23  2:53   ` Chao Yu
  2013-11-24  4:05     ` Jaegeuk Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Chao Yu @ 2013-11-23  2:53 UTC (permalink / raw)
  To: jaegeuk.kim
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel,
	'谭姝'

Hi,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk.kim@samsung.com]
> Sent: Friday, November 22, 2013 5:11 PM
> To: Chao Yu
> Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net; 谭姝
> Subject: Re: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
> 
> Hi,
> 
> Just one niptick.
> 
> 2013-11-22 (금), 09:09 +0800, Chao Yu:
> > Previously we read sit entries page one by one, this method lost the chance
> > of reading contiguous page together. So we read pages as contiguous as
> > possible for better mount performance.
> >
> > change log:
> >  o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng
> >    suggested.
> >  o add mark_page_accessed() before release page to delay VM reclaiming.
> >  o remove '*order' for simplification of function as Jaegeuk Kim suggested.
> >
> > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> > ---
> >  fs/f2fs/segment.c |  103 +++++++++++++++++++++++++++++++++++++++--------------
> >  fs/f2fs/segment.h |    2 ++
> >  2 files changed, 78 insertions(+), 27 deletions(-)
> >
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index 8149eba..998e7d3 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -14,6 +14,7 @@
> >  #include <linux/blkdev.h>
> >  #include <linux/prefetch.h>
> >  #include <linux/vmalloc.h>
> > +#include <linux/swap.h>
> >
> >  #include "f2fs.h"
> >  #include "segment.h"
> > @@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
> >  	return restore_curseg_summaries(sbi);
> >  }
> >
> > +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
> > +{
> > +	struct address_space *mapping = sbi->meta_inode->i_mapping;
> > +	struct page *page;
> > +	block_t blk_addr, prev_blk_addr = 0;
> > +	int sit_blk_cnt = SIT_BLK_CNT(sbi);
> 
> Can we remove SIT_BLK_CNT by replacing with sit_i->sit_blocks?

Because sit_i->sit_blocks is a multiple of segment size(i.e. 512/1024),
but we may use part of sit_blocks, not all of them. So it's waste to read 
all of them.
What's your opinion?

Regards,
Yu

> 
> --
> Jaegeuk Kim
> Samsung


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
  2013-11-23  2:53   ` Chao Yu
@ 2013-11-24  4:05     ` Jaegeuk Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2013-11-24  4:05 UTC (permalink / raw)
  To: Chao Yu
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel,
	'谭姝'

Hi,

2013-11-23 (토), 10:53 +0800, Chao Yu:
> Hi,
> 
> > -----Original Message-----
> > From: Jaegeuk Kim [mailto:jaegeuk.kim@samsung.com]
> > Sent: Friday, November 22, 2013 5:11 PM
> > To: Chao Yu
> > Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net; 谭姝
> > Subject: Re: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
> > 
> > Hi,
> > 
> > Just one niptick.
> > 
> > 2013-11-22 (금), 09:09 +0800, Chao Yu:
> > > Previously we read sit entries page one by one, this method lost the chance
> > > of reading contiguous page together. So we read pages as contiguous as
> > > possible for better mount performance.
> > >
> > > change log:
> > >  o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng
> > >    suggested.
> > >  o add mark_page_accessed() before release page to delay VM reclaiming.
> > >  o remove '*order' for simplification of function as Jaegeuk Kim suggested.
> > >
> > > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> > > ---
> > >  fs/f2fs/segment.c |  103 +++++++++++++++++++++++++++++++++++++++--------------
> > >  fs/f2fs/segment.h |    2 ++
> > >  2 files changed, 78 insertions(+), 27 deletions(-)
> > >
> > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > > index 8149eba..998e7d3 100644
> > > --- a/fs/f2fs/segment.c
> > > +++ b/fs/f2fs/segment.c
> > > @@ -14,6 +14,7 @@
> > >  #include <linux/blkdev.h>
> > >  #include <linux/prefetch.h>
> > >  #include <linux/vmalloc.h>
> > > +#include <linux/swap.h>
> > >
> > >  #include "f2fs.h"
> > >  #include "segment.h"
> > > @@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
> > >  	return restore_curseg_summaries(sbi);
> > >  }
> > >
> > > +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
> > > +{
> > > +	struct address_space *mapping = sbi->meta_inode->i_mapping;
> > > +	struct page *page;
> > > +	block_t blk_addr, prev_blk_addr = 0;
> > > +	int sit_blk_cnt = SIT_BLK_CNT(sbi);
> > 
> > Can we remove SIT_BLK_CNT by replacing with sit_i->sit_blocks?
> 
> Because sit_i->sit_blocks is a multiple of segment size(i.e. 512/1024),
> but we may use part of sit_blocks, not all of them. So it's waste to read 
> all of them.
> What's your opinion?

Got it.
It's right and we can avoid that.
Thanks, :)

-- 
Jaegeuk Kim
Samsung


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
  2013-11-22  1:09 [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance Chao Yu
  2013-11-22  9:10 ` Jaegeuk Kim
@ 2013-11-24  4:26 ` Jaegeuk Kim
  2013-11-25  1:33   ` Chao Yu
  1 sibling, 1 reply; 6+ messages in thread
From: Jaegeuk Kim @ 2013-11-24  4:26 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, 谭姝

Hi,

2013-11-22 (금), 09:09 +0800, Chao Yu:
> Previously we read sit entries page one by one, this method lost the chance 
> of reading contiguous page together. So we read pages as contiguous as 
> possible for better mount performance.
> 
> change log:
>  o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng 
>    suggested.
>  o add mark_page_accessed() before release page to delay VM reclaiming.
>  o remove '*order' for simplification of function as Jaegeuk Kim suggested.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
>  fs/f2fs/segment.c |  103 +++++++++++++++++++++++++++++++++++++++--------------
>  fs/f2fs/segment.h |    2 ++
>  2 files changed, 78 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 8149eba..998e7d3 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -14,6 +14,7 @@
>  #include <linux/blkdev.h>
>  #include <linux/prefetch.h>
>  #include <linux/vmalloc.h>
> +#include <linux/swap.h>
>  
>  #include "f2fs.h"
>  #include "segment.h"
> @@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
>  	return restore_curseg_summaries(sbi);
>  }
>  
> +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
> +{
> +	struct address_space *mapping = sbi->meta_inode->i_mapping;
> +	struct page *page;
> +	block_t blk_addr, prev_blk_addr = 0;
> +	int sit_blk_cnt = SIT_BLK_CNT(sbi);
> +	int blkno = start;
> +
> +	for (; blkno < start + nrpages && blkno < sit_blk_cnt; blkno++) {
> +
> +		blk_addr = current_sit_addr(sbi, start * SIT_ENTRY_PER_BLOCK);

Should be:
	blk_addr = current_sit_addr(sbi, blkno * SIT_ENTRY_PER_BLOCK);
	                                -------
I'll fix this and merge the patch though.
Thanks,

-- 
Jaegeuk Kim
Samsung


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
  2013-11-24  4:26 ` Jaegeuk Kim
@ 2013-11-25  1:33   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2013-11-25  1:33 UTC (permalink / raw)
  To: jaegeuk.kim
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel,
	'谭姝'

Hi,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk.kim@samsung.com]
> Sent: Sunday, November 24, 2013 12:26 PM
> To: Chao Yu
> Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net; 谭姝
> Subject: Re: [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance
> 
> Hi,
> 
> 2013-11-22 (금), 09:09 +0800, Chao Yu:
> > Previously we read sit entries page one by one, this method lost the chance
> > of reading contiguous page together. So we read pages as contiguous as
> > possible for better mount performance.
> >
> > change log:
> >  o merge judgements/use 'Continue' or 'Break' instead of 'Goto' as Gu Zheng
> >    suggested.
> >  o add mark_page_accessed() before release page to delay VM reclaiming.
> >  o remove '*order' for simplification of function as Jaegeuk Kim suggested.
> >
> > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> > ---
> >  fs/f2fs/segment.c |  103 +++++++++++++++++++++++++++++++++++++++--------------
> >  fs/f2fs/segment.h |    2 ++
> >  2 files changed, 78 insertions(+), 27 deletions(-)
> >
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index 8149eba..998e7d3 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -14,6 +14,7 @@
> >  #include <linux/blkdev.h>
> >  #include <linux/prefetch.h>
> >  #include <linux/vmalloc.h>
> > +#include <linux/swap.h>
> >
> >  #include "f2fs.h"
> >  #include "segment.h"
> > @@ -1488,41 +1489,89 @@ static int build_curseg(struct f2fs_sb_info *sbi)
> >  	return restore_curseg_summaries(sbi);
> >  }
> >
> > +static int ra_sit_pages(struct f2fs_sb_info *sbi, int start, int nrpages)
> > +{
> > +	struct address_space *mapping = sbi->meta_inode->i_mapping;
> > +	struct page *page;
> > +	block_t blk_addr, prev_blk_addr = 0;
> > +	int sit_blk_cnt = SIT_BLK_CNT(sbi);
> > +	int blkno = start;
> > +
> > +	for (; blkno < start + nrpages && blkno < sit_blk_cnt; blkno++) {
> > +
> > +		blk_addr = current_sit_addr(sbi, start * SIT_ENTRY_PER_BLOCK);
> 
> Should be:
> 	blk_addr = current_sit_addr(sbi, blkno * SIT_ENTRY_PER_BLOCK);
> 	                                -------
> I'll fix this and merge the patch though.
> Thanks,

Oh, It's my mistake, sorry for that.
Thanks for your review! :)

> 
> --
> Jaegeuk Kim
> Samsung


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-25  1:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-22  1:09 [f2fs-dev] [PATCH V3 2/2] f2fs: read contiguous sit entry pages by merging for mount performance Chao Yu
2013-11-22  9:10 ` Jaegeuk Kim
2013-11-23  2:53   ` Chao Yu
2013-11-24  4:05     ` Jaegeuk Kim
2013-11-24  4:26 ` Jaegeuk Kim
2013-11-25  1:33   ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).