Changeset 566ba81 in mainline


Ignore:
Timestamp:
2006-01-08T14:43:52Z (19 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6d7ffa65
Parents:
2fe2046c
Message:

Console command 'zone' now takes zone address as parameter.
Added buddy system statistics into the 'zone' command.

Location:
generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • generic/include/mm/buddy.h

    r2fe2046c r566ba81  
    5656extern bool buddy_system_can_alloc(buddy_system_t *b, __u8 order);
    5757extern void buddy_system_free(buddy_system_t *b, link_t *block);
     58extern void buddy_system_structure_print(buddy_system_t *b);
     59
    5860
    5961#endif
  • generic/include/mm/frame.h

    r2fe2046c r566ba81  
    114114 */
    115115extern void zone_print_list(void);
    116 extern void zone_print_one(index_t index);
     116extern void zone_print_one(__address base);
    117117
    118118#endif
  • generic/src/mm/buddy.c

    r2fe2046c r566ba81  
    231231
    232232}
     233
     234
     235
     236/** Prints out structure of buddy system
     237 *
     238 * @param b Pointer to buddy system
     239 * @param es Element size
     240 */
     241void buddy_system_structure_print(buddy_system_t *b) {
     242        index_t i;
     243        count_t cnt, elem_count = 0, block_count = 0;
     244        link_t * cur;
     245       
     246
     247        printf("Order\tStatistics\n");
     248        printf("-----\t--------------------------------------\n");
     249       
     250        for (i=0;i < b->max_order; i++) {
     251                cnt = 0;
     252                if (!list_empty(&b->order[i])) {
     253                        for (cur = b->order[i].next; cur != &b->order[i]; cur = cur->next) cnt++;
     254                }
     255       
     256                printf("#%d:\t%d blocks available (%d elements per block)\n", i, cnt, 1 << i);
     257               
     258                block_count += cnt;
     259                elem_count += (1 << i) * cnt;
     260        }
     261        printf("-----\t--------------------------------------\n");
     262        printf("Buddy system contains %d elements (%d blocks)\n" , elem_count, block_count);
     263
     264}
  • generic/src/mm/frame.c

    r2fe2046c r566ba81  
    491491        link_t *cur;
    492492        index_t i = 0;
     493        spinlock_lock(&zone_head_lock);
    493494        printf("No.\tBase address\tFree Frames\tBusy Frames\n");
    494495        printf("---\t------------\t-----------\t-----------\n");
    495496        for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
    496497                zone = list_get_instance(cur, zone_t, link);
     498                spinlock_lock(&zone->lock);
    497499                printf("%d\t%L\t%d\t\t%d\n",i++,zone->base, zone->free_count, zone->busy_count);
    498500        }
     501        spinlock_unlock(&zone_head_lock);
    499502
    500503}
     
    502505/** Prints zone details
    503506 *
    504  * @param zone_index Zone order in zones list (0 is the first zone)
    505  */
    506 void zone_print_one(index_t zone_index) {
    507         zone_t *zone = NULL;
     507 * @param base Zone base address
     508 */
     509void zone_print_one(__address base) {
     510        zone_t *zone = NULL, *z ;
    508511        link_t *cur;
    509         index_t i = 0;
     512       
     513       
     514        spinlock_lock(&zone_head_lock);
     515       
    510516       
    511517        for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
    512                 if (i == zone_index) {
    513                         zone = list_get_instance(cur, zone_t, link);
     518                z = list_get_instance(cur, zone_t, link);
     519                if (base == z->base) {
     520                        zone = z;
    514521                        break;
    515522                }
    516                 i++;
    517         }
     523        }
     524       
    518525       
    519526        if (!zone) {
    520                 printf("No zone with index %d\n", zone_index);
     527                printf("No zone with address %X\n", base);
    521528                return;
    522529        }
    523530       
    524         printf("Memory zone %d information\n\n", zone_index);
     531        spinlock_lock(&zone->lock);
     532        printf("Memory zone information\n\n");
    525533        printf("Zone base address: %P\n", zone->base);
    526534        printf("Zone size: %d frames (%d kbytes)\n", zone->free_count + zone->busy_count, ((zone->free_count + zone->busy_count) * FRAME_SIZE) >> 10);
    527535        printf("Allocated space: %d frames (%d kbytes)\n", zone->busy_count, (zone->busy_count * FRAME_SIZE) >> 10);
    528536        printf("Available space: %d (%d kbytes)\n", zone->free_count, (zone->free_count * FRAME_SIZE) >> 10);
    529         printf("Buddy allocator structures: not implemented\n");
    530 }
    531 
     537       
     538        printf("\nBuddy allocator structures:\n\n");
     539        buddy_system_structure_print(zone->buddy_system);
     540       
     541       
     542        spinlock_unlock(&zone->lock);
     543        spinlock_unlock(&zone_head_lock);
     544       
     545}
     546
Note: See TracChangeset for help on using the changeset viewer.