Re: [patch 3/4] jffs2: avoid soft-lockup in jffs2_reserve_space_gc()

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

 



>>  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!

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]