On Fri, Jan 18, 2019 at 01:55:24PM +0100, Vlastimil Babka wrote:
> > +static bool
> > +__reset_isolation_pfn(struct zone *zone, unsigned long pfn, bool 
> > check_source,
> > +                                                   bool check_target)
> > +{
> > +   struct page *page = pfn_to_online_page(pfn);
> > +   struct page *end_page;
> > +
> > +   if (!page)
> > +           return false;
> > +   if (zone != page_zone(page))
> > +           return false;
> > +   if (pageblock_skip_persistent(page))
> > +           return false;
> > +
> > +   /*
> > +    * If skip is already cleared do no further checking once the
> > +    * restart points have been set.
> > +    */
> > +   if (check_source && check_target && !get_pageblock_skip(page))
> > +           return true;
> > +
> > +   /*
> > +    * If clearing skip for the target scanner, do not select a
> > +    * non-movable pageblock as the starting point.
> > +    */
> > +   if (!check_source && check_target &&
> > +       get_pageblock_migratetype(page) != MIGRATE_MOVABLE)
> > +           return false;
> > +
> > +   /*
> > +    * Only clear the hint if a sample indicates there is either a
> > +    * free page or an LRU page in the block. One or other condition
> > +    * is necessary for the block to be a migration source/target.
> > +    */
> > +   page = pfn_to_page(pageblock_start_pfn(pfn));
> > +   if (zone != page_zone(page))
> > +           return false;
> > +   end_page = page + pageblock_nr_pages;
> 
> Watch out for start pfn being invalid, and end_page being invalid or after 
> zone end?
> 

Yeah, it is possible there is no alignment on pageblock_nr_pages.

> > +
> > +   do {
> > +           if (check_source && PageLRU(page)) {
> > +                   clear_pageblock_skip(page);
> > +                   return true;
> > +           }
> > +
> > +           if (check_target && PageBuddy(page)) {
> > +                   clear_pageblock_skip(page);
> > +                   return true;
> > +           }
> > +
> > +           page += (1 << PAGE_ALLOC_COSTLY_ORDER);
> 
> Also probably check pfn_valid_within() and page_zone?
> 

Again yes. Holes could have been punched.

I've an updated version but I'll shove it through tests just to be sure.

> > +   } while (page < end_page);
> > +
> > +   return false;
> > +}
> > +
> >  /*
> >   * This function is called to clear all cached information on pageblocks 
> > that
> >   * should be skipped for page isolation when the migrate and free page 
> > scanner
> 
> ...
> 
> > @@ -1193,7 +1273,7 @@ fast_isolate_freepages(struct compact_control *cc)
> >      * If starting the scan, use a deeper search and use the highest
> >      * PFN found if a suitable one is not found.
> >      */
> > -   if (cc->free_pfn == pageblock_start_pfn(zone_end_pfn(cc->zone) - 1)) {
> > +   if (cc->free_pfn >= cc->zone->compact_init_free_pfn) {
> >             limit = pageblock_nr_pages >> 1;
> >             scan_start = true;
> >     }
> > @@ -1338,7 +1418,6 @@ static void isolate_freepages(struct compact_control 
> > *cc)
> >     unsigned long isolate_start_pfn; /* exact pfn we start at */
> >     unsigned long block_end_pfn;    /* end of current pageblock */
> >     unsigned long low_pfn;       /* lowest pfn scanner is able to scan */
> > -   unsigned long nr_isolated;
> >     struct list_head *freelist = &cc->freepages;
> >     unsigned int stride;
> >  
> > @@ -1374,6 +1453,8 @@ static void isolate_freepages(struct compact_control 
> > *cc)
> >                             block_end_pfn = block_start_pfn,
> >                             block_start_pfn -= pageblock_nr_pages,
> >                             isolate_start_pfn = block_start_pfn) {
> > +           unsigned long nr_isolated;
> 
> Unrelated cleanup? Nevermind.
> 

I'll move the hunks to "mm, compaction: Sample pageblocks for free
pages" where they belong

-- 
Mel Gorman
SUSE Labs

Reply via email to