37#ifdef LOSCFG_DEBUG_VERSION
39#define CLEAR_ALL_CACHE "clear all"
40#define CLEAR_PATH_CACHE "clear pathcache"
41#define CLEAR_PAGE_CACHE "clear pagecache"
70 struct Vnode *item = NULL;
71 struct Vnode *nextItem = NULL;
73 LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, list,
struct Vnode,
actFreeEntry) {
74 LosBufPrintf(buf,
"%-10p %-10p %-10p %10p 0x%08x %-3d %-4s %-3d %-3d %-8o\t%s\n",
88 for (
int i = 0; i < LOSCFG_MAX_PATH_CACHE_SIZE; i++) {
93 LosBufPrintf(buf,
"%-3d %-10p %-11p %-10p %-9d %s\n", i, pc,
124 struct Vnode *vnode = NULL;
145 int pathCacheTotalTry = 0;
146 int pathCacheTotalHit = 0;
149 int pageCacheTotalTry = 0;
150 int pageCacheTotalHit = 0;
156 LosBufPrintf(buf,
"\n=================================================================\n");
157 LosBufPrintf(buf,
"VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode\n");
161 vnodeTotal = vnodeVirtual + vnodeFree + vnodeActive;
163 LosBufPrintf(buf,
"\n=================================================================\n");
164 LosBufPrintf(buf,
"No. CacheAddr ParentAddr ChildAddr HitCount Name\n");
167 LosBufPrintf(buf,
"\n=================================================================\n");
170 LosBufPrintf(buf,
"\n=================================================================\n");
172 pathCacheTotal, pathCacheTotalTry, pathCacheTotalHit);
173 LosBufPrintf(buf,
"Vnode Total:%d Free:%d Virtual:%d Active:%d\n",
174 vnodeTotal, vnodeFree, vnodeVirtual, vnodeActive);
175 LosBufPrintf(buf,
"PageCache total:%d Try:%d Hit:%d\n", pageCacheTotal, pageCacheTotalTry, pageCacheTotalHit);
182 if (buffer == NULL || buflen <
sizeof(CLEAR_ALL_CACHE)) {
188 if (!strcmp(buffer, CLEAR_ALL_CACHE)) {
191 }
else if (!strcmp(buffer, CLEAR_PAGE_CACHE)) {
193 }
else if (!strcmp(buffer, CLEAR_PATH_CACHE)) {
199 PRINTK(
"%d vnodes and related pathcaches cleared\n%d pages cleared\n", vnodeCount, pageCount);
211 PRINT_ERR(
"create fs_cache error!\n");
static int PageCacheMapProcess(struct SeqBuf *buf)
static const struct ProcFileOperations FS_CACHE_PROC_FOPS
static int VnodeListProcess(struct SeqBuf *buf, LIST_HEAD *list)
static int FsCacheClear(struct ProcFile *pf, const char *buffer, size_t buflen, loff_t *ppos)
static int PathCacheListProcess(struct SeqBuf *buf)
void ProcFsCacheInit(void)
static char * VnodeTypeToStr(enum VnodeType type)
static int FsCacheInfoFill(struct SeqBuf *buf, void *arg)
static int PageCacheEntryProcess(struct SeqBuf *buf, struct page_mapping *mapping)
int LosBufPrintf(struct SeqBuf *seqBuf, const char *fmt,...)
支持可变参数 写 buf
int OsTryShrinkMemory(size_t nPage)
VOID ResetPageCacheHitInfo(int *try, int *hit)
void ResetPathCacheHitInfo(int *hit, int *try)
LIST_HEAD * GetPathCacheList(void)
struct ProcDirEntry * CreateProcEntry(const char *name, mode_t mode, struct ProcDirEntry *parent)
create a proc node
VM_OFFSET_T pgoff
页标,文件被切成一页一页读到内存
struct Vnode * childVnode
struct Vnode * parentVnode
proc 目录/文件项, @notethinking 直接叫 ProcEntry不香吗 ? 操作 /proc的 真正结构体
const struct ProcFileOperations * procFileOps
驱动程序,每个 /proc 下目录的驱动程序都不一样
真正最后能操作pro file的接口,proc本质是个内存文件系统, vfs - > ProcFileOperations
int(* read)(struct SeqBuf *m, void *v)
vnode并不包含文件名,因为 vnode和文件名是 1:N 的关系
struct page_mapping mapping
LIST_HEAD * GetVnodeVirtualList(void)
int VnodeClearCache(void)
int VnodeHold(void)
拿锁,封装互斥量
LIST_HEAD * GetVnodeFreeList(void)
LIST_HEAD * GetVnodeActiveList(void)