Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 8d308b9 in mainline


Ignore:
Timestamp:
2011-05-15T19:28:27Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
0d8a304, 9d47440
Parents:
d61c3a7
Message:

Start tracking reservable memory after zones are created and possibly
merged. The initial amount of reservable memory is the number of free
frames at the time of call to reserve_init().

Location:
kernel/generic
Files:
5 edited

Legend:

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

    rd61c3a7 r8d308b9  
    164164extern void frame_free_noreserve(uintptr_t);
    165165extern void frame_reference_add(pfn_t);
     166extern size_t frame_total_free_get(void);
    166167
    167168extern size_t find_zone(pfn_t, size_t, size_t);
  • kernel/generic/include/mm/reserve.h

    rd61c3a7 r8d308b9  
    3838#include <typedefs.h>
    3939
     40extern void reserve_init(void);
    4041extern bool reserve_try_alloc(size_t);
    4142extern void reserve_force_alloc(size_t);
  • kernel/generic/src/main/main.c

    rd61c3a7 r8d308b9  
    7171#include <mm/as.h>
    7272#include <mm/slab.h>
     73#include <mm/reserve.h>
    7374#include <synch/waitq.h>
    7475#include <synch/futex.h>
     
    217218        ddi_init();
    218219        arch_post_mm_init();
     220        reserve_init();
    219221        arch_pre_smp_init();
    220222        smp_init();
  • kernel/generic/src/mm/frame.c

    rd61c3a7 r8d308b9  
    182182 *
    183183 */
    184 #ifdef CONFIG_DEBUG
    185 NO_TRACE static size_t total_frames_free(void)
     184NO_TRACE static size_t frame_total_free_get_internal(void)
    186185{
    187186        size_t total = 0;
    188187        size_t i;
     188
    189189        for (i = 0; i < zones.count; i++)
    190190                total += zones.info[i].free_count;
     
    192192        return total;
    193193}
    194 #endif /* CONFIG_DEBUG */
     194
     195NO_TRACE size_t frame_total_free_get(void)
     196{
     197        size_t total;
     198
     199        irq_spinlock_lock(&zones.lock, true);
     200        total = frame_total_free_get_internal();
     201        irq_spinlock_unlock(&zones.lock, true);
     202
     203        return total;
     204}
     205
    195206
    196207/** Find a zone with a given frames.
     
    840851                        buddy_system_free(zone->buddy_system, &zone->frames[i].buddy_link);
    841852                }
    842 
    843                 /* "Unreserve" new frames. */
    844                 reserve_free(count);
    845853        } else
    846854                zone->frames = NULL;
     
    10511059               
    10521060#ifdef CONFIG_DEBUG
    1053                 size_t avail = total_frames_free();
     1061                size_t avail = frame_total_free_get_internal();
    10541062#endif
    10551063               
  • kernel/generic/src/mm/reserve.c

    rd61c3a7 r8d308b9  
    4545IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(reserve_lock, "reserve_lock");
    4646static ssize_t reserve = 0;
     47
     48/** Initialize memory reservations tracking.
     49 *
     50 * This function must be called after frame zones are created and merged
     51 * and before any address space area is created.
     52 */
     53void reserve_init(void)
     54{
     55        reserve = frame_total_free_get();
     56}
    4757
    4858/** Try to reserve memory.
Note: See TracChangeset for help on using the changeset viewer.