1.1 --- a/pages_conserving.cc Wed Mar 24 23:44:53 2021 +0100
1.2 +++ b/pages_conserving.cc Thu Mar 25 01:42:50 2021 +0100
1.3 @@ -1,12 +1,12 @@
1.4 #include "pages_conserving.h"
1.5
1.6 -PagesConserving::PagesConserving(Memory *memory, unsigned int increment)
1.7 -: Pages(memory), _increment(increment)
1.8 +PagesConserving::PagesConserving(Memory *memory)
1.9 +: Pages(memory)
1.10 {
1.11 }
1.12
1.13 PagesConserving::PagesConserving()
1.14 -: Pages(), _increment(1)
1.15 +: Pages()
1.16 {
1.17 }
1.18
1.19 @@ -42,7 +42,7 @@
1.20
1.21 /* Decrease the provision of flexpages to pipes. */
1.22
1.23 -bool PagesConserving::decrease()
1.24 +bool PagesConserving::decrease(offset_t size)
1.25 {
1.26 // NOTE: Need to remove flexpages from the queue.
1.27 // NOTE: This might need to happen incrementally in case some pages are not
1.28 @@ -54,15 +54,15 @@
1.29 /* Increase the provision of flexpages to pipes, returning whether allocation
1.30 succeeded. */
1.31
1.32 -bool PagesConserving::increase()
1.33 +bool PagesConserving::increase(offset_t size)
1.34 {
1.35 - unsigned int regions = _increment;
1.36 + offset_t allocated_size = 0;
1.37 std::list<Region *> allocated;
1.38 std::list<Region *>::iterator it;
1.39
1.40 /* Allocate regions for the defined increment value. */
1.41
1.42 - while (regions)
1.43 + while (allocated_size < size)
1.44 {
1.45 Region *r = _memory->region();
1.46
1.47 @@ -77,7 +77,7 @@
1.48 }
1.49
1.50 allocated.push_back(r);
1.51 - regions--;
1.52 + allocated_size += r->size();
1.53 }
1.54
1.55 /* Queue flexpages for the regions. */
1.56 @@ -88,11 +88,4 @@
1.57 return true;
1.58 }
1.59
1.60 -/* Return the allocation increment. */
1.61 -
1.62 -offset_t PagesConserving::allocation()
1.63 -{
1.64 - return _memory->region_size() * _increment;
1.65 -}
1.66 -
1.67 // vim: tabstop=4 expandtab shiftwidth=4