Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3789092ybl; Tue, 20 Aug 2019 02:13:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPKZvr4PunzwNFcrbsPlm+iw8lyhMHPW9aSQhtFikT9NAJh/PRS/bjpJ5goGDdfATZB1sV X-Received: by 2002:a17:90a:ad86:: with SMTP id s6mr13171697pjq.53.1566292421235; Tue, 20 Aug 2019 02:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566292421; cv=none; d=google.com; s=arc-20160816; b=DNkLOhXle18i/jsfu95DNumXLgAUr1o3HXzPWG/IWs9ZywL+G1jEsRT7/2WLEkFbhN wKzH/E0KG4p5fe4Mb5E+aAEvLNk1wvU27wPql90QvbYHVnrBgMUtgET+0Km6BnUWvLlf rcCfX9jqSxdbG549NtpP8XRITlxyLL235SimjyACZ1ZaiZ8jb7tYdAoVtPIY8BNZskRz 6FCY1gpsYE5GWLHTTo1CwOZZPIJMTr5+yel3GkS6dtQw3cHMl3kpQ/cxTtcWRMP8NuuB RltH9oIT6CT9Dg/7sNLr5++c4062dpGQeUGS8DJkJPlGX80sGwU3nxv9Y8KupwmxwrTx JLdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=yr4DWOS0wZ9pQnLznA6p79dP+OgDCCcVoOSKs0QoAnE=; b=UBsPbgOJynM4qWeZ6rarp2c3ZpZ2rp2LtUEP7WuvhimfW6wifGOF1FiPZgHD5oC/6g Hf0js0q0j/P4OWHMvnV1a2TNnd2pWx/s9U4dc2HPv5Y9cLOYI4xLXG4uzOvcHipPOIK8 p9GcXtbYC/A8eUCqOXG9ONNNwJjKWBB0hIE2iz67m4OdfrXQUTHm7Y0ffBzoDShjcv89 OjXUoJ+41+IB3JbShK2TAnUM7ljf3ihtfpZLzXfrAfcAT7ytLvuF1ofCkoS0jxY9OACi WaFGxkqLnb2CFFOV7bhRqk+w8EoTWLgdTZI5LX9bG/HuLiCWHgXHga5kzH8UD7MJro6w 5tVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h35si11451353pgm.183.2019.08.20.02.13.25; Tue, 20 Aug 2019 02:13:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729482AbfHTJMa (ORCPT + 99 others); Tue, 20 Aug 2019 05:12:30 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56128 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728771AbfHTJMa (ORCPT ); Tue, 20 Aug 2019 05:12:30 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D3DE6B93F5B37132134D; Tue, 20 Aug 2019 17:12:25 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 20 Aug 2019 17:12:17 +0800 Subject: Re: [PATCH v2] f2fs: allocate memory in batch in build_sit_info() To: Jaegeuk Kim CC: , , , Chen Gong References: <20190726074120.3278-1-yuchao0@huawei.com> <20190819202007.GA23891@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: <99a2713a-50d2-8a77-87d9-661ab7ed3a0c@huawei.com> Date: Tue, 20 Aug 2019 17:12:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190819202007.GA23891@jaegeuk-macbookpro.roam.corp.google.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> Signed-off-by: Chao Yu >> --- >> 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 > . >