Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
a28dcc38
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
10 个月 前同步成功
通知
450
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a28dcc38
编写于
6月 24, 2021
作者:
O
openharmony_ci
提交者:
Gitee
6月 24, 2021
浏览文件
操作
浏览文件
下载
差异文件
!360 增加清除文件系统缓存的维测接口
Merge pull request !360 from 野生毛霉君/master
上级
b8e18ffd
3d1cf683
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
80 addition
and
21 deletion
+80
-21
fs/proc/os_adapt/fs_cache_proc.c
fs/proc/os_adapt/fs_cache_proc.c
+50
-21
fs/vfs/include/vnode.h
fs/vfs/include/vnode.h
+1
-0
fs/vfs/operation/fs_file_mapping.c
fs/vfs/operation/fs_file_mapping.c
+5
-0
fs/vfs/vnode.c
fs/vfs/vnode.c
+23
-0
kernel/base/include/los_vm_filemap.h
kernel/base/include/los_vm_filemap.h
+1
-0
未找到文件。
fs/proc/os_adapt/fs_cache_proc.c
浏览文件 @
a28dcc38
...
...
@@ -35,6 +35,11 @@
#include "los_vm_filemap.h"
#ifdef LOSCFG_DEBUG_VERSION
#define CLEAR_ALL_CACHE "clear all"
#define CLEAR_PATH_CACHE "clear pathcache"
#define CLEAR_PAGE_CACHE "clear pagecache"
static
char
*
VnodeTypeToStr
(
enum
VnodeType
type
)
{
switch
(
type
)
{
case
VNODE_TYPE_UNKNOWN
:
...
...
@@ -93,40 +98,39 @@ static int PathCacheListProcess(struct SeqBuf *buf)
return
count
;
}
static
void
PageCacheEntryProcess
(
struct
SeqBuf
*
buf
,
struct
page_mapping
*
mapping
)
static
int
PageCacheEntryProcess
(
struct
SeqBuf
*
buf
,
struct
page_mapping
*
mapping
)
{
int
total
=
0
;
LosFilePage
*
fpage
=
NULL
;
if
(
mapping
==
NULL
)
{
LosBufPrintf
(
buf
,
"null]
\n
"
);
return
;
return
total
;
}
LOS_DL_LIST_FOR_EACH_ENTRY
(
fpage
,
&
mapping
->
page_list
,
LosFilePage
,
node
)
{
LosBufPrintf
(
buf
,
"%d,"
,
fpage
->
pgoff
);
total
++
;
}
LosBufPrintf
(
buf
,
"]
\n
"
);
return
;
return
total
;
}
static
void
PageCacheMapProcess
(
struct
SeqBuf
*
buf
)
static
int
PageCacheMapProcess
(
struct
SeqBuf
*
buf
)
{
struct
filelist
*
flist
=
&
tg_filelist
;
struct
file
*
filep
=
NULL
;
(
void
)
sem_wait
(
&
flist
->
fl_sem
);
for
(
int
i
=
3
;
i
<
CONFIG_NFILE_DESCRIPTORS
;
i
++
)
{
if
(
!
get_bit
(
i
))
{
continue
;
}
filep
=
&
flist
->
fl_files
[
i
];
if
(
filep
==
NULL
)
{
continue
;
}
LosBufPrintf
(
buf
,
"[%d]%s:["
,
i
,
filep
->
f_path
);
PageCacheEntryProcess
(
buf
,
filep
->
f_mapping
);
struct
file_map
*
mapList
=
GetFileMappingList
();
char
*
name
=
NULL
;
struct
file_map
*
curMap
=
NULL
;
int
total
=
0
;
(
VOID
)
LOS_MuxLock
(
&
mapList
->
lock
,
LOS_WAIT_FOREVER
);
LOS_DL_LIST_FOR_EACH_ENTRY
(
curMap
,
&
mapList
->
head
,
struct
file_map
,
head
)
{
name
=
curMap
->
rename
?
curMap
->
rename
:
curMap
->
owner
;
LosBufPrintf
(
buf
,
"%s:["
,
name
);
total
+=
PageCacheEntryProcess
(
buf
,
&
curMap
->
mapping
);
}
(
void
)
sem_post
(
&
flist
->
fl_sem
);
(
VOID
)
LOS_MuxUnlock
(
&
mapList
->
lock
);
return
total
;
}
static
int
FsCacheInfoFill
(
struct
SeqBuf
*
buf
,
void
*
arg
)
...
...
@@ -140,6 +144,7 @@ static int FsCacheInfoFill(struct SeqBuf *buf, void *arg)
int
pathCacheTotalTry
=
0
;
int
pathCacheTotalHit
=
0
;
int
pageCacheTotal
=
0
;
int
pageCacheTotalTry
=
0
;
int
pageCacheTotalHit
=
0
;
...
...
@@ -159,19 +164,43 @@ static int FsCacheInfoFill(struct SeqBuf *buf, void *arg)
pathCacheTotal
=
PathCacheListProcess
(
buf
);
LosBufPrintf
(
buf
,
"
\n
=================================================================
\n
"
);
PageCacheMapProcess
(
buf
);
pageCacheTotal
=
PageCacheMapProcess
(
buf
);
LosBufPrintf
(
buf
,
"
\n
=================================================================
\n
"
);
LosBufPrintf
(
buf
,
"PathCache Total:%d Try:%d Hit:%d
\n
"
,
pathCacheTotal
,
pathCacheTotalTry
,
pathCacheTotalHit
);
LosBufPrintf
(
buf
,
"Vnode Total:%d Free:%d Virtual:%d Active:%d
\n
"
,
vnodeTotal
,
vnodeFree
,
vnodeVirtual
,
vnodeActive
);
LosBufPrintf
(
buf
,
"PageCache
Try:%d Hit:%d
\n
"
,
pageCacheTotalTry
,
pageCacheTotalHit
);
LosBufPrintf
(
buf
,
"PageCache
total:%d Try:%d Hit:%d
\n
"
,
pageCacheTotal
,
pageCacheTotalTry
,
pageCacheTotalHit
);
VnodeDrop
();
return
0
;
}
static
int
FsCacheClear
(
struct
ProcFile
*
pf
,
const
char
*
buffer
,
size_t
buflen
,
loff_t
*
ppos
)
{
if
(
buffer
==
NULL
||
buflen
<
sizeof
(
CLEAR_ALL_CACHE
))
{
return
-
EINVAL
;
}
int
vnodeCount
=
0
;
int
pageCount
=
0
;
if
(
!
strcmp
(
buffer
,
CLEAR_ALL_CACHE
))
{
vnodeCount
=
VnodeClearCache
();
pageCount
=
OsTryShrinkMemory
(
VM_FILEMAP_MAX_SCAN
);
}
else
if
(
!
strcmp
(
buffer
,
CLEAR_PAGE_CACHE
))
{
pageCount
=
OsTryShrinkMemory
(
VM_FILEMAP_MAX_SCAN
);
}
else
if
(
!
strcmp
(
buffer
,
CLEAR_PATH_CACHE
))
{
vnodeCount
=
VnodeClearCache
();
}
else
{
return
-
EINVAL
;
}
PRINTK
(
"%d vnodes and related pathcaches cleared
\n
%d pages cleared
\n
"
,
vnodeCount
,
pageCount
);
return
buflen
;
}
static
const
struct
ProcFileOperations
FS_CACHE_PROC_FOPS
=
{
.
read
=
FsCacheInfoFill
,
.
write
=
FsCacheClear
,
};
void
ProcFsCacheInit
(
void
)
...
...
fs/vfs/include/vnode.h
浏览文件 @
a28dcc38
...
...
@@ -179,5 +179,6 @@ int VfsVnodePermissionCheck(const struct Vnode *node, int accMode);
LIST_HEAD
*
GetVnodeFreeList
(
void
);
LIST_HEAD
*
GetVnodeActiveList
(
void
);
LIST_HEAD
*
GetVnodeVirtualList
(
void
);
int
VnodeClearCache
(
void
);
#endif
/* !_VNODE_H_ */
fs/vfs/operation/fs_file_mapping.c
浏览文件 @
a28dcc38
...
...
@@ -293,4 +293,9 @@ out:
(
void
)
sem_post
(
&
f_list
->
fl_sem
);
return
ret
;
}
struct
file_map
*
GetFileMappingList
()
{
return
&
g_file_mapping
;
}
#endif
fs/vfs/vnode.c
浏览文件 @
a28dcc38
...
...
@@ -640,3 +640,26 @@ LIST_HEAD* GetVnodeActiveList()
{
return
&
g_vnodeActiveList
;
}
int
VnodeClearCache
()
{
struct
Vnode
*
item
=
NULL
;
struct
Vnode
*
nextItem
=
NULL
;
int
count
=
0
;
VnodeHold
();
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
item
,
nextItem
,
&
g_vnodeActiveList
,
struct
Vnode
,
actFreeEntry
)
{
if
((
item
->
useCount
>
0
)
||
(
item
->
flag
&
VNODE_FLAG_MOUNT_ORIGIN
)
||
(
item
->
flag
&
VNODE_FLAG_MOUNT_NEW
))
{
continue
;
}
if
(
VnodeFree
(
item
)
==
LOS_OK
)
{
count
++
;
}
}
VnodeDrop
();
return
count
;
}
kernel/base/include/los_vm_filemap.h
浏览文件 @
a28dcc38
...
...
@@ -208,6 +208,7 @@ typedef struct ProcessCB LosProcessCB;
VOID
OsVmmFileRegionFree
(
struct
file
*
filep
,
LosProcessCB
*
processCB
);
#ifdef LOSCFG_DEBUG_VERSION
VOID
ResetPageCacheHitInfo
(
int
*
try
,
int
*
hit
);
struct
file_map
*
GetFileMappingList
(
void
);
#endif
#ifdef __cplusplus
#if __cplusplus
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录