Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1954790ybt; Thu, 2 Jul 2020 19:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK+Mibtawsl768kWxAQSVxO7PvThMcu1tjIm0IFoQ5tt+BPktOsQe1JpWnXFpkTieaM9oS X-Received: by 2002:a05:6402:3058:: with SMTP id bu24mr20710035edb.242.1593742494440; Thu, 02 Jul 2020 19:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593742494; cv=none; d=google.com; s=arc-20160816; b=Hi/AZ7ua5IsftjilB5aU4AXOZUGUGOzcSKt1xHSL41rw87n9wBIZE2BY9jUQ3ZUp4U 1O1xGr6yCbBVIJDkSTPud0n8kx6Wn/IyHCgTYJmneOrPbnJyMg9JBeFy8xRsBTAQIskO 0SYg2QymOxlewo5XtVhQheudcJHBKUTx4e+OzJovQMjXHNczAayPsDfFhWKoNxKh07r1 aqYij+uGjv0YntAomr0/Hk8Qy2Ec1XBAfaoEWki00J5sWSgdovg7XVoryEUVGEybBkMO hLxCZcUf7Q9BlsISx0bs1oWAep0yePdrNoJy1M5+uokIEd3fe/haHko8ETmH5Yd88L36 gFDQ== 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=wwqTjgCMlwxcbcZGemOfcEty2C+GpcanAUM4E0SaIQA=; b=EKWK4y3aYsTpsfYsnr2CGEc3WaovvzzesBP5ylqP0bsv5va1Mn5Vrdby6NOZs1EAao J9rakJ4VWqzctBxfMgUfWArLrmT80WOx+d7V/ikXyCGxf8dcHJNGDDG1+AxlY9lhqLtq zDs2ZobsdHNZOUqajpu3JlyFa/E3sKsYcTcy6bwbwyyNbOToqPh+VRtgiWEXG5kobJ/n LkapNYNLC3qsDKq6muAPABcf19zXIlackJozdcg4OhrlS+0i/x4Xupk2UQdxPwm+1j6m NkdCDnGlUGQnXuvgTiaZnaNBc2mGDyuFiHsR6WqT0gA/UlTG8LvibCbY7XSnr/DoE2+i /Hug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz22si6415346ejb.742.2020.07.02.19.14.31; Thu, 02 Jul 2020 19:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726048AbgGCCNX (ORCPT + 99 others); Thu, 2 Jul 2020 22:13:23 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:60292 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726030AbgGCCNX (ORCPT ); Thu, 2 Jul 2020 22:13:23 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id ABB822F59E07BC97FD66; Fri, 3 Jul 2020 10:13:20 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.201) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 3 Jul 2020 10:13:17 +0800 Subject: Re: [PATCH RFC 2/5] f2fs: record average update time of segment To: Jaegeuk Kim CC: , , References: <20200630100428.19105-1-yuchao0@huawei.com> <20200630100428.19105-2-yuchao0@huawei.com> <20200701161927.GD1724572@google.com> From: Chao Yu Message-ID: <70776961-0430-0a9f-cf26-09a2cc192b07@huawei.com> Date: Fri, 3 Jul 2020 10:13:17 +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: <20200701161927.GD1724572@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 2020/7/2 0:19, Jaegeuk Kim wrote: > On 06/30, Chao Yu wrote: >> Previously, once we update one block in segment, we will update mtime of >> segment to last time, making aged segment becoming freshest, result in >> that GC with cost benefit algorithm missing such segment, So this patch >> changes to record mtime as average block updating time instead of last >> updating time. >> >> It's not needed to reset mtime for prefree segment, as se->valid_blocks >> is zero, then old se->mtime won't take any weight with below calculation: >> >> se->mtime = (se->mtime * se->valid_blocks + mtime) / >> (se->valid_blocks + 1); >> >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/segment.c | 21 ++++++++++++++++++--- >> 1 file changed, 18 insertions(+), 3 deletions(-) >> >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index 863ec6f1fb87..906c313835ad 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -2150,6 +2150,22 @@ static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type, >> __mark_sit_entry_dirty(sbi, segno); >> } >> >> +static void update_segment_mtime(struct f2fs_sb_info *sbi, block_t blkaddr) >> +{ >> + unsigned int segno = GET_SEGNO(sbi, blkaddr); >> + struct seg_entry *se = get_seg_entry(sbi, segno); >> + unsigned long long mtime = get_mtime(sbi, false); >> + >> + if (!se->mtime) { > > Don't need {}. Updated, BTW, have fixed below compile error: m68k-linux-ld: fs/f2fs/segment.o: in function `update_segment_mtime': fs/f2fs/segment.c:2162: undefined reference to `__udivdi3' Thanks, > >> + se->mtime = mtime; >> + } else { >> + se->mtime = (se->mtime * se->valid_blocks + mtime) / >> + (se->valid_blocks + 1); >> + } >> + if (mtime > SIT_I(sbi)->max_mtime) >> + SIT_I(sbi)->max_mtime = mtime; >> +} >> + >> static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) >> { >> struct seg_entry *se; >> @@ -2169,10 +2185,9 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) >> f2fs_bug_on(sbi, (new_vblocks >> (sizeof(unsigned short) << 3) || >> (new_vblocks > sbi->blocks_per_seg))); >> >> + update_segment_mtime(sbi, blkaddr); >> + >> se->valid_blocks = new_vblocks; >> - se->mtime = get_mtime(sbi, false); >> - if (se->mtime > SIT_I(sbi)->max_mtime) >> - SIT_I(sbi)->max_mtime = se->mtime; >> >> /* Update valid block bitmap */ >> if (del > 0) { >> -- >> 2.26.2 > . >