All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizefan@huawei.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org, artem.bityutskiy@linux.intel.com,
	akpm@linux-foundation.org, dwmw2@infradead.org,
	stable@vger.kernel.org
Subject: Re: [patch 3/4] jffs2: avoid soft-lockup in jffs2_reserve_space_gc()
Date: Wed, 26 Feb 2014 20:04:13 +0800	[thread overview]
Message-ID: <530DD83D.5090507@huawei.com> (raw)
In-Reply-To: <20140226021709.GD4194@ld-irv-0074>

>>  fs/jffs2/nodemgmt.c |   13 +++++++++----
>>  1 file changed, 9 insertions(+), 4 deletions(-)
>>
>> diff -puN fs/jffs2/nodemgmt.c~jffs2-avoid-soft-lockup-in-jffs2_reserve_space_gc fs/jffs2/nodemgmt.c
>> --- a/fs/jffs2/nodemgmt.c~jffs2-avoid-soft-lockup-in-jffs2_reserve_space_gc
>> +++ a/fs/jffs2/nodemgmt.c
>> @@ -211,20 +211,25 @@ out:
>>  int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
>>  			   uint32_t *len, uint32_t sumsize)
>>  {
>> -	int ret = -EAGAIN;
>> +	int ret;
>>  	minsize = PAD(minsize);
>>  
>>  	jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize);
>>  
>> -	spin_lock(&c->erase_completion_lock);
>> -	while(ret == -EAGAIN) {
>> +	while (true) {
>> +		spin_lock(&c->erase_completion_lock);
>>  		ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
>>  		if (ret) {
>>  			jffs2_dbg(1, "%s(): looping, ret is %d\n",
>>  				  __func__, ret);
>>  		}
>> +		spin_unlock(&c->erase_completion_lock);
>> +
>> +		if (ret == -EAGAIN)
>> +			cond_resched();
> 
> Just curious: would this be a place to use cond_resched_lock(), and keep
> the lock outside the loop?
> 

Yeah, cond_resched_lock() can be used too, but doesn't make much difference.
This patch adds 5 LOC, and using cond_resched_lock() will also add 5 LOC.

As you've already merged it, I think it isn't worth borthing to make this change.

diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 0331072..36e9538 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -223,6 +223,11 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t mi
nsize,
                        jffs2_dbg(1, "%s(): looping, ret is %d\n",
                                  __func__, ret);
                }
+
+               if (ret == -EAGAIN)
+                       cond_resched_lock(&c->erease_completion_lock);
+               else
+                       break;
        }
        spin_unlock(&c->erase_completion_lock);


>> +		else
>> +			break;
>>  	}
>> -	spin_unlock(&c->erase_completion_lock);
>>  	if (!ret)
>>  		ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1);
>>  
> 
> Anyway, pushed to l2-mtd.git.
> 

Thanks!

      reply	other threads:[~2014-02-26 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140212204456.E010B5A40F6@corp2gmr1-2.hot.corp.google.com>
2014-02-26  2:17 ` [patch 3/4] jffs2: avoid soft-lockup in jffs2_reserve_space_gc() Brian Norris
2014-02-26 12:04   ` Li Zefan [this message]

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=530DD83D.5090507@huawei.com \
    --to=lizefan@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=stable@vger.kernel.org \
    /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.