Rev 3188 | Rev 3206 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3188 | Rev 3205 | ||
---|---|---|---|
Line 1212... | Line 1212... | ||
1212 | { |
1212 | { |
1213 | zone_t *zone = NULL; |
1213 | zone_t *zone = NULL; |
1214 | unsigned int i; |
1214 | unsigned int i; |
1215 | ipl_t ipl; |
1215 | ipl_t ipl; |
1216 | 1216 | ||
1217 | ipl = interrupts_disable(); |
- | |
1218 | spinlock_lock(&zones.lock); |
- | |
1219 | - | ||
1220 | #ifdef __32_BITS__ |
1217 | #ifdef __32_BITS__ |
1221 | printf("# base address free frames busy frames\n"); |
1218 | printf("# base address free frames busy frames\n"); |
1222 | printf("-- ------------ ------------ ------------\n"); |
1219 | printf("-- ------------ ------------ ------------\n"); |
1223 | #endif |
1220 | #endif |
1224 | 1221 | ||
1225 | #ifdef __64_BITS__ |
1222 | #ifdef __64_BITS__ |
1226 | printf("# base address free frames busy frames\n"); |
1223 | printf("# base address free frames busy frames\n"); |
1227 | printf("-- -------------------- ------------ ------------\n"); |
1224 | printf("-- -------------------- ------------ ------------\n"); |
1228 | #endif |
1225 | #endif |
1229 | 1226 | ||
- | 1227 | /* |
|
- | 1228 | * Because printing may require allocation of memory, we may not hold |
|
- | 1229 | * the frame allocator locks when printing zone statistics. Therefore, |
|
- | 1230 | * we simply gather the statistics under the protection of the locks and |
|
- | 1231 | * print the statistics when the locks have been released. |
|
- | 1232 | * |
|
- | 1233 | * When someone adds/removes zones while we are printing the statistics, |
|
- | 1234 | * we may end up with inaccurate output (e.g. a zone being skipped from |
|
- | 1235 | * the listing). |
|
- | 1236 | */ |
|
- | 1237 | ||
1230 | for (i = 0; i < zones.count; i++) { |
1238 | for (i = 0; ; i++) { |
- | 1239 | uintptr_t base; |
|
- | 1240 | count_t free_count; |
|
- | 1241 | count_t busy_count; |
|
- | 1242 | ||
- | 1243 | ipl = interrupts_disable(); |
|
- | 1244 | spinlock_lock(&zones.lock); |
|
- | 1245 | ||
- | 1246 | if (i >= zones.count) { |
|
- | 1247 | spinlock_unlock(&zones.lock); |
|
- | 1248 | interrupts_restore(ipl); |
|
- | 1249 | break; |
|
- | 1250 | } |
|
- | 1251 | ||
1231 | zone = zones.info[i]; |
1252 | zone = zones.info[i]; |
1232 | spinlock_lock(&zone->lock); |
1253 | spinlock_lock(&zone->lock); |
1233 | 1254 | ||
- | 1255 | base = PFN2ADDR(zone->base); |
|
- | 1256 | free_count = zone->free_count; |
|
- | 1257 | busy_count = zone->busy_count; |
|
- | 1258 | ||
- | 1259 | spinlock_unlock(&zone->lock); |
|
- | 1260 | ||
- | 1261 | spinlock_unlock(&zones.lock); |
|
- | 1262 | interrupts_restore(ipl); |
|
- | 1263 | ||
1234 | #ifdef __32_BITS__ |
1264 | #ifdef __32_BITS__ |
1235 | printf("%-2u %10p %12" PRIc " %12" PRIc "\n", |
1265 | printf("%-2u %10p %12" PRIc " %12" PRIc "\n", i, base, |
1236 | i, PFN2ADDR(zone->base), zone->free_count, |
- | |
1237 | zone->busy_count); |
1266 | free_count, busy_count); |
1238 | #endif |
1267 | #endif |
1239 | 1268 | ||
1240 | #ifdef __64_BITS__ |
1269 | #ifdef __64_BITS__ |
1241 | printf("%-2u %18p %12" PRIc " %12" PRIc "\n", i, |
1270 | printf("%-2u %18p %12" PRIc " %12" PRIc "\n", i, base, |
1242 | PFN2ADDR(zone->base), zone->free_count, zone->busy_count); |
1271 | free_count, busy_count); |
1243 | #endif |
1272 | #endif |
1244 | 1273 | ||
1245 | spinlock_unlock(&zone->lock); |
- | |
1246 | } |
1274 | } |
1247 | - | ||
1248 | spinlock_unlock(&zones.lock); |
- | |
1249 | interrupts_restore(ipl); |
- | |
1250 | } |
1275 | } |
1251 | 1276 | ||
1252 | /** Prints zone details. |
1277 | /** Prints zone details. |
1253 | * |
1278 | * |
1254 | * @param num Zone base address or zone number. |
1279 | * @param num Zone base address or zone number. |