From patchwork Thu Oct 25 15:08:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 194208 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 23AE12C0091 for ; Fri, 26 Oct 2012 02:11:40 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946145Ab2JYPK3 (ORCPT ); Thu, 25 Oct 2012 11:10:29 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:45419 "EHLO e33.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946134Ab2JYPKY (ORCPT ); Thu, 25 Oct 2012 11:10:24 -0400 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Oct 2012 09:10:24 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 25 Oct 2012 09:10:21 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id D60B43E4007B; Thu, 25 Oct 2012 09:10:17 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9PFAGiM141550; Thu, 25 Oct 2012 09:10:17 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9PFABuj032202; Thu, 25 Oct 2012 09:10:16 -0600 Received: from us.ibm.com ([9.115.122.193]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q9PFA5uP031448; Thu, 25 Oct 2012 09:10:08 -0600 Received: by us.ibm.com (sSMTP sendmail emulation); Thu, 25 Oct 2012 23:10:01 +0800 From: zwu.kernel@gmail.com To: linux-fsdevel@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, linuxram@linux.vnet.ibm.com, viro@zeniv.linux.org.uk, david@fromorbit.com, tytso@mit.edu, cmm@us.ibm.com, Zhi Yong Wu Subject: [RFC v4 07/15] vfs,hot_track: add the aging function Date: Thu, 25 Oct 2012 23:08:59 +0800 Message-Id: <1351177747-19389-8-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1351177747-19389-1-git-send-email-zwu.kernel@gmail.com> References: <1351177747-19389-1-git-send-email-zwu.kernel@gmail.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12102515-2398-0000-0000-00000CD8D4D2 X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000294; HX=3.00000198; KW=3.00000007; PH=3.00000001; SC=3.00000008; SDB=6.00185562; UDB=6.00042037; UTC=2012-10-25 15:10:22 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zhi Yong Wu Signed-off-by: Zhi Yong Wu --- fs/hot_tracking.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/hot_tracking.h | 6 +++++ 2 files changed, 62 insertions(+), 0 deletions(-) diff --git a/fs/hot_tracking.c b/fs/hot_tracking.c index 05624ad..575cd3a 100644 --- a/fs/hot_tracking.c +++ b/fs/hot_tracking.c @@ -331,6 +331,24 @@ static void hot_freq_data_update(struct hot_freq_data *freq_data, bool write) } } +static bool hot_freq_data_is_obsolete(struct hot_freq_data *freq_data) +{ + int ret = 0; + struct timespec ckt = current_kernel_time(); + + u64 cur_time = timespec_to_ns(&ckt); + u64 last_read_ns = + (cur_time - timespec_to_ns(&freq_data->last_read_time)); + u64 last_write_ns = + (cur_time - timespec_to_ns(&freq_data->last_write_time)); + u64 kick_ns = TIME_TO_KICK * NSEC_PER_SEC; + + if ((last_read_ns > kick_ns) && (last_write_ns > kick_ns)) + ret = 1; + + return ret; +} + static u64 hot_raw_shift(u64 counter, u32 bits, bool dir) { if (dir) @@ -495,6 +513,44 @@ static void hot_map_array_update(struct hot_freq_data *freq_data, } } +/* Update temperatures for each range item for aging purposes */ +static void hot_range_update(struct hot_inode_item *he, + struct hot_info *root) +{ + struct hot_range_item *hr_nodes[8]; + u32 start = 0; + bool obsolete; + int i, n; + + while (1) { + spin_lock(&he->lock); + n = radix_tree_gang_lookup(&he->hot_range_tree, + (void **)hr_nodes, start, + ARRAY_SIZE(hr_nodes)); + if (!n) { + spin_unlock(&he->lock); + break; + } + spin_unlock(&he->lock); + + start = hr_nodes[n - 1]->start + 1; + for (i = 0; i < n; i++) { + kref_get(&hr_nodes[i]->hot_range.refs); + hot_map_array_update( + &hr_nodes[i]->hot_range.hot_freq_data, root); + + spin_lock(&hr_nodes[i]->hot_range.lock); + obsolete = hot_freq_data_is_obsolete( + &hr_nodes[i]->hot_range.hot_freq_data); + spin_unlock(&hr_nodes[i]->hot_range.lock); + + hot_range_item_put(hr_nodes[i]); + if (obsolete) + hot_range_item_put(hr_nodes[i]); + } + } +} + /* * Initialize inode and range map arrays. */ diff --git a/fs/hot_tracking.h b/fs/hot_tracking.h index be2365c..67c6fb6 100644 --- a/fs/hot_tracking.h +++ b/fs/hot_tracking.h @@ -26,6 +26,12 @@ #define FREQ_POWER 4 /* + * time to quit keeping track of + * tracking data (seconds) + */ +#define TIME_TO_KICK 300 + +/* * The following comments explain what exactly comprises a unit of heat. * * Each of six values of heat are calculated and combined in order to form an