Changeset 5f7a0ef in mainline for kernel/generic/src/mm/frame.c


Ignore:
Timestamp:
2008-07-06T19:47:48Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
498b201
Parents:
2ec725f
Message:

Introduce FRAME_LOW_16_GiB slab/frame allocator flag. When specified, the
allocators will not allocate memory above 16 GiB. Each architecture needs to
make sure not to merge zones from below and above 16 GiB. Allocations that
require memory below 16 GiB need to be altered to use this flag.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/frame.c

    r2ec725f r5f7a0ef  
    201201}
    202202
    203 /**
    204  * Try to find a zone where can we find the frame.
     203/** Try to find a zone where can we find the frame.
    205204 *
    206205 * Assume interrupts are disabled.
     
    238237                if (i >= zones.count)
    239238                        i = 0;
    240         } while(i != hint);
     239        } while (i != hint);
    241240
    242241        spinlock_unlock(&zones.lock);
     
    255254 *
    256255 * @param order         Size (2^order) of free space we are trying to find.
     256 * @param flags         Required flags of the target zone.
    257257 * @param pzone         Pointer to preferred zone or NULL, on return contains
    258258 *                      zone number.
    259259 */
    260 static zone_t *find_free_zone_and_lock(uint8_t order, unsigned int *pzone)
     260static zone_t *
     261find_free_zone_and_lock(uint8_t order, int flags, unsigned int *pzone)
    261262{
    262263        unsigned int i;
     
    264265        unsigned int hint = pzone ? *pzone : 0;
    265266       
     267        /* Mask off flags that are not applicable. */
     268        flags &= FRAME_LOW_16_GiB;
     269
    266270        spinlock_lock(&zones.lock);
    267271        if (hint >= zones.count)
     
    273277                spinlock_lock(&z->lock);
    274278
    275                 /* Check if the zone has 2^order frames area available  */
    276                 if (zone_can_alloc(z, order)) {
    277                         spinlock_unlock(&zones.lock);
    278                         if (pzone)
    279                                 *pzone = i;
    280                         return z;
     279                /*
     280                 * Check whether the zone meets the search criteria.
     281                 */
     282                if ((z->flags & flags) == flags) {
     283                        /*
     284                         * Check if the zone has 2^order frames area available.
     285                         */
     286                        if (zone_can_alloc(z, order)) {
     287                                spinlock_unlock(&zones.lock);
     288                                if (pzone)
     289                                        *pzone = i;
     290                                return z;
     291                        }
    281292                }
    282293                spinlock_unlock(&z->lock);
    283294                if (++i >= zones.count)
    284295                        i = 0;
    285         } while(i != hint);
     296        } while (i != hint);
    286297        spinlock_unlock(&zones.lock);
    287298        return NULL;
     
    811822        z->base = start;
    812823        z->count = count;
     824
     825        /* Mask off flags that are calculated automatically. */
     826        flags &= ~FRAME_LOW_16_GiB;
     827        /* Determine calculated flags. */
     828        if (z->base + count < (1ULL << (34 - FRAME_WIDTH)))     /* 16 GiB */
     829                flags |= FRAME_LOW_16_GiB;
     830
    813831        z->flags = flags;
     832
    814833        z->free_count = count;
    815834        z->busy_count = 0;
     
    9831002         * First, find suitable frame zone.
    9841003         */
    985         zone = find_free_zone_and_lock(order, pzone);
     1004        zone = find_free_zone_and_lock(order, flags, pzone);
    9861005       
    9871006        /* If no memory, reclaim some slab memory,
     
    9901009                freed = slab_reclaim(0);
    9911010                if (freed)
    992                         zone = find_free_zone_and_lock(order, pzone);
     1011                        zone = find_free_zone_and_lock(order, flags, pzone);
    9931012                if (!zone) {
    9941013                        freed = slab_reclaim(SLAB_RECLAIM_ALL);
    9951014                        if (freed)
    996                                 zone = find_free_zone_and_lock(order, pzone);
     1015                                zone = find_free_zone_and_lock(order, flags,
     1016                                    pzone);
    9971017                }
    9981018        }
Note: See TracChangeset for help on using the changeset viewer.