Changeset b0c2075 in mainline for kernel/test/mm/falloc2.c


Ignore:
Timestamp:
2013-09-10T17:48:57Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
85147f3
Parents:
86733f3
Message:

new physical memory allocator supporting physical address constrains
the buddy allocator framework is retired and replaced by a two-level bitmap
the allocator can allocate an arbitrary number of frames, not only a power-of-two count

Caution: Change of semantics
The physical memory allocator no longer allocates naturally aligned blocks. If you require an aligned block, specify it as the constraint.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/mm/falloc2.c

    r86733f3 rb0c2075  
    4040#include <arch.h>
    4141
    42 #define MAX_FRAMES  256U
    43 #define MAX_ORDER   8
     42#define MAX_FRAMES  256
    4443
    4544#define THREAD_RUNS  1
     
    6665       
    6766        for (unsigned int run = 0; run < THREAD_RUNS; run++) {
    68                 for (unsigned int order = 0; order <= MAX_ORDER; order++) {
     67                for (size_t count = 1; count <= MAX_FRAMES; count++) {
     68                        size_t bytes = FRAMES2SIZE(count);
     69                       
    6970                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    70                             "Allocating %u frames blocks ... \n", THREAD->tid,
    71                             CPU->id, 1 << order);
     71                            "Allocating %zu frames blocks (%zu bytes) ... \n", THREAD->tid,
     72                            CPU->id, count, bytes);
    7273                       
    7374                        unsigned int allocated = 0;
    74                         for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
     75                        for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) {
    7576                                frames[allocated] =
    76                                     PA2KA(frame_alloc(order, FRAME_ATOMIC, 0));
     77                                    PA2KA(frame_alloc(count, FRAME_ATOMIC, 0));
    7778                                if (frames[allocated]) {
    78                                         memsetb((void *) frames[allocated], FRAME_SIZE << order, val);
     79                                        memsetb((void *) frames[allocated], bytes, val);
    7980                                        allocated++;
    8081                                } else
     
    8990                       
    9091                        for (unsigned int i = 0; i < allocated; i++) {
    91                                 for (size_t k = 0; k <= (((size_t) FRAME_SIZE << order) - 1);
    92                                     k++) {
     92                                for (size_t k = 0; k < bytes; k++) {
    9393                                        if (((uint8_t *) frames[i])[k] != val) {
    9494                                                TPRINTF("Thread #%" PRIu64 " (cpu%u): "
Note: See TracChangeset for help on using the changeset viewer.