Changeset e5a015b in mainline for kernel/generic/include/mm/frame.h


Ignore:
Timestamp:
2011-04-16T20:45:36Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a7dbd49
Parents:
b2fb47f (diff), 9e953bda (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge the memory reservation feature (Phase 1) from
lp:~jakub/helenos/mm.

This merge makes the testcase from ticket #114 non-reproducible. The
testcase is now available as tester's malloc2 test. It also seems to me
that this merge makes it harder for the system to run out of memory
during kconsole 'test *' and 'tester *', even though I did see several
hangs already with this feature in place. See below for what is still
missing to make the hangs even less probable or even impossible.

In Phase 1, I am targeting just the low-hanging fruits. In particular,
only anonymous and ELF backend pages are reserved physical memory at
time of as_area_create() and as_area_resize(). Memory is unreserved on
as_area_destroy(). In all other cases, memory is reserved at the same
time as it is allocated, making those calls subject to infinite
blocking if FRAME_ATOMIC is not used.

Possible sources of memory overcommit not addressed in this merge:

  • As mentioned above, only backend pages are reserved; pages for supporting structures such as B+tree nodes, TTEs are not reserved or handled otherwise. Kernel heap allocator fragmentation is not included in the reservations either.
  • The initial amount of reservable memory is fed from zone_construct(). Zone merging is not taken into account, which can make the reservable memory tracking inaccurate.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/mm/frame.h

    rb2fb47f re5a015b  
    6262
    6363/** Convert the frame address to kernel VA. */
    64 #define FRAME_KA          0x01
     64#define FRAME_KA          0x1
    6565/** Do not panic and do not sleep on failure. */
    66 #define FRAME_ATOMIC      0x02
     66#define FRAME_ATOMIC      0x2
    6767/** Do not start reclaiming when no free memory. */
    68 #define FRAME_NO_RECLAIM  0x04
     68#define FRAME_NO_RECLAIM  0x4
     69/** Do not reserve / unreserve memory. */
     70#define FRAME_NO_RESERVE  0x8
    6971
    7072typedef uint8_t zone_flags_t;
    7173
    7274/** Available zone (free for allocation) */
    73 #define ZONE_AVAILABLE  0x00
     75#define ZONE_AVAILABLE  0x0
    7476/** Zone is reserved (not available for allocation) */
    75 #define ZONE_RESERVED   0x08
     77#define ZONE_RESERVED   0x8
    7678/** Zone is used by firmware (not available for allocation) */
    7779#define ZONE_FIRMWARE   0x10
     
    8587        uint8_t buddy_order;  /**< Buddy system block order */
    8688        link_t buddy_link;    /**< Link to the next free block inside
    87                                one order */
     89                                   one order */
    8890        void *parent;         /**< If allocated by slab, this points there */
    8991} frame_t;
     
    9193typedef struct {
    9294        pfn_t base;                    /**< Frame_no of the first frame
    93                                         in the frames array */
     95                                            in the frames array */
    9496        size_t count;                  /**< Size of zone */
    9597        size_t free_count;             /**< Number of free frame_t
    96                                         structures */
     98                                            structures */
    9799        size_t busy_count;             /**< Number of busy frame_t
    98                                         structures */
     100                                            structures */
    99101        zone_flags_t flags;            /**< Type of the zone */
    100102       
    101103        frame_t *frames;               /**< Array of frame_t structures
    102                                         in this zone */
     104                                            in this zone */
    103105        buddy_system_t *buddy_system;  /**< Buddy system for the zone */
    104106} zone_t;
     
    146148    ((~(((sysarg_t) -1) << (order)) & (index)) == 0)
    147149#define IS_BUDDY_LEFT_BLOCK(zone, frame) \
    148     (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x01) == 0)
     150    (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
    149151#define IS_BUDDY_RIGHT_BLOCK(zone, frame) \
    150     (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x01) == 1)
     152    (((frame_index((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
    151153#define IS_BUDDY_LEFT_BLOCK_ABS(zone, frame) \
    152     (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x01) == 0)
     154    (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 0)
    153155#define IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame) \
    154     (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x01) == 1)
    155 
    156 #define frame_alloc(order, flags) \
    157     frame_alloc_generic(order, flags, NULL)
     156    (((frame_index_abs((zone), (frame)) >> (frame)->buddy_order) & 0x1) == 1)
    158157
    159158extern void frame_init(void);
    160159extern void *frame_alloc_generic(uint8_t, frame_flags_t, size_t *);
     160extern void *frame_alloc(uint8_t, frame_flags_t);
     161extern void *frame_alloc_noreserve(uint8_t, frame_flags_t);
     162extern void frame_free_generic(uintptr_t, frame_flags_t);
    161163extern void frame_free(uintptr_t);
     164extern void frame_free_noreserve(uintptr_t);
    162165extern void frame_reference_add(pfn_t);
    163166
    164 extern size_t find_zone(pfn_t frame, size_t count, size_t hint);
     167extern size_t find_zone(pfn_t, size_t, size_t);
    165168extern size_t zone_create(pfn_t, size_t, pfn_t, zone_flags_t);
    166169extern void *frame_get_parent(pfn_t, size_t);
Note: See TracChangeset for help on using the changeset viewer.