mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>, <chao@kernel.org>,
	Chen Gong <gongchen4@huawei.com>
Subject: Re: [PATCH v2] f2fs: allocate memory in batch in build_sit_info()
Date: Tue, 20 Aug 2019 17:12:16 +0800	[thread overview]
Message-ID: <99a2713a-50d2-8a77-87d9-661ab7ed3a0c@huawei.com> (raw)
In-Reply-To: <20190819202007.GA23891@jaegeuk-macbookpro.roam.corp.google.com>

On 2019/8/20 4:20, Jaegeuk Kim wrote:
> On 07/26, Chao Yu wrote:
>> build_sit_info() allocate all bitmaps for each segment one by one,
>> it's quite low efficiency, this pach changes to allocate large
>> continuous memory at a time, and divide it and assign for each bitmaps
>> of segment. For large size image, it can expect improving its mount
>> speed.
> 
> Hmm, I hit a kernel panic when mounting a partition during fault injection test:
> 
> 726 #ifdef CONFIG_F2FS_CHECK_FS
> 727         if (f2fs_test_bit(offset, sit_i->sit_bitmap) !=
> 728                         f2fs_test_bit(offset, sit_i->sit_bitmap_mir))
> 729                 f2fs_bug_on(sbi, 1);
> 730 #endif

We didn't change anything about sit_i->sit_bitmap{_mir,}, it's so wired we panic
here... :(

I double check the change, but find nothing suspicious, btw, my fault injection
testcase shows normal.

Jaegeuk, do you have any idea about this issue?

Thanks,

> 
> For your information, I'm testing without this patch.
> 
> Thanks,
> 
>>
>> Signed-off-by: Chen Gong <gongchen4@huawei.com>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> v2:
>> - fix warning triggered in kmalloc() if requested memory size exceeds 4MB.
>>  fs/f2fs/segment.c | 51 +++++++++++++++++++++--------------------------
>>  fs/f2fs/segment.h |  1 +
>>  2 files changed, 24 insertions(+), 28 deletions(-)
>>
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index a661ac32e829..d720eacd9c57 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -3941,7 +3941,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
>>  	struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
>>  	struct sit_info *sit_i;
>>  	unsigned int sit_segs, start;
>> -	char *src_bitmap;
>> +	char *src_bitmap, *bitmap;
>>  	unsigned int bitmap_size;
>>  
>>  	/* allocate memory for SIT information */
>> @@ -3964,27 +3964,31 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
>>  	if (!sit_i->dirty_sentries_bitmap)
>>  		return -ENOMEM;
>>  
>> +#ifdef CONFIG_F2FS_CHECK_FS
>> +	bitmap_size = MAIN_SEGS(sbi) * SIT_VBLOCK_MAP_SIZE * 4;
>> +#else
>> +	bitmap_size = MAIN_SEGS(sbi) * SIT_VBLOCK_MAP_SIZE * 3;
>> +#endif
>> +	sit_i->bitmap = f2fs_kvzalloc(sbi, bitmap_size, GFP_KERNEL);
>> +	if (!sit_i->bitmap)
>> +		return -ENOMEM;
>> +
>> +	bitmap = sit_i->bitmap;
>> +
>>  	for (start = 0; start < MAIN_SEGS(sbi); start++) {
>> -		sit_i->sentries[start].cur_valid_map
>> -			= f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE, GFP_KERNEL);
>> -		sit_i->sentries[start].ckpt_valid_map
>> -			= f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE, GFP_KERNEL);
>> -		if (!sit_i->sentries[start].cur_valid_map ||
>> -				!sit_i->sentries[start].ckpt_valid_map)
>> -			return -ENOMEM;
>> +		sit_i->sentries[start].cur_valid_map = bitmap;
>> +		bitmap += SIT_VBLOCK_MAP_SIZE;
>> +
>> +		sit_i->sentries[start].ckpt_valid_map = bitmap;
>> +		bitmap += SIT_VBLOCK_MAP_SIZE;
>>  
>>  #ifdef CONFIG_F2FS_CHECK_FS
>> -		sit_i->sentries[start].cur_valid_map_mir
>> -			= f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE, GFP_KERNEL);
>> -		if (!sit_i->sentries[start].cur_valid_map_mir)
>> -			return -ENOMEM;
>> +		sit_i->sentries[start].cur_valid_map_mir = bitmap;
>> +		bitmap += SIT_VBLOCK_MAP_SIZE;
>>  #endif
>>  
>> -		sit_i->sentries[start].discard_map
>> -			= f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE,
>> -							GFP_KERNEL);
>> -		if (!sit_i->sentries[start].discard_map)
>> -			return -ENOMEM;
>> +		sit_i->sentries[start].discard_map = bitmap;
>> +		bitmap += SIT_VBLOCK_MAP_SIZE;
>>  	}
>>  
>>  	sit_i->tmp_map = f2fs_kzalloc(sbi, SIT_VBLOCK_MAP_SIZE, GFP_KERNEL);
>> @@ -4492,21 +4496,12 @@ static void destroy_free_segmap(struct f2fs_sb_info *sbi)
>>  static void destroy_sit_info(struct f2fs_sb_info *sbi)
>>  {
>>  	struct sit_info *sit_i = SIT_I(sbi);
>> -	unsigned int start;
>>  
>>  	if (!sit_i)
>>  		return;
>>  
>> -	if (sit_i->sentries) {
>> -		for (start = 0; start < MAIN_SEGS(sbi); start++) {
>> -			kvfree(sit_i->sentries[start].cur_valid_map);
>> -#ifdef CONFIG_F2FS_CHECK_FS
>> -			kvfree(sit_i->sentries[start].cur_valid_map_mir);
>> -#endif
>> -			kvfree(sit_i->sentries[start].ckpt_valid_map);
>> -			kvfree(sit_i->sentries[start].discard_map);
>> -		}
>> -	}
>> +	if (sit_i->sentries)
>> +		kvfree(sit_i->bitmap);
>>  	kvfree(sit_i->tmp_map);
>>  
>>  	kvfree(sit_i->sentries);
>> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
>> index b74602813a05..ec4d568fd58c 100644
>> --- a/fs/f2fs/segment.h
>> +++ b/fs/f2fs/segment.h
>> @@ -226,6 +226,7 @@ struct sit_info {
>>  	block_t sit_base_addr;		/* start block address of SIT area */
>>  	block_t sit_blocks;		/* # of blocks used by SIT area */
>>  	block_t written_valid_blocks;	/* # of valid blocks in main area */
>> +	char *bitmap;			/* all bitmaps pointer */
>>  	char *sit_bitmap;		/* SIT bitmap pointer */
>>  #ifdef CONFIG_F2FS_CHECK_FS
>>  	char *sit_bitmap_mir;		/* SIT bitmap mirror */
>> -- 
>> 2.18.0.rc1
> .
> 

  reply	other threads:[~2019-08-20  9:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26  7:41 Chao Yu
2019-08-19 20:20 ` Jaegeuk Kim
2019-08-20  9:12   ` Chao Yu [this message]
2019-08-20 17:41     ` Jaegeuk Kim
2019-08-22 17:47       ` [f2fs-dev] " Jaegeuk Kim
2019-08-23  1:10         ` 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=99a2713a-50d2-8a77-87d9-661ab7ed3a0c@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=chao@kernel.org \
    --cc=gongchen4@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®