Changeset b0c2075 in mainline for kernel/test/mm/falloc1.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/falloc1.c

    r86733f3 rb0c2075  
    3737#include <align.h>
    3838
    39 #define MAX_FRAMES  1024U
     39#define MAX_FRAMES  1024
    4040#define MAX_ORDER   8
    4141#define TEST_RUNS   2
     
    5151                return "Unable to allocate frames";
    5252       
    53         unsigned int results[MAX_ORDER + 1];
     53        unsigned int results[MAX_FRAMES + 1];
     54       
    5455        for (unsigned int run = 0; run < TEST_RUNS; run++) {
    55                 for (unsigned int order = 0; order <= MAX_ORDER; order++) {
    56                         TPRINTF("Allocating %u frames blocks ... ", 1 << order);
     56                for (size_t count = 1; count <= MAX_FRAMES; count++) {
     57                        size_t bytes = FRAMES2SIZE(count);
     58                       
     59                        TPRINTF("Allocating %zu frames blocks (%zu bytes) ... ",
     60                            count, bytes);
    5761                       
    5862                        unsigned int allocated = 0;
    59                         for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
     63                        for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) {
    6064                                frames[allocated] =
    61                                     PA2KA(frame_alloc(order, FRAME_ATOMIC, 0));
    62                                
    63                                 if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) !=
    64                                     frames[allocated]) {
    65                                         TPRINTF("Block at address %p (size %u) is not aligned\n",
    66                                             (void *) frames[allocated], (FRAME_SIZE << order) >> 10);
    67                                         return "Test failed";
    68                                 }
     65                                    PA2KA(frame_alloc(count, FRAME_ATOMIC, 0));
    6966                               
    7067                                if (frames[allocated])
     
    7875                        TPRINTF("%d blocks allocated.\n", allocated);
    7976                       
    80                         if (run) {
    81                                 if (results[order] != allocated)
     77                        if (run > 0) {
     78                                if (results[count] != allocated)
    8279                                        return "Possible frame leak";
    8380                        } else
    84                                 results[order] = allocated;
     81                                results[count] = allocated;
    8582                       
    8683                        TPRINTF("Deallocating ... ");
Note: See TracChangeset for help on using the changeset viewer.