From patchwork Mon Oct 29 04:30:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyong Wu X-Patchwork-Id: 1660971 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7C5BBDFB7A for ; Mon, 29 Oct 2012 04:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932243Ab2J2EcV (ORCPT ); Mon, 29 Oct 2012 00:32:21 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:35225 "EHLO e2.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754873Ab2J2EcI (ORCPT ); Mon, 29 Oct 2012 00:32:08 -0400 Received: from /spool/local by e2.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 Oct 2012 00:32:07 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e2.ny.us.ibm.com (192.168.1.102) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 29 Oct 2012 00:32:04 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 2061538C8039; Mon, 29 Oct 2012 00:32:04 -0400 (EDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9T4W3RX283022; Mon, 29 Oct 2012 00:32:03 -0400 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9T4W2wE023844; Sun, 28 Oct 2012 22:32:03 -0600 Received: from us.ibm.com ([9.115.122.193]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q9T4Vv9L023761; Sun, 28 Oct 2012 22:31:58 -0600 Received: by us.ibm.com (sSMTP sendmail emulation); Mon, 29 Oct 2012 12:31:53 +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, wuzhy@linux.vnet.ibm.com, wenqing.lz@taobao.com Subject: [RFC v4+ hot_track 07/19] vfs: add map info update function Date: Mon, 29 Oct 2012 12:30:49 +0800 Message-Id: <1351485061-12297-8-git-send-email-zwu.kernel@gmail.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1351485061-12297-1-git-send-email-zwu.kernel@gmail.com> References: <1351485061-12297-1-git-send-email-zwu.kernel@gmail.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12102904-5112-0000-0000-00000DF34960 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Zhi Yong Wu Signed-off-by: Zhi Yong Wu --- fs/hot_tracking.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/hot_tracking.h | 21 +++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-) diff --git a/fs/hot_tracking.c b/fs/hot_tracking.c index 83e590c..9245dd3 100644 --- a/fs/hot_tracking.c +++ b/fs/hot_tracking.c @@ -398,6 +398,72 @@ static u32 hot_temp_calc(struct hot_freq_data *freq_data) } /* + * Calculate a new temperature and, if necessary, + * move the list_head corresponding to this inode or range + * to the proper list with the new temperature + */ +static void hot_map_array_update(struct hot_freq_data *freq_data, + struct hot_info *root) +{ + struct hot_map_head *buckets, *cur_bucket; + struct hot_comm_item *comm_item; + struct hot_inode_item *he; + struct hot_range_item *hr; + u32 temp = hot_temp_calc(freq_data); + u8 a_temp = temp >> (32 - HEAT_MAP_BITS); + u8 b_temp = freq_data->last_temp >> (32 - HEAT_MAP_BITS); + + comm_item = container_of(freq_data, + struct hot_comm_item, hot_freq_data); + + if (freq_data->flags & FREQ_DATA_TYPE_INODE) { + he = container_of(comm_item, + struct hot_inode_item, hot_inode); + buckets = root->heat_inode_map; + + if (he == NULL) + return; + + spin_lock(&he->hot_inode.lock); + if (list_empty(&he->hot_inode.n_list) || (a_temp != b_temp)) { + if (!list_empty(&he->hot_inode.n_list)) { + list_del_init(&he->hot_inode.n_list); + root->hot_map_nr--; + } + + cur_bucket = buckets + a_temp; + list_add_tail(&he->hot_inode.n_list, + &cur_bucket->node_list); + root->hot_map_nr++; + freq_data->last_temp = temp; + } + spin_unlock(&he->hot_inode.lock); + } else if (freq_data->flags & FREQ_DATA_TYPE_RANGE) { + hr = container_of(comm_item, + struct hot_range_item, hot_range); + buckets = root->heat_range_map; + + if (hr == NULL) + return; + + spin_lock(&hr->hot_range.lock); + if (list_empty(&hr->hot_range.n_list) || (a_temp != b_temp)) { + if (!list_empty(&hr->hot_range.n_list)) { + list_del_init(&hr->hot_range.n_list); + root->hot_map_nr--; + } + + cur_bucket = buckets + a_temp; + list_add_tail(&hr->hot_range.n_list, + &cur_bucket->node_list); + root->hot_map_nr++; + freq_data->last_temp = temp; + } + spin_unlock(&hr->hot_range.lock); + } +} + +/* * Initialize inode and range map arrays. */ static void hot_map_array_init(struct hot_info *root) diff --git a/fs/hot_tracking.h b/fs/hot_tracking.h index cc4666e..196b894 100644 --- a/fs/hot_tracking.h +++ b/fs/hot_tracking.h @@ -26,6 +26,27 @@ #define FREQ_POWER 4 +/* NRR/NRW heat unit = 2^X accesses */ +#define NRR_MULTIPLIER_POWER 20 /* NRR - number of reads since mount */ +#define NRR_COEFF_POWER 0 +#define NRW_MULTIPLIER_POWER 20 /* NRW - number of writes since mount */ +#define NRW_COEFF_POWER 0 + +/* LTR/LTW heat unit = 2^X ns of age */ +#define LTR_DIVIDER_POWER 30 /* LTR - time elapsed since last read(ns) */ +#define LTR_COEFF_POWER 1 +#define LTW_DIVIDER_POWER 30 /* LTW - time elapsed since last write(ns) */ +#define LTW_COEFF_POWER 1 + +/* + * AVR/AVW cold unit = 2^X ns of average delta + * AVR/AVW heat unit = HEAT_MAX_VALUE - cold unit + */ +#define AVR_DIVIDER_POWER 40 /* AVR - average delta between recent reads(ns) */ +#define AVR_COEFF_POWER 0 +#define AVW_DIVIDER_POWER 40 /* AVW - average delta between recent writes(ns) */ +#define AVW_COEFF_POWER 0 + void hot_inode_item_put(struct hot_inode_item *he); struct hot_inode_item *hot_inode_item_find(struct hot_info *root, u64 ino);