Subversion Repositories HelenOS

Rev

Rev 2927 | Rev 3211 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2927 Rev 3149
Line 42... Line 42...
42
#include <mm/buddy.h>
42
#include <mm/buddy.h>
43
#include <mm/frame.h>
43
#include <mm/frame.h>
44
#include <arch/types.h>
44
#include <arch/types.h>
45
#include <debug.h>
45
#include <debug.h>
46
#include <print.h>
46
#include <print.h>
-
 
47
#include <macros.h>
47
 
48
 
48
/** Return size needed for the buddy configuration data */
49
/** Return size needed for the buddy configuration data */
49
size_t buddy_conf_size(int max_order)
50
size_t buddy_conf_size(int max_order)
50
{
51
{
51
    return sizeof(buddy_system_t) + (max_order + 1) * sizeof(link_t);
52
    return sizeof(buddy_system_t) + (max_order + 1) * sizeof(link_t);
Line 287... Line 288...
287
 * @param elem_size Element size
288
 * @param elem_size Element size
288
 */
289
 */
289
void buddy_system_structure_print(buddy_system_t *b, size_t elem_size) {
290
void buddy_system_structure_print(buddy_system_t *b, size_t elem_size) {
290
    index_t i;
291
    index_t i;
291
    count_t cnt, elem_count = 0, block_count = 0;
292
    count_t cnt, elem_count = 0, block_count = 0;
292
    link_t * cur;
293
    link_t *cur;
293
   
294
   
294
 
295
 
295
    printf("Order\tBlocks\tSize    \tBlock size\tElems per block\n");
296
    printf("Order\tBlocks\tSize    \tBlock size\tElems per block\n");
296
    printf("-----\t------\t--------\t----------\t---------------\n");
297
    printf("-----\t------\t--------\t----------\t---------------\n");
297
   
298
   
298
    for (i=0;i <= b->max_order; i++) {
299
    for (i = 0;i <= b->max_order; i++) {
299
        cnt = 0;
300
        cnt = 0;
300
        if (!list_empty(&b->order[i])) {
301
        if (!list_empty(&b->order[i])) {
301
            for (cur = b->order[i].next; cur != &b->order[i]; cur = cur->next)
302
            for (cur = b->order[i].next; cur != &b->order[i]; cur = cur->next)
302
                cnt++;
303
                cnt++;
303
        }
304
        }
304
   
305
   
-
 
306
        printf("#%" PRIi "\t%5" PRIc "\t%7" PRIc "K\t%8" PRIi "K\t%6u\t",
305
        printf("#%zd\t%5zd\t%7zdK\t%8zdK\t%6zd\t", i, cnt, (cnt * (1 << i) * elem_size) >> 10, ((1 << i) * elem_size) >> 10, 1 << i);
307
            i, cnt, SIZE2KB(cnt * (1 << i) * elem_size), SIZE2KB((1 << i) * elem_size), 1 << i);
306
        if (!list_empty(&b->order[i])) {
308
        if (!list_empty(&b->order[i])) {
307
            for (cur = b->order[i].next; cur != &b->order[i]; cur = cur->next) {
309
            for (cur = b->order[i].next; cur != &b->order[i]; cur = cur->next) {
308
                b->op->print_id(b, cur);
310
                b->op->print_id(b, cur);
309
                printf(" ");
311
                printf(" ");
310
            }
312
            }
Line 313... Line 315...
313
           
315
           
314
        block_count += cnt;
316
        block_count += cnt;
315
        elem_count += (1 << i) * cnt;
317
        elem_count += (1 << i) * cnt;
316
    }
318
    }
317
    printf("-----\t------\t--------\t----------\t---------------\n");
319
    printf("-----\t------\t--------\t----------\t---------------\n");
318
    printf("Buddy system contains %zd free elements (%zd blocks)\n" , elem_count, block_count);
320
    printf("Buddy system contains %" PRIc " free elements (%" PRIc " blocks)\n" , elem_count, block_count);
319
 
-
 
320
}
321
}
321
 
322
 
322
/** @}
323
/** @}
323
 */
324
 */