Changeset 68f11ddc in mainline for kernel/generic/src/mm/backend_anon.c
- Timestamp:
- 2018-12-03T16:54:22Z (5 years ago)
- Parents:
- a0765f6
- git-author:
- Jiri Svoboda <jiri@…> (2018-12-03 16:53:27)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-12-03 16:54:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/backend_anon.c
ra0765f6 r68f11ddc 144 144 assert(PTE_PRESENT(&pte)); 145 145 146 btree_insert(&area->sh_info->pagemap,146 as_pagemap_insert(&area->sh_info->pagemap, 147 147 (base + P2SZ(j)) - area->base, 148 (void *) PTE_GET_FRAME(&pte), NULL);148 PTE_GET_FRAME(&pte)); 149 149 page_table_unlock(area->as, false); 150 150 … … 201 201 mutex_lock(&area->sh_info->lock); 202 202 if (area->sh_info->shared) { 203 btree_node_t *leaf;204 205 203 /* 206 204 * The area is shared, chances are that the mapping can be found … … 210 208 * mapping, a new frame is allocated and the mapping is created. 211 209 */ 212 frame = (uintptr_t) btree_search(&area->sh_info->pagemap, 213 upage - area->base, &leaf); 214 if (!frame) { 215 bool allocate = true; 216 unsigned int i; 210 errno_t rc = as_pagemap_find(&area->sh_info->pagemap, 211 upage - area->base, &frame); 212 if (rc != EOK) { 213 /* Need to allocate the frame */ 214 kpage = km_temporary_page_get(&frame, 215 FRAME_NO_RESERVE); 216 memsetb((void *) kpage, PAGE_SIZE, 0); 217 km_temporary_page_put(kpage); 217 218 218 219 /* 219 * Zero can be returned as a valid frame address.220 * Just a small workaround.220 * Insert the address of the newly allocated 221 * frame to the pagemap. 221 222 */ 222 for (i = 0; i < leaf->keys; i++) { 223 if (leaf->key[i] == upage - area->base) { 224 allocate = false; 225 break; 226 } 227 } 228 if (allocate) { 229 kpage = km_temporary_page_get(&frame, 230 FRAME_NO_RESERVE); 231 memsetb((void *) kpage, PAGE_SIZE, 0); 232 km_temporary_page_put(kpage); 233 234 /* 235 * Insert the address of the newly allocated 236 * frame to the pagemap. 237 */ 238 btree_insert(&area->sh_info->pagemap, 239 upage - area->base, (void *) frame, leaf); 240 } 223 as_pagemap_insert(&area->sh_info->pagemap, 224 upage - area->base, frame); 241 225 } 242 226 frame_reference_add(ADDR2PFN(frame));
Note:
See TracChangeset
for help on using the changeset viewer.