Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
b3120b54
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
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看板
提交
b3120b54
编写于
6月 21, 2021
作者:
O
openharmony_ci
提交者:
Gitee
6月 21, 2021
浏览文件
操作
浏览文件
下载
差异文件
!342 增加/proc/fs_cache来显示文件系统缓存维测信息
Merge pull request !342 from 野生毛霉君/master
上级
3f84ed50
53c6d96c
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
294 addition
and
32 deletion
+294
-32
fs/proc/include/internal.h
fs/proc/include/internal.h
+2
-0
fs/proc/os_adapt/fs_cache_proc.c
fs/proc/os_adapt/fs_cache_proc.c
+187
-0
fs/proc/os_adapt/proc_init.c
fs/proc/os_adapt/proc_init.c
+1
-0
fs/vfs/include/path_cache.h
fs/vfs/include/path_cache.h
+7
-0
fs/vfs/include/vnode.h
fs/vfs/include/vnode.h
+3
-0
fs/vfs/path_cache.c
fs/vfs/path_cache.c
+48
-24
fs/vfs/vnode.c
fs/vfs/vnode.c
+23
-8
kernel/base/include/los_vm_filemap.h
kernel/base/include/los_vm_filemap.h
+3
-0
kernel/base/vm/los_vm_filemap.c
kernel/base/vm/los_vm_filemap.c
+20
-0
未找到文件。
fs/proc/include/internal.h
浏览文件 @
b3120b54
...
...
@@ -63,6 +63,8 @@ extern void ProcMountsInit(void);
extern
void
ProcUptimeInit
(
void
);
void
ProcFsCacheInit
(
void
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
fs/proc/os_adapt/fs_cache_proc.c
0 → 100644
浏览文件 @
b3120b54
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "internal.h"
#include "proc_fs.h"
#include "vnode.h"
#include "path_cache.h"
#include "los_vm_filemap.h"
static
char
*
VnodeTypeToStr
(
enum
VnodeType
type
)
{
switch
(
type
)
{
case
VNODE_TYPE_UNKNOWN
:
return
"UKN"
;
case
VNODE_TYPE_REG
:
return
"REG"
;
case
VNODE_TYPE_DIR
:
return
"DIR"
;
case
VNODE_TYPE_BLK
:
return
"BLK"
;
case
VNODE_TYPE_CHR
:
return
"CHR"
;
case
VNODE_TYPE_BCHR
:
return
"BCH"
;
case
VNODE_TYPE_FIFO
:
return
"FIF"
;
case
VNODE_TYPE_LNK
:
return
"LNK"
;
default:
return
"BAD"
;
}
}
static
int
VnodeListProcess
(
struct
SeqBuf
*
buf
,
LIST_HEAD
*
list
)
{
int
count
=
0
;
struct
Vnode
*
item
=
NULL
;
struct
Vnode
*
nextItem
=
NULL
;
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
item
,
nextItem
,
list
,
struct
Vnode
,
actFreeEntry
)
{
LosBufPrintf
(
buf
,
"%-10p %-10p %-10p %10p 0x%08x %-3d %-4s %-3d %-3d %o
\n
"
,
item
,
item
->
parent
,
item
->
data
,
item
->
vop
,
item
->
hash
,
item
->
useCount
,
VnodeTypeToStr
(
item
->
type
),
item
->
gid
,
item
->
uid
,
item
->
mode
);
count
++
;
}
return
count
;
}
static
int
PathCacheListProcess
(
struct
SeqBuf
*
buf
)
{
int
count
=
0
;
LIST_HEAD
*
bucketList
=
GetPathCacheList
();
for
(
int
i
=
0
;
i
<
LOSCFG_MAX_PATH_CACHE_SIZE
;
i
++
)
{
struct
PathCache
*
pc
=
NULL
;
LIST_HEAD
*
list
=
&
bucketList
[
i
];
LOS_DL_LIST_FOR_EACH_ENTRY
(
pc
,
list
,
struct
PathCache
,
hashEntry
)
{
LosBufPrintf
(
buf
,
"%-3d %-10p %-11p %-10p %-9d %s
\n
"
,
i
,
pc
,
pc
->
parentVnode
,
pc
->
childVnode
,
pc
->
hit
,
pc
->
name
);
count
++
;
}
}
return
count
;
}
static
void
PageCacheEntryProcess
(
struct
SeqBuf
*
buf
,
struct
page_mapping
*
mapping
)
{
LosFilePage
*
fpage
=
NULL
;
if
(
mapping
==
NULL
)
{
LosBufPrintf
(
buf
,
"null]
\n
"
);
return
;
}
LOS_DL_LIST_FOR_EACH_ENTRY
(
fpage
,
&
mapping
->
page_list
,
LosFilePage
,
node
)
{
LosBufPrintf
(
buf
,
"%d,"
,
fpage
->
pgoff
);
}
LosBufPrintf
(
buf
,
"]
\n
"
);
return
;
}
static
void
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
);
}
(
void
)
sem_post
(
&
flist
->
fl_sem
);
}
static
int
FsCacheInfoFill
(
struct
SeqBuf
*
buf
,
void
*
arg
)
{
int
vnodeFree
=
0
;
int
vnodeActive
=
0
;
int
vnodeVirtual
=
0
;
int
vnodeTotal
=
0
;
int
pathCacheTotal
=
0
;
int
pathCacheTotalTry
=
0
;
int
pathCacheTotalHit
=
0
;
int
pageCacheTotalTry
=
0
;
int
pageCacheTotalHit
=
0
;
ResetPathCacheHitInfo
(
&
pathCacheTotalHit
,
&
pathCacheTotalTry
);
ResetPageCacheHitInfo
(
&
pageCacheTotalTry
,
&
pageCacheTotalHit
);
VnodeHold
();
LosBufPrintf
(
buf
,
"
\n
=================================================================
\n
"
);
LosBufPrintf
(
buf
,
"VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode
\n
"
);
vnodeVirtual
=
VnodeListProcess
(
buf
,
GetVnodeVirtualList
());
vnodeFree
=
VnodeListProcess
(
buf
,
GetVnodeFreeList
());
vnodeActive
=
VnodeListProcess
(
buf
,
GetVnodeActiveList
());
vnodeTotal
=
vnodeVirtual
+
vnodeFree
+
vnodeActive
;
LosBufPrintf
(
buf
,
"
\n
=================================================================
\n
"
);
LosBufPrintf
(
buf
,
"No. CacheAddr ParentAddr ChildAddr HitCount Name
\n
"
);
pathCacheTotal
=
PathCacheListProcess
(
buf
);
LosBufPrintf
(
buf
,
"
\n
=================================================================
\n
"
);
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
);
VnodeDrop
();
return
0
;
}
static
const
struct
ProcFileOperations
FS_CACHE_PROC_FOPS
=
{
.
read
=
FsCacheInfoFill
,
};
void
ProcFsCacheInit
(
void
)
{
#ifdef LOSCFG_DEBUG_VERSION
struct
ProcDirEntry
*
pde
=
CreateProcEntry
(
"fs_cache"
,
0
,
NULL
);
if
(
pde
==
NULL
)
{
PRINT_ERR
(
"create fs_cache error!
\n
"
);
return
;
}
pde
->
procFileOps
=
&
FS_CACHE_PROC_FOPS
;
#endif
}
fs/proc/os_adapt/proc_init.c
浏览文件 @
b3120b54
...
...
@@ -64,6 +64,7 @@ void ProcFsInit(void)
ProcProcessInit
();
ProcUptimeInit
();
ProcKernelTraceInit
();
ProcFsCacheInit
();
}
LOS_MODULE_INIT
(
ProcFsInit
,
LOS_INIT_LEVEL_KMOD_EXTENDED
);
...
...
fs/vfs/include/path_cache.h
浏览文件 @
b3120b54
...
...
@@ -42,6 +42,9 @@ struct PathCache {
LIST_ENTRY
childEntry
;
/* list entry for cache list in the child vnode */
LIST_ENTRY
hashEntry
;
/* list entry for buckets in the hash table */
uint8_t
nameLen
;
/* length of path component */
#ifdef LOSCFG_DEBUG_VERSION
int
hit
;
/* cache hit count*/
#endif
char
name
[
0
];
/* path component name */
};
...
...
@@ -52,5 +55,9 @@ int PathCacheLookup(struct Vnode *parent, const char *name, int len, struct Vnod
void
VnodePathCacheFree
(
struct
Vnode
*
vnode
);
void
PathCacheMemoryDump
(
void
);
void
PathCacheDump
(
void
);
LIST_HEAD
*
GetPathCacheList
(
void
);
#ifdef LOSCFG_DEBUG_VERSION
void
ResetPathCacheHitInfo
(
int
*
hit
,
int
*
try
);
#endif
#endif
/* _PATH_CACHE_H */
fs/vfs/include/vnode.h
浏览文件 @
b3120b54
...
...
@@ -176,5 +176,8 @@ void VnodeMemoryDump(void);
mode_t
GetUmask
(
void
);
int
VfsPermissionCheck
(
uint
fuid
,
uint
fgid
,
mode_t
fileMode
,
int
accMode
);
int
VfsVnodePermissionCheck
(
const
struct
Vnode
*
node
,
int
accMode
);
LIST_HEAD
*
GetVnodeFreeList
(
void
);
LIST_HEAD
*
GetVnodeActiveList
(
void
);
LIST_HEAD
*
GetVnodeVirtualList
(
void
);
#endif
/* !_VNODE_H_ */
fs/vfs/path_cache.c
浏览文件 @
b3120b54
...
...
@@ -37,6 +37,23 @@
#define PATH_CACHE_HASH_MASK (LOSCFG_MAX_PATH_CACHE_SIZE - 1)
LIST_HEAD
g_pathCacheHashEntrys
[
LOSCFG_MAX_PATH_CACHE_SIZE
];
#ifdef LOSCFG_DEBUG_VERSION
static
int
g_totalPathCacheHit
=
0
;
static
int
g_totalPathCacheTry
=
0
;
#define TRACE_TRY_CACHE() do { g_totalPathCacheTry++; } while (0)
#define TRACE_HIT_CACHE(pc) do { pc->hit++; g_totalPathCacheHit++; } while (0)
void
ResetPathCacheHitInfo
(
int
*
hit
,
int
*
try
)
{
*
hit
=
g_totalPathCacheHit
;
*
try
=
g_totalPathCacheTry
;
g_totalPathCacheHit
=
0
;
g_totalPathCacheTry
=
0
;
}
#else
#define TRACE_TRY_CACHE()
#define TRACE_HIT_CACHE(pc)
#endif
int
PathCacheInit
(
void
)
{
...
...
@@ -50,12 +67,12 @@ void PathCacheDump(void)
{
PRINTK
(
"-------->pathCache dump in
\n
"
);
for
(
int
i
=
0
;
i
<
LOSCFG_MAX_PATH_CACHE_SIZE
;
i
++
)
{
struct
PathCache
*
n
c
=
NULL
;
struct
PathCache
*
p
c
=
NULL
;
LIST_HEAD
*
nhead
=
&
g_pathCacheHashEntrys
[
i
];
LOS_DL_LIST_FOR_EACH_ENTRY
(
n
c
,
nhead
,
struct
PathCache
,
hashEntry
)
{
LOS_DL_LIST_FOR_EACH_ENTRY
(
p
c
,
nhead
,
struct
PathCache
,
hashEntry
)
{
PRINTK
(
" pathCache dump hash %d item %s %p %p %d
\n
"
,
i
,
nc
->
name
,
nc
->
parentVnode
,
nc
->
childVnode
,
n
c
->
nameLen
);
pc
->
name
,
pc
->
parentVnode
,
pc
->
childVnode
,
p
c
->
nameLen
);
}
}
PRINTK
(
"-------->pathCache dump out
\n
"
);
...
...
@@ -94,7 +111,7 @@ static void PathCacheInsert(struct Vnode *parent, struct PathCache *cache, const
struct
PathCache
*
PathCacheAlloc
(
struct
Vnode
*
parent
,
struct
Vnode
*
vnode
,
const
char
*
name
,
uint8_t
len
)
{
struct
PathCache
*
n
c
=
NULL
;
struct
PathCache
*
p
c
=
NULL
;
size_t
pathCacheSize
;
int
ret
;
...
...
@@ -103,53 +120,55 @@ struct PathCache *PathCacheAlloc(struct Vnode *parent, struct Vnode *vnode, cons
}
pathCacheSize
=
sizeof
(
struct
PathCache
)
+
len
+
1
;
n
c
=
(
struct
PathCache
*
)
zalloc
(
pathCacheSize
);
if
(
n
c
==
NULL
)
{
p
c
=
(
struct
PathCache
*
)
zalloc
(
pathCacheSize
);
if
(
p
c
==
NULL
)
{
PRINT_ERR
(
"pathCache alloc failed, no memory!
\n
"
);
return
NULL
;
}
ret
=
strncpy_s
(
n
c
->
name
,
len
+
1
,
name
,
len
);
ret
=
strncpy_s
(
p
c
->
name
,
len
+
1
,
name
,
len
);
if
(
ret
!=
LOS_OK
)
{
return
NULL
;
}
n
c
->
parentVnode
=
parent
;
n
c
->
nameLen
=
len
;
n
c
->
childVnode
=
vnode
;
p
c
->
parentVnode
=
parent
;
p
c
->
nameLen
=
len
;
p
c
->
childVnode
=
vnode
;
LOS_ListAdd
((
&
(
parent
->
childPathCaches
)),
(
&
(
n
c
->
childEntry
)));
LOS_ListAdd
((
&
(
vnode
->
parentPathCaches
)),
(
&
(
n
c
->
parentEntry
)));
LOS_ListAdd
((
&
(
parent
->
childPathCaches
)),
(
&
(
p
c
->
childEntry
)));
LOS_ListAdd
((
&
(
vnode
->
parentPathCaches
)),
(
&
(
p
c
->
parentEntry
)));
PathCacheInsert
(
parent
,
n
c
,
name
,
len
);
PathCacheInsert
(
parent
,
p
c
,
name
,
len
);
return
n
c
;
return
p
c
;
}
int
PathCacheFree
(
struct
PathCache
*
n
c
)
int
PathCacheFree
(
struct
PathCache
*
p
c
)
{
if
(
n
c
==
NULL
)
{
if
(
p
c
==
NULL
)
{
PRINT_ERR
(
"pathCache free: invalid pathCache
\n
"
);
return
-
ENOENT
;
}
LOS_ListDelete
(
&
n
c
->
hashEntry
);
LOS_ListDelete
(
&
n
c
->
parentEntry
);
LOS_ListDelete
(
&
n
c
->
childEntry
);
free
(
n
c
);
LOS_ListDelete
(
&
p
c
->
hashEntry
);
LOS_ListDelete
(
&
p
c
->
parentEntry
);
LOS_ListDelete
(
&
p
c
->
childEntry
);
free
(
p
c
);
return
LOS_OK
;
}
int
PathCacheLookup
(
struct
Vnode
*
parent
,
const
char
*
name
,
int
len
,
struct
Vnode
**
vnode
)
{
struct
PathCache
*
n
c
=
NULL
;
struct
PathCache
*
p
c
=
NULL
;
int
hash
=
NameHash
(
name
,
len
,
parent
)
&
PATH_CACHE_HASH_MASK
;
LIST_HEAD
*
dhead
=
&
g_pathCacheHashEntrys
[
hash
];
LOS_DL_LIST_FOR_EACH_ENTRY
(
nc
,
dhead
,
struct
PathCache
,
hashEntry
)
{
if
(
nc
->
parentVnode
==
parent
&&
nc
->
nameLen
==
len
&&
!
strncmp
(
nc
->
name
,
name
,
len
))
{
*
vnode
=
nc
->
childVnode
;
TRACE_TRY_CACHE
();
LOS_DL_LIST_FOR_EACH_ENTRY
(
pc
,
dhead
,
struct
PathCache
,
hashEntry
)
{
if
(
pc
->
parentVnode
==
parent
&&
pc
->
nameLen
==
len
&&
!
strncmp
(
pc
->
name
,
name
,
len
))
{
*
vnode
=
pc
->
childVnode
;
TRACE_HIT_CACHE
(
pc
);
return
LOS_OK
;
}
}
...
...
@@ -184,3 +203,8 @@ void VnodePathCacheFree(struct Vnode *vnode)
FreeParentPathCache
(
vnode
);
FreeChildPathCache
(
vnode
);
}
LIST_HEAD
*
GetPathCacheList
()
{
return
g_pathCacheHashEntrys
;
}
fs/vfs/vnode.c
浏览文件 @
b3120b54
...
...
@@ -35,7 +35,7 @@
LIST_HEAD
g_vnodeFreeList
;
/* free vnodes list */
LIST_HEAD
g_vnodeVirtualList
;
/* dev vnodes list */
LIST_HEAD
g_vnode
Curr
List
;
/* inuse vnodes list */
LIST_HEAD
g_vnode
Active
List
;
/* inuse vnodes list */
static
int
g_freeVnodeSize
=
0
;
/* system free vnodes size */
static
int
g_totalVnodeSize
=
0
;
/* total vnode size */
...
...
@@ -57,7 +57,7 @@ int VnodesInit(void)
LOS_ListInit
(
&
g_vnodeFreeList
);
LOS_ListInit
(
&
g_vnodeVirtualList
);
LOS_ListInit
(
&
g_vnode
Curr
List
);
LOS_ListInit
(
&
g_vnode
Active
List
);
retval
=
VnodeAlloc
(
NULL
,
&
g_rootVnode
);
if
(
retval
!=
LOS_OK
)
{
PRINT_ERR
(
"VnodeInit failed error %d
\n
"
,
retval
);
...
...
@@ -94,7 +94,7 @@ struct Vnode *VnodeReclaimLru(void)
struct
Vnode
*
nextItem
=
NULL
;
int
releaseCount
=
0
;
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
item
,
nextItem
,
&
g_vnode
Curr
List
,
struct
Vnode
,
actFreeEntry
)
{
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
item
,
nextItem
,
&
g_vnode
Active
List
,
struct
Vnode
,
actFreeEntry
)
{
if
((
item
->
useCount
>
0
)
||
(
item
->
flag
&
VNODE_FLAG_MOUNT_ORIGIN
)
||
(
item
->
flag
&
VNODE_FLAG_MOUNT_NEW
))
{
...
...
@@ -152,7 +152,7 @@ int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode)
LOS_ListAdd
(
&
g_vnodeVirtualList
,
&
(
vnode
->
actFreeEntry
));
vnode
->
vop
=
&
g_devfsOps
;
}
else
{
LOS_ListTailInsert
(
&
g_vnode
Curr
List
,
&
(
vnode
->
actFreeEntry
));
LOS_ListTailInsert
(
&
g_vnode
Active
List
,
&
(
vnode
->
actFreeEntry
));
vnode
->
vop
=
vop
;
}
VnodeDrop
();
...
...
@@ -204,7 +204,7 @@ int VnodeFreeAll(const struct Mount *mount)
struct
Vnode
*
nextVnode
=
NULL
;
int
ret
;
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
vnode
,
nextVnode
,
&
g_vnode
Curr
List
,
struct
Vnode
,
actFreeEntry
)
{
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
vnode
,
nextVnode
,
&
g_vnode
Active
List
,
struct
Vnode
,
actFreeEntry
)
{
if
((
vnode
->
originMount
==
mount
)
&&
!
(
vnode
->
flag
&
VNODE_FLAG_MOUNT_NEW
))
{
ret
=
VnodeFree
(
vnode
);
if
(
ret
!=
LOS_OK
)
{
...
...
@@ -220,7 +220,7 @@ BOOL VnodeInUseIter(const struct Mount *mount)
{
struct
Vnode
*
vnode
=
NULL
;
LOS_DL_LIST_FOR_EACH_ENTRY
(
vnode
,
&
g_vnode
Curr
List
,
struct
Vnode
,
actFreeEntry
)
{
LOS_DL_LIST_FOR_EACH_ENTRY
(
vnode
,
&
g_vnode
Active
List
,
struct
Vnode
,
actFreeEntry
)
{
if
(
vnode
->
originMount
==
mount
)
{
if
((
vnode
->
useCount
>
0
)
||
(
vnode
->
flag
&
VNODE_FLAG_MOUNT_ORIGIN
))
{
return
TRUE
;
...
...
@@ -294,7 +294,7 @@ static void RefreshLRU(struct Vnode *vnode)
return
;
}
LOS_ListDelete
(
&
(
vnode
->
actFreeEntry
));
LOS_ListTailInsert
(
&
g_vnode
Curr
List
,
&
(
vnode
->
actFreeEntry
));
LOS_ListTailInsert
(
&
g_vnode
Active
List
,
&
(
vnode
->
actFreeEntry
));
}
static
int
ProcessVirtualVnode
(
struct
Vnode
*
parent
,
uint32_t
flags
,
struct
Vnode
**
vnode
)
...
...
@@ -612,7 +612,7 @@ void VnodeMemoryDump(void)
struct
Vnode
*
nextItem
=
NULL
;
int
vnodeCount
=
0
;
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
item
,
nextItem
,
&
g_vnode
Curr
List
,
struct
Vnode
,
actFreeEntry
)
{
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE
(
item
,
nextItem
,
&
g_vnode
Active
List
,
struct
Vnode
,
actFreeEntry
)
{
if
((
item
->
useCount
>
0
)
||
(
item
->
flag
&
VNODE_FLAG_MOUNT_ORIGIN
)
||
(
item
->
flag
&
VNODE_FLAG_MOUNT_NEW
))
{
...
...
@@ -625,3 +625,18 @@ void VnodeMemoryDump(void)
PRINTK
(
"Vnode number = %d
\n
"
,
vnodeCount
);
PRINTK
(
"Vnode memory size = %d(B)
\n
"
,
vnodeCount
*
sizeof
(
struct
Vnode
));
}
LIST_HEAD
*
GetVnodeFreeList
()
{
return
&
g_vnodeFreeList
;
}
LIST_HEAD
*
GetVnodeVirtualList
()
{
return
&
g_vnodeVirtualList
;
}
LIST_HEAD
*
GetVnodeActiveList
()
{
return
&
g_vnodeActiveList
;
}
kernel/base/include/los_vm_filemap.h
浏览文件 @
b3120b54
...
...
@@ -206,6 +206,9 @@ VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, int off, int le
typedef
struct
ProcessCB
LosProcessCB
;
VOID
OsVmmFileRegionFree
(
struct
file
*
filep
,
LosProcessCB
*
processCB
);
#ifdef LOSCFG_DEBUG_VERSION
VOID
ResetPageCacheHitInfo
(
int
*
try
,
int
*
hit
);
#endif
#ifdef __cplusplus
#if __cplusplus
}
...
...
kernel/base/vm/los_vm_filemap.c
浏览文件 @
b3120b54
...
...
@@ -47,6 +47,24 @@
#define UNUSED(x) (VOID)x
#endif
#ifdef LOSCFG_DEBUG_VERSION
static
int
g_totalPageCacheTry
=
0
;
static
int
g_totalPageCacheHit
=
0
;
#define TRACE_TRY_CACHE() do { g_totalPageCacheTry++; } while (0)
#define TRACE_HIT_CACHE() do { g_totalPageCacheHit++; } while (0)
VOID
ResetPageCacheHitInfo
(
int
*
try
,
int
*
hit
)
{
*
try
=
g_totalPageCacheTry
;
*
hit
=
g_totalPageCacheHit
;
g_totalPageCacheHit
=
0
;
g_totalPageCacheTry
=
0
;
}
#else
#define TRACE_TRY_CACHE()
#define TRACE_HIT_CACHE()
#endif
#ifdef LOSCFG_KERNEL_VM
STATIC
VOID
OsPageCacheAdd
(
LosFilePage
*
page
,
struct
page_mapping
*
mapping
,
VM_OFFSET_T
pgoff
)
...
...
@@ -365,7 +383,9 @@ INT32 OsVmmFileFault(LosVmMapRegion *region, LosVmPgFault *vmf)
/* get or create a new cache node */
LOS_SpinLockSave
(
&
mapping
->
list_lock
,
&
intSave
);
fpage
=
OsFindGetEntry
(
mapping
,
vmf
->
pgoff
);
TRACE_TRY_CACHE
();
if
(
fpage
!=
NULL
)
{
TRACE_HIT_CACHE
();
OsPageRefIncLocked
(
fpage
);
}
else
{
fpage
=
OsPageCacheAlloc
(
mapping
,
vmf
->
pgoff
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录