Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754437AbbGOJah (ORCPT ); Wed, 15 Jul 2015 05:30:37 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:35844 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753767AbbGOJae (ORCPT ); Wed, 15 Jul 2015 05:30:34 -0400 X-AuditID: cbfee61b-f79416d0000014c0-df-55a628343e1d From: Chao Yu To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] f2fs: use atomic_t to record hit ratio info of extent cache Date: Wed, 15 Jul 2015 17:29:49 +0800 Message-id: <012c01d0bee0$e37a9e00$aa6fda00$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdC+2LfHWzEYQ7NBQlGrDA95OAifUA== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsVy+t9jAV0TjWWhBp0TlS2erJ/FbHFpkbvF 5V1z2ByYPTat6mTz2L3gM5PH501yAcxRXDYpqTmZZalF+nYJXBk/HlYVvJaq+PTyOGsD42qx LkZODgkBE4mlbf/ZIWwxiQv31rN1MXJxCAksYpR4+OAjM4TzilHi19TrTCBVbAIqEss7/oPZ IkD2oUWXwbqZBTwkGju+s3YxcnAICwRI/HvKARJmEVCVmPP5OVg5r4ClxI2JJ9khbEGJH5Pv sUC0akms33mcCcKWl9i85i0zxEEKEjvOvmYEGSkioCcx7U0BRIm4xMYjt1gmMArMQjJpFpJJ s5BMmoWkZQEjyypG0dSC5ILipPRcI73ixNzi0rx0veT83E2M4NB9Jr2DcVWDxSFGAQ5GJR7e hkVLQ4VYE8uKK3MPMUpwMCuJ8G4UXxYqxJuSWFmVWpQfX1Sak1p8iFGag0VJnPdkvk+okEB6 YklqdmpqQWoRTJaJg1OqgVF4S7FAgIVw8KkZdV084YtnyJ77LX3i8MGmUruzO3hLxFZs0+jo Em2dfPOT41R+P2ktjss2a07yGSW0uExii/dh/7NtDfOVrpk+UxpXOd7lFXh3S5lJtZHlzcaJ bGJFd5QE/V8c9FI+u71776fnx0Uuhi34UnGEZ/2cb0sbLZ/8Xyaxz81kUb0SS3FGoqEWc1Fx IgA95jnXWQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3589 Lines: 96 Variables for recording extent cache ratio info were updated without protection, this patch tries to alter them to atomic_t type for more accurate stat. Signed-off-by: Chao Yu --- fs/f2fs/debug.c | 7 +++++-- fs/f2fs/extent_cache.c | 6 +++--- fs/f2fs/f2fs.h | 7 ++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 2aeaf4e..bc215fd 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c @@ -33,8 +33,8 @@ static void update_general_status(struct f2fs_sb_info *sbi) int i; /* validation check of the segment numbers */ - si->hit_ext = sbi->read_hit_ext; - si->total_ext = sbi->total_hit_ext; + si->hit_ext = atomic_read(&sbi->read_hit_ext); + si->total_ext = atomic_read(&sbi->total_hit_ext); si->ext_tree = sbi->total_ext_tree; si->ext_node = atomic_read(&sbi->total_ext_node); si->ndirty_node = get_pages(sbi, F2FS_DIRTY_NODES); @@ -369,6 +369,9 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi) si->sbi = sbi; sbi->stat_info = si; + atomic_set(&sbi->total_hit_ext, 0); + atomic_set(&sbi->read_hit_ext, 0); + atomic_set(&sbi->inline_xattr, 0); atomic_set(&sbi->inline_inode, 0); atomic_set(&sbi->inline_dir, 0); diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c index 5f78fc1..362df8c 100644 --- a/fs/f2fs/extent_cache.c +++ b/fs/f2fs/extent_cache.c @@ -279,7 +279,7 @@ static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs, et->largest.fofs + et->largest.len > pgofs) { *ei = et->largest; ret = true; - stat_inc_read_hit(sbi->sb); + stat_inc_read_hit(sbi); goto out; } @@ -292,10 +292,10 @@ static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs, et->cached_en = en; spin_unlock(&sbi->extent_lock); ret = true; - stat_inc_read_hit(sbi->sb); + stat_inc_read_hit(sbi); } out: - stat_inc_total_hit(sbi->sb); + stat_inc_total_hit(sbi); read_unlock(&et->lock); trace_f2fs_lookup_extent_tree_end(inode, pgofs, ei); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index b18b852..38ba525 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -781,7 +781,8 @@ struct f2fs_sb_info { unsigned int segment_count[2]; /* # of allocated segments */ unsigned int block_count[2]; /* # of allocated blocks */ atomic_t inplace_count; /* # of inplace update */ - int total_hit_ext, read_hit_ext; /* extent cache hit ratio */ + atomic_t total_hit_ext; /* # of lookup extent cache */ + atomic_t read_hit_ext; /* # of hit extent cache */ atomic_t inline_xattr; /* # of inline_xattr inodes */ atomic_t inline_inode; /* # of inline_data inodes */ atomic_t inline_dir; /* # of inline_dentry inodes */ @@ -1837,8 +1838,8 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) #define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++) #define stat_inc_dirty_dir(sbi) ((sbi)->n_dirty_dirs++) #define stat_dec_dirty_dir(sbi) ((sbi)->n_dirty_dirs--) -#define stat_inc_total_hit(sb) ((F2FS_SB(sb))->total_hit_ext++) -#define stat_inc_read_hit(sb) ((F2FS_SB(sb))->read_hit_ext++) +#define stat_inc_total_hit(sbi) (atomic_inc(&(sbi)->total_hit_ext)) +#define stat_inc_read_hit(sbi) (atomic_inc(&(sbi)->read_hit_ext)) #define stat_inc_inline_xattr(inode) \ do { \ if (f2fs_has_inline_xattr(inode)) \ -- 2.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/