* [f2fs-dev] [PATCH 4/4] f2fs: make some changes for memory using
@ 2022-06-28 3:24 Guowei Du
0 siblings, 0 replies; only message in thread
From: Guowei Du @ 2022-06-28 3:24 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: linux-kernel, duguowei, linux-f2fs-devel
From: duguowei <duguowei@xiaomi.com>
No functional change.
- one is just using a variable for f2fs_available_free_memory
- another adds 'inline' modifier for the function call
Signed-off-by: duguowei <duguowei@xiaomi.com>
---
fs/f2fs/node.c | 18 ++++++++++--------
fs/f2fs/shrinker.c | 6 +++---
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 836c79a20afc..2924c8ce13bb 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -46,7 +46,7 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
struct sysinfo val;
- unsigned long avail_ram;
+ unsigned long avail_ram, ram_thresh;
unsigned long mem_size = 0;
bool res = false;
@@ -57,25 +57,27 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
/* only uses low memory */
avail_ram = val.totalram - val.totalhigh;
+ ram_thresh = avail_ram * nm_i->ram_thresh / 100;
/*
- * give 25%, 25%, 50%, 50%, 50% memory for each components respectively
+ * give 25%, 25%, 50%, 50%, 50%, 100% of memory threshold
+ * for each components respectively
*/
if (type == FREE_NIDS) {
mem_size = (nm_i->nid_cnt[FREE_NID] *
sizeof(struct free_nid)) >> PAGE_SHIFT;
- res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 2);
+ res = mem_size < (ram_thresh >> 2);
} else if (type == NAT_ENTRIES) {
mem_size = (nm_i->nat_cnt[TOTAL_NAT] *
sizeof(struct nat_entry)) >> PAGE_SHIFT;
- res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 2);
+ res = mem_size < (ram_thresh >> 2);
if (excess_cached_nats(sbi))
res = false;
} else if (type == DIRTY_DENTS) {
if (sbi->sb->s_bdi->wb.dirty_exceeded)
return false;
mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
- res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1);
+ res = mem_size < (ram_thresh >> 1);
} else if (type == INO_ENTRIES) {
int i;
@@ -83,17 +85,17 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
mem_size += sbi->im[i].ino_num *
sizeof(struct ino_entry);
mem_size >>= PAGE_SHIFT;
- res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1);
+ res = mem_size < (ram_thresh >> 1);
} else if (type == EXTENT_CACHE) {
mem_size = (atomic_read(&sbi->total_ext_tree) *
sizeof(struct extent_tree) +
atomic_read(&sbi->total_ext_node) *
sizeof(struct extent_node)) >> PAGE_SHIFT;
- res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1);
+ res = mem_size < (ram_thresh >> 1);
} else if (type == DISCARD_CACHE) {
mem_size = (atomic_read(&dcc->discard_cmd_cnt) *
sizeof(struct discard_cmd)) >> PAGE_SHIFT;
- res = mem_size < (avail_ram * nm_i->ram_thresh / 100);
+ res = mem_size < ram_thresh;
} else if (type == COMPRESS_PAGE) {
#ifdef CONFIG_F2FS_FS_COMPRESSION
unsigned long free_ram = val.freeram;
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index dd3c3c7a90ec..201207b78bda 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -16,19 +16,19 @@ static LIST_HEAD(f2fs_list);
static DEFINE_SPINLOCK(f2fs_list_lock);
static unsigned int shrinker_run_no;
-static unsigned long __count_nat_entries(struct f2fs_sb_info *sbi)
+static inline unsigned long __count_nat_entries(struct f2fs_sb_info *sbi)
{
return NM_I(sbi)->nat_cnt[RECLAIMABLE_NAT];
}
-static unsigned long __count_free_nids(struct f2fs_sb_info *sbi)
+static inline unsigned long __count_free_nids(struct f2fs_sb_info *sbi)
{
long count = NM_I(sbi)->nid_cnt[FREE_NID] - MAX_FREE_NIDS;
return count > 0 ? count : 0;
}
-static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi)
+static inline unsigned long __count_extent_cache(struct f2fs_sb_info *sbi)
{
return atomic_read(&sbi->total_zombie_tree) +
atomic_read(&sbi->total_ext_node);
--
2.36.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-28 3:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-28 3:24 [f2fs-dev] [PATCH 4/4] f2fs: make some changes for memory using Guowei Du
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).