Changeset 5f7a0ef in mainline for kernel/generic/src/mm/frame.c
- Timestamp:
- 2008-07-06T19:47:48Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 498b201
- Parents:
- 2ec725f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/frame.c
r2ec725f r5f7a0ef 201 201 } 202 202 203 /** 204 * Try to find a zone where can we find the frame. 203 /** Try to find a zone where can we find the frame. 205 204 * 206 205 * Assume interrupts are disabled. … … 238 237 if (i >= zones.count) 239 238 i = 0; 240 } while (i != hint);239 } while (i != hint); 241 240 242 241 spinlock_unlock(&zones.lock); … … 255 254 * 256 255 * @param order Size (2^order) of free space we are trying to find. 256 * @param flags Required flags of the target zone. 257 257 * @param pzone Pointer to preferred zone or NULL, on return contains 258 258 * zone number. 259 259 */ 260 static zone_t *find_free_zone_and_lock(uint8_t order, unsigned int *pzone) 260 static zone_t * 261 find_free_zone_and_lock(uint8_t order, int flags, unsigned int *pzone) 261 262 { 262 263 unsigned int i; … … 264 265 unsigned int hint = pzone ? *pzone : 0; 265 266 267 /* Mask off flags that are not applicable. */ 268 flags &= FRAME_LOW_16_GiB; 269 266 270 spinlock_lock(&zones.lock); 267 271 if (hint >= zones.count) … … 273 277 spinlock_lock(&z->lock); 274 278 275 /* Check if the zone has 2^order frames area available */ 276 if (zone_can_alloc(z, order)) { 277 spinlock_unlock(&zones.lock); 278 if (pzone) 279 *pzone = i; 280 return z; 279 /* 280 * Check whether the zone meets the search criteria. 281 */ 282 if ((z->flags & flags) == flags) { 283 /* 284 * Check if the zone has 2^order frames area available. 285 */ 286 if (zone_can_alloc(z, order)) { 287 spinlock_unlock(&zones.lock); 288 if (pzone) 289 *pzone = i; 290 return z; 291 } 281 292 } 282 293 spinlock_unlock(&z->lock); 283 294 if (++i >= zones.count) 284 295 i = 0; 285 } while (i != hint);296 } while (i != hint); 286 297 spinlock_unlock(&zones.lock); 287 298 return NULL; … … 811 822 z->base = start; 812 823 z->count = count; 824 825 /* Mask off flags that are calculated automatically. */ 826 flags &= ~FRAME_LOW_16_GiB; 827 /* Determine calculated flags. */ 828 if (z->base + count < (1ULL << (34 - FRAME_WIDTH))) /* 16 GiB */ 829 flags |= FRAME_LOW_16_GiB; 830 813 831 z->flags = flags; 832 814 833 z->free_count = count; 815 834 z->busy_count = 0; … … 983 1002 * First, find suitable frame zone. 984 1003 */ 985 zone = find_free_zone_and_lock(order, pzone);1004 zone = find_free_zone_and_lock(order, flags, pzone); 986 1005 987 1006 /* If no memory, reclaim some slab memory, … … 990 1009 freed = slab_reclaim(0); 991 1010 if (freed) 992 zone = find_free_zone_and_lock(order, pzone);1011 zone = find_free_zone_and_lock(order, flags, pzone); 993 1012 if (!zone) { 994 1013 freed = slab_reclaim(SLAB_RECLAIM_ALL); 995 1014 if (freed) 996 zone = find_free_zone_and_lock(order, pzone); 1015 zone = find_free_zone_and_lock(order, flags, 1016 pzone); 997 1017 } 998 1018 }
Note:
See TracChangeset
for help on using the changeset viewer.