Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp760604ybt; Wed, 1 Jul 2020 09:20:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY76Scw7IHHowt5qcABw0BOFQZgFlsXya6BXNferj8G7P1mLIkoAqQZkKq9yvfcnR7P6rS X-Received: by 2002:a17:906:1187:: with SMTP id n7mr18666529eja.161.1593620421804; Wed, 01 Jul 2020 09:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593620421; cv=none; d=google.com; s=arc-20160816; b=PI/cZzQHgMRR0XuopPqgYSHbqb/Wdrx9DaJZ1osu0sHdQJWT0DeUCcRYHGdiV4+9mL 9rLGJv7FZpZtltQl5z3mtEK51vZZ8HcwRbydPOJQ1SZFsjA+G0VQ1U4x9Z9iRNUAuhoE v90H8PS/19Y5ZemEtw0xCIGPFMIFYbEc3slBKNYdkwWp6sxeFSs8oYsT7J/eW08I0d9d WkGtNaNE7hiO6wsRlk9qSjJOMSq2gu9lk/WN0Ht9NugbgZslSw6tEKR37N4RLOtZmeWX gL0ygbvY/Fr5fwapsTgkwphKMQCil+c+6nLgW12DGqeC4ISpBGhooifO5IYQD9DnO8yr 8Ggg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=hN+bWmvhLyYMQqJwoiEqRT71K8opl4HQO++ciXq3Rt4=; b=hZmyPp4kISMHAEVxzodGc2qL5D8eMaKvLruZm6kvx4Izlro24S4u1WmayfJXKJdqsQ 8hencXBpeKm0qfgWfrP9wq2G8YSGf0dUJ3FszdWu4ZCOKw5v8ebEgqcVpdw7v1QouXAi WIOn5NELSDqIwF+qtzIoMAB+yOO/47OeCQdRkd0cWRDXsUaDnEUTJrmL5BEra8w5V6sl rDXv3SxV37PuG8JlmDMHvwFUEhkT0Dxs8IHWOGY83Niadqq8qgydt1yiIXxWXB6+kHYO UmPr9hH4s+EU9OQWDJyvLIr1tafQ2rrg9ufS02tZcLhab4zMNTrPuem3V/vifuev7sjr JfHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KHDPOc0F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci26si4012046ejc.715.2020.07.01.09.19.58; Wed, 01 Jul 2020 09:20:21 -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; dkim=pass header.i=@kernel.org header.s=default header.b=KHDPOc0F; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732154AbgGAQT3 (ORCPT + 99 others); Wed, 1 Jul 2020 12:19:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:46014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729019AbgGAQT2 (ORCPT ); Wed, 1 Jul 2020 12:19:28 -0400 Received: from localhost (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DDAC7207BB; Wed, 1 Jul 2020 16:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593620368; bh=2zNupGrsJWVvIy1EGdDug2tvMr8j7918+kyHDf++ejA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KHDPOc0FLDP3WLnhF3VbexIDJ4vOZBhmmYCWfOGkeAvEzeZAlnQFI9ozskQG1IBio c0UByb07z0wVjS5DmK3dTO14yPvWnf5hFOz7qdeQMQcOBfWfPFvNEXweF6F3J5pImm /jMBf9Kpd7HLKQKcvg4J3TLlnnZg7dOBAbWdCRVo= Date: Wed, 1 Jul 2020 09:19:27 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH RFC 2/5] f2fs: record average update time of segment Message-ID: <20200701161927.GD1724572@google.com> References: <20200630100428.19105-1-yuchao0@huawei.com> <20200630100428.19105-2-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200630100428.19105-2-yuchao0@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 {}. > + 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