Changeset 482f968 in mainline for kernel/generic/src/mm/frame.c


Ignore:
Timestamp:
2018-10-31T16:48:51Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
91a8f83, bab75df6
Parents:
37781819
Message:

Make FRAME_HIGHMEM fall back to low memory on failure.

Which is what existing users of it are doing, and there is no reason
not to as far as I can see.

Also make sure calls to frame_alloc all have either FRAME_LOWMEM or
FRAME_HIGHMEM explicitly set, as appropriate.

File:
1 edited

Legend:

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

    r37781819 r482f968  
    815815}
    816816
     817static size_t try_find_zone(size_t count, bool lowmem,
     818    pfn_t frame_constraint, size_t hint)
     819{
     820        if (!lowmem) {
     821                size_t znum = find_free_zone(count,
     822                    ZONE_HIGHMEM | ZONE_AVAILABLE, frame_constraint, hint);
     823                if (znum != (size_t) -1)
     824                        return znum;
     825        }
     826
     827        return find_free_zone(count, ZONE_LOWMEM | ZONE_AVAILABLE,
     828            frame_constraint, hint);
     829}
     830
    817831/** Allocate frames of physical memory.
    818832 *
     
    843857        irq_spinlock_lock(&zones.lock, true);
    844858
     859        // TODO: Print diagnostic if neither is explicitly specified.
     860        bool lowmem = (flags & FRAME_LOWMEM) || !(flags & FRAME_HIGHMEM);
     861
    845862        /*
    846863         * First, find suitable frame zone.
    847864         */
    848         size_t znum = find_free_zone(count, FRAME_TO_ZONE_FLAGS(flags),
    849             frame_constraint, hint);
     865        size_t znum = try_find_zone(count, lowmem, frame_constraint, hint);
    850866
    851867        /*
     
    859875
    860876                if (freed > 0)
    861                         znum = find_free_zone(count, FRAME_TO_ZONE_FLAGS(flags),
     877                        znum = try_find_zone(count, lowmem,
    862878                            frame_constraint, hint);
    863879
     
    868884
    869885                        if (freed > 0)
    870                                 znum = find_free_zone(count, FRAME_TO_ZONE_FLAGS(flags),
     886                                znum = try_find_zone(count, lowmem,
    871887                                    frame_constraint, hint);
    872888                }
Note: See TracChangeset for help on using the changeset viewer.