瀏覽代碼

[dfs] Mark dirty on unmap on shared mapping only (#9195)

[dfs] feat: Mark dirty on unmap for shared mapping

This patch optimizes the pcache varea management by refining the
conditions under which pages are marked dirty, specifically targeting
the unmap operations in the dfs_pcache component. These changes were
necessary to enhance the efficiency of page cache management.

Changes:
- Adjusted include statements in `dfs_pcache.c` for better organization.
- Modified `dfs_aspace_unmap` function:
  - Added a check to ensure `varea` is not privately locked before marking a page as dirty.
- Updated `dfs_aspace_page_unmap` function:
  - Added a similar check for `varea` lock status before marking a page as dirty.

Signed-off-by: Shell <smokewood@qq.com>
Shell 1 年之前
父節點
當前提交
1b581d0755
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. 8 6
      components/dfs/dfs_v2/src/dfs_pcache.c

+ 8 - 6
components/dfs/dfs_v2/src/dfs_pcache.c

@@ -13,10 +13,11 @@
 #define DBG_LVL DBG_WARNING
 #include <rtdbg.h>
 
-#include "dfs_pcache.h"
-#include "dfs_dentry.h"
-#include "dfs_mnt.h"
-#include "mm_page.h"
+#include <dfs_pcache.h>
+#include <dfs_dentry.h>
+#include <dfs_mnt.h>
+#include <mm_page.h>
+#include <mm_private.h>
 #include <mmu.h>
 #include <tlb.h>
 
@@ -1380,7 +1381,8 @@ int dfs_aspace_unmap(struct dfs_file *file, struct rt_varea *varea)
 
                                 rt_varea_unmap_page(map_varea, vaddr);
 
-                                if (varea->attr == MMU_MAP_U_RWCB && page->fpos < page->aspace->vnode->size)
+                                if (!rt_varea_is_private_locked(varea) &&
+                                    page->fpos < page->aspace->vnode->size)
                                 {
                                     dfs_page_dirty(page);
                                 }
@@ -1425,7 +1427,7 @@ int dfs_aspace_page_unmap(struct dfs_file *file, struct rt_varea *varea, void *v
 
                 if (map && varea->aspace == map->aspace && vaddr == map->vaddr)
                 {
-                    if (varea->attr == MMU_MAP_U_RWCB)
+                    if (!rt_varea_is_private_locked(varea))
                     {
                         dfs_page_dirty(page);
                     }