MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_aspace_gc

Function dfs_aspace_gc

components/dfs/dfs_v2/src/dfs_pcache.c:97–136  ·  view source on GitHub ↗

* @brief Perform garbage collection on an address space to release pages * * This function attempts to release a specified number of pages from both inactive * and active lists of the given address space. It prioritizes releasing pages from * the inactive list first before moving to the active list. * * @param[in] aspace Pointer to the address space structure to perform GC on * @param[in] c

Source from the content-addressed store, hash-verified

95 * @return Number of pages actually released (count - remaining)
96 */
97static int dfs_aspace_gc(struct dfs_aspace *aspace, int count)
98{
99 int cnt = count;
100
101 if (aspace)
102 {
103 dfs_aspace_lock(aspace);
104
105 if (aspace->pages_count > 0)
106 {
107 struct dfs_page *page = RT_NULL;
108 rt_list_t *node = aspace->list_inactive.next;
109
110 while (cnt && node != &aspace->list_active)
111 {
112 page = rt_list_entry(node, struct dfs_page, space_node);
113 node = node->next;
114 if (dfs_page_remove(page) == 0)
115 {
116 cnt --;
117 }
118 }
119
120 node = aspace->list_active.next;
121 while (cnt && node != &aspace->list_inactive)
122 {
123 page = rt_list_entry(node, struct dfs_page, space_node);
124 node = node->next;
125 if (dfs_page_remove(page) == 0)
126 {
127 cnt --;
128 }
129 }
130 }
131
132 dfs_aspace_unlock(aspace);
133 }
134
135 return count - cnt;
136}
137
138/**
139 * @brief Release page cache entries to free up memory

Callers 1

dfs_pcache_releaseFunction · 0.85

Calls 3

dfs_aspace_lockFunction · 0.85
dfs_page_removeFunction · 0.85
dfs_aspace_unlockFunction · 0.85

Tested by

no test coverage detected