Changeset 692bd3f2 in mainline
- Timestamp:
- 2012-11-06T22:51:56Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1107050
- Parents:
- 338810f
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/mm/as.h
r338810f r692bd3f2 42 42 #define AS_AREA_CACHEABLE 0x08 43 43 #define AS_AREA_GUARD 0x10 44 #define AS_AREA_NORESERVE 0x20 44 45 45 46 /** Address space area info exported to uspace. */ -
kernel/generic/src/mm/backend_anon.c
r338810f r692bd3f2 74 74 bool anon_create(as_area_t *area) 75 75 { 76 if (area->flags & AS_AREA_NORESERVE) 77 return true; 78 76 79 return reserve_try_alloc(area->pages); 77 80 } … … 79 82 bool anon_resize(as_area_t *area, size_t new_pages) 80 83 { 84 if (area->flags & AS_AREA_NORESERVE) 85 return true; 86 81 87 if (new_pages > area->pages) 82 88 return reserve_try_alloc(new_pages - area->pages); … … 100 106 ASSERT(mutex_locked(&area->as->lock)); 101 107 ASSERT(mutex_locked(&area->lock)); 108 ASSERT(!(area->flags & AS_AREA_NORESERVE)); 102 109 103 110 /* … … 139 146 void anon_destroy(as_area_t *area) 140 147 { 148 if (area->flags & AS_AREA_NORESERVE) 149 return; 150 141 151 reserve_free(area->pages); 142 152 } … … 225 235 * the different causes 226 236 */ 227 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE); 237 238 unsigned int flags; 239 240 if (area->flags & AS_AREA_NORESERVE) { 241 /* 242 * This is a NORESERVE area, which means that no 243 * physical memory has been reserved beforehands. 244 * We therefore need to make an atomic and reserving 245 * allocation. 246 */ 247 flags = FRAME_ATOMIC; 248 } else { 249 /* 250 * The physical memory has already been reserved 251 * when this part of the area was created. Avoid 252 * double reservation by using the appropriate flag. 253 */ 254 flags = FRAME_NO_RESERVE; 255 } 256 257 kpage = km_temporary_page_get(&frame, flags); 258 if (!kpage) 259 return AS_PF_FAULT; 228 260 memsetb((void *) kpage, PAGE_SIZE, 0); 229 261 km_temporary_page_put(kpage); … … 255 287 ASSERT(mutex_locked(&area->lock)); 256 288 257 frame_free_noreserve(frame); 289 if (area->flags & AS_AREA_NORESERVE) { 290 /* 291 * In case of the NORESERVE areas, physical memory will not be 292 * unreserved when the area is destroyed so we need to use the 293 * normal unreserving frame_free(). 294 */ 295 frame_free(frame); 296 } else { 297 /* 298 * The reserve will be given back when the area is destroyed or 299 * resized, so use the frame_free_noreserve() which does not 300 * manipulate the reserve or it would be given back twice. 301 */ 302 frame_free_noreserve(frame); 303 } 258 304 } 259 305
Note:
See TracChangeset
for help on using the changeset viewer.