From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: shrink spinlock coverage
Date: Thu, 7 May 2020 05:49:19 -0700 [thread overview]
Message-ID: <20200507124919.GA197114@google.com> (raw)
In-Reply-To: <f577a7a8-298f-cdda-7627-1273f83c261c@huawei.com>
On 05/07, Chao Yu wrote:
> On 2020/5/6 23:05, Jaegeuk Kim wrote:
> > On 05/06, Chao Yu wrote:
> >> In f2fs_try_to_free_nids(), .nid_list_lock spinlock critical region will
> >> increase as expected shrink number increase, to avoid spining other CPUs
> >> for long time, it's better to implement like extent cache and nats
> >> shrinker.
> >>
> >> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> >> ---
> >> v2:
> >> - fix unlock wrong spinlock.
> >> fs/f2fs/node.c | 15 +++++++++++----
> >> 1 file changed, 11 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> >> index 4da0d8713df5..ad0b14f4dab8 100644
> >> --- a/fs/f2fs/node.c
> >> +++ b/fs/f2fs/node.c
> >> @@ -2488,7 +2488,6 @@ void f2fs_alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
> >> int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
> >> {
> >> struct f2fs_nm_info *nm_i = NM_I(sbi);
> >> - struct free_nid *i, *next;
> >> int nr = nr_shrink;
> >>
> >> if (nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS)
> >> @@ -2498,14 +2497,22 @@ int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
> >> return 0;
> >>
> >> spin_lock(&nm_i->nid_list_lock);
> >> - list_for_each_entry_safe(i, next, &nm_i->free_nid_list, list) {
> >> - if (nr_shrink <= 0 ||
> >> - nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS)
> >> + while (nr_shrink) {
> >> + struct free_nid *i;
> >> +
> >> + if (nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS)
> >> break;
> >>
> >> + i = list_first_entry(&nm_i->free_nid_list,
> >> + struct free_nid, list);
> >> + list_del(&i->list);
> >> + spin_unlock(&nm_i->nid_list_lock);
> >> +
> >> __remove_free_nid(sbi, i, FREE_NID);
> >
> > __remove_free_nid() will do list_del again. btw, how about just splitting out
>
> Oh, my bad.
>
> How about moving __remove_free_nid into .nid_list_lock coverage?
>
> > given nr_shrink into multiple trials?
>
> Like this?
Yes.
>
> while (shrink) {
> batch = DEFAULT_BATCH_NUMBER; // 16
> spinlock();
> list_for_each_entry_safe() {
> if (!shrink || !batch)
> break;
> remove_item_from_list;
> shrink--;
> batch--;
> }
> spin_unlock();
> }
>
> Thanks,
>
> >
> >> kmem_cache_free(free_nid_slab, i);
> >> nr_shrink--;
> >> +
> >> + spin_lock(&nm_i->nid_list_lock);
> >> }
> >> spin_unlock(&nm_i->nid_list_lock);
> >> mutex_unlock(&nm_i->build_lock);
> >> --
> >> 2.18.0.rc1
> > .
> >
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, chao@kernel.org
Subject: Re: [PATCH v2] f2fs: shrink spinlock coverage
Date: Thu, 7 May 2020 05:49:19 -0700 [thread overview]
Message-ID: <20200507124919.GA197114@google.com> (raw)
In-Reply-To: <f577a7a8-298f-cdda-7627-1273f83c261c@huawei.com>
On 05/07, Chao Yu wrote:
> On 2020/5/6 23:05, Jaegeuk Kim wrote:
> > On 05/06, Chao Yu wrote:
> >> In f2fs_try_to_free_nids(), .nid_list_lock spinlock critical region will
> >> increase as expected shrink number increase, to avoid spining other CPUs
> >> for long time, it's better to implement like extent cache and nats
> >> shrinker.
> >>
> >> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> >> ---
> >> v2:
> >> - fix unlock wrong spinlock.
> >> fs/f2fs/node.c | 15 +++++++++++----
> >> 1 file changed, 11 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> >> index 4da0d8713df5..ad0b14f4dab8 100644
> >> --- a/fs/f2fs/node.c
> >> +++ b/fs/f2fs/node.c
> >> @@ -2488,7 +2488,6 @@ void f2fs_alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
> >> int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
> >> {
> >> struct f2fs_nm_info *nm_i = NM_I(sbi);
> >> - struct free_nid *i, *next;
> >> int nr = nr_shrink;
> >>
> >> if (nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS)
> >> @@ -2498,14 +2497,22 @@ int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
> >> return 0;
> >>
> >> spin_lock(&nm_i->nid_list_lock);
> >> - list_for_each_entry_safe(i, next, &nm_i->free_nid_list, list) {
> >> - if (nr_shrink <= 0 ||
> >> - nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS)
> >> + while (nr_shrink) {
> >> + struct free_nid *i;
> >> +
> >> + if (nm_i->nid_cnt[FREE_NID] <= MAX_FREE_NIDS)
> >> break;
> >>
> >> + i = list_first_entry(&nm_i->free_nid_list,
> >> + struct free_nid, list);
> >> + list_del(&i->list);
> >> + spin_unlock(&nm_i->nid_list_lock);
> >> +
> >> __remove_free_nid(sbi, i, FREE_NID);
> >
> > __remove_free_nid() will do list_del again. btw, how about just splitting out
>
> Oh, my bad.
>
> How about moving __remove_free_nid into .nid_list_lock coverage?
>
> > given nr_shrink into multiple trials?
>
> Like this?
Yes.
>
> while (shrink) {
> batch = DEFAULT_BATCH_NUMBER; // 16
> spinlock();
> list_for_each_entry_safe() {
> if (!shrink || !batch)
> break;
> remove_item_from_list;
> shrink--;
> batch--;
> }
> spin_unlock();
> }
>
> Thanks,
>
> >
> >> kmem_cache_free(free_nid_slab, i);
> >> nr_shrink--;
> >> +
> >> + spin_lock(&nm_i->nid_list_lock);
> >> }
> >> spin_unlock(&nm_i->nid_list_lock);
> >> mutex_unlock(&nm_i->build_lock);
> >> --
> >> 2.18.0.rc1
> > .
> >
next prev parent reply other threads:[~2020-05-07 12:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 10:45 [f2fs-dev] [PATCH v2] f2fs: shrink spinlock coverage Chao Yu
2020-05-06 10:45 ` Chao Yu
2020-05-06 15:05 ` [f2fs-dev] " Jaegeuk Kim
2020-05-06 15:05 ` Jaegeuk Kim
2020-05-07 3:03 ` [f2fs-dev] " Chao Yu
2020-05-07 3:03 ` Chao Yu
2020-05-07 12:49 ` Jaegeuk Kim [this message]
2020-05-07 12:49 ` Jaegeuk Kim
-- strict thread matches above, loose matches on Subject: below --
2020-05-08 9:50 [f2fs-dev] " Chao Yu
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=20200507124919.GA197114@google.com \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.