From: Yuan Zhong <yuan.mark.zhong@samsung.com>
To: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: Jaegeuk Kim <jaegeuk.kim@samsung.com>,
"linux-f2fs-devel@lists.sourceforge.net"
<linux-f2fs-devel@lists.sourceforge.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
shu tan <shu.tan@samsung.com>
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: avoid congestion_wait when do_checkpoint for better performance
Date: Tue, 08 Oct 2013 11:30:14 +0000 (GMT) [thread overview]
Message-ID: <30722427.272521381231813403.JavaMail.weblogic@epml26> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252, Size: 5263 bytes --]
Hi Gu,
> Hi Yuan,
> On 10/08/2013 04:30 PM, Yuan Zhong wrote:
> > Previously, do_checkpoint() will call congestion_wait() for waiting the pages (previous submitted node/meta/data pages) to be written back.
> > Because congestion_wait() will set a regular period (e.g. HZ / 50 ) for waiting.
> > For this reason, there is a situation that after the pages have been written back,
> > but the checkpoint thread still wait for congestion_wait to exit.
> How do you confirm this issue?
I traced the execution path.
In f2fs_end_io_write, dec_page_count(p->sbi, F2FS_WRITEBACK) will be called.
And I found that, when pages of F2FS_WRITEBACK has been zero, but
checkpoint thread still congestion_wait for pages of F2FS_WRITEBACK to be zero.
So, I think this point could be improved.
And I wrote a simple test case and tested on Micro-SD card, the steps as following:
(a) create a fixed-size file (4KB)
(b) go on to sync the file
(c) go back to step #a (fixed numbers of cycling:1024)
The results indicated that the execution time is reduced greatly by using this patch.
> I suspect that the block-core does not have a wake-up mechanism
> when the back device is uncongested.
Yes, you are right.
So I wake up the checkpoint thread by myself, when pages of F2FS_WRITEBACK to be zero.
In f2fs_end_io_write, f2fs_writeback_wait is called.
you cloud find this code in my patch.
> > This is a problem here, especially, when sync a large number of small files or dirs.
> > In order to avoid this, a wait_list is introduced,
> > the checkpoint thread will be dropped into the wait_list if the pages have not been written back,
> > and will be waked up by contrast.
> Please pay some attention to the mail form, this mail is out of format in my mail client.
> Regards,
> Gu
Regards,
Yuan
> >
> > Signed-off-by: Yuan Zhong <yuan.mark.zhong@samsung.com>
> > ---
> > fs/f2fs/checkpoint.c | 3 +--
> > fs/f2fs/f2fs.h | 19 +++++++++++++++++++
> > fs/f2fs/segment.c | 1 +
> > fs/f2fs/super.c | 1 +
> > 4 files changed, 22 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> > index ca39442..5d69ae0 100644
> > --- a/fs/f2fs/checkpoint.c
> > +++ b/fs/f2fs/checkpoint.c
> > @@ -758,8 +758,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
> > f2fs_put_page(cp_page, 1);
> >
> > /* wait for previous submitted node/meta pages writeback */
> > - while (get_pages(sbi, F2FS_WRITEBACK))
> > - congestion_wait(BLK_RW_ASYNC, HZ / 50);
> > + f2fs_writeback_wait(sbi);
> >
> > filemap_fdatawait_range(sbi->node_inode->i_mapping, 0, LONG_MAX);
> > filemap_fdatawait_range(sbi->meta_inode->i_mapping, 0, LONG_MAX);
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index 7fd99d8..4b0d70e 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -18,6 +18,8 @@
> > #include <linux/crc32.h>
> > #include <linux/magic.h>
> > #include <linux/kobject.h>
> > +#include <linux/wait.h>
> > +#include <linux/sched.h>
> >
> > /*
> > * For mount options
> > @@ -368,6 +370,7 @@ struct f2fs_sb_info {
> > struct mutex fs_lock[NR_GLOBAL_LOCKS]; /* blocking FS operations */
> > struct mutex node_write; /* locking node writes */
> > struct mutex writepages; /* mutex for writepages() */
> > + wait_queue_head_t writeback_wqh; /* wait_queue for writeback */
> > unsigned char next_lock_num; /* round-robin global locks */
> > int por_doing; /* recovery is doing or not */
> > int on_build_free_nids; /* build_free_nids is doing */
> > @@ -961,6 +964,22 @@ static inline int f2fs_readonly(struct super_block *sb)
> > return sb->s_flags & MS_RDONLY;
> > }
> >
> > +static inline void f2fs_writeback_wait(struct f2fs_sb_info *sbi)
> > +{
> > + DEFINE_WAIT(wait);
> > +
> > + prepare_to_wait(&sbi->writeback_wqh, &wait, TASK_UNINTERRUPTIBLE);
> > + if (get_pages(sbi, F2FS_WRITEBACK))
> > + io_schedule();
> > + finish_wait(&sbi->writeback_wqh, &wait);
> > +}
> > +
> > +static inline void f2fs_writeback_wake(struct f2fs_sb_info *sbi)
> > +{
> > + if (!get_pages(sbi, F2FS_WRITEBACK))
> > + wake_up_all(&sbi->writeback_wqh);
> > +}
> > +
> > /*
> > * file.c
> > */
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index bd79bbe..0708aa9 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -597,6 +597,7 @@ static void f2fs_end_io_write(struct bio *bio, int err)
> >
> > if (p->is_sync)
> > complete(p->wait);
> > + f2fs_writeback_wake(p->sbi);
> > kfree(p);
> > bio_put(bio);
> > }
> > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> > index 094ccc6..3ac6d85 100644
> > --- a/fs/f2fs/super.c
> > +++ b/fs/f2fs/super.c
> > @@ -835,6 +835,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
> > mutex_init(&sbi->gc_mutex);
> > mutex_init(&sbi->writepages);
> > mutex_init(&sbi->cp_mutex);
> > + init_waitqueue_head(&sbi->writeback_wqh);
> > for (i = 0; i < NR_GLOBAL_LOCKS; i++)
> > mutex_init(&sbi->fs_lock[i]);
> > mutex_init(&sbi->node_write);ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next reply other threads:[~2013-10-08 11:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 11:30 Yuan Zhong [this message]
2013-10-09 4:04 ` [f2fs-dev] [PATCH v2] f2fs: avoid congestion_wait when do_checkpoint for better performance Gu Zheng
[not found] ` <BLU175-W48D340F1A4D0966D8895D0B41E0@phx.gbl>
2013-10-10 8:11 ` Gu Zheng
[not found] ` <BLU175-W378B020AC54C62046132AAB41E0@phx.gbl>
2013-10-11 2:16 ` Gu Zheng
-- strict thread matches above, loose matches on Subject: below --
2013-10-09 5:58 Yuan Zhong
2013-10-08 8:30 Yuan Zhong
2013-10-08 9:37 ` Gu Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30722427.272521381231813403.JavaMail.weblogic@epml26 \
--to=yuan.mark.zhong@samsung.com \
--cc=guz.fnst@cn.fujitsu.com \
--cc=jaegeuk.kim@samsung.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shu.tan@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox