mm: vmscan: correct some vmscan counters for
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 25 lines · Hillf Danton
Quoted 24 lines · On Fri, 24 May 2019 09:27:02 +0800 Yang Shi wrote:
Quoted 9 lines · Hillf Danton
Review
Quoted 7 lines · On Thu, 23 May 2019 10:27:38 +0800 Yang Shi wrote:
@ -1642,14 +1650,14 @@ static unsigned long isolate_lru_pages(unsigned long
nr_to_scan,unsigned long nr_zone_taken[MAX_NR_ZONES] = { 0 }; unsigned long nr_skipped[MAX_NR_ZONES] = { 0, }; unsigned long skipped = 0;(quoted diff) +2
-1- unsigned long scan, total_scan, nr_pages; + unsigned long scan, total_scan; + unsigned long nr_pages;Change for no earn:)
Aha, yes.
Quoted 12 lines
Review
Quoted 9 lines
LIST_HEAD(pages_skipped); isolate_mode_t mode = (sc->may_unmap ? 0 : ISOLATE_UNMAPPED);(quoted diff) +2
-3+ total_scan = 0; scan = 0; - for (total_scan = 0; - scan < nr_to_scan && nr_taken < nr_to_scan && !list_empty(src); - total_scan++) { + while (scan < nr_to_scan && !list_empty(src)) { struct page *page;AFAICS scan currently prevents us from looping for ever, while
nr_takenbails us out once we get what's expected, so I doubt it makes much sense to cutnr_takenoff.
Quoted 4 lines
Quoted 3 lines
It is because "scan <
nr_to_scan&&nr_taken>=nr_to_scan" is impossible now with the units fixed.With the units fixed,
nr_takenis no longer checked.
It is because scan would be always >= nr_taken.
Quoted 27 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
page = lru_to_page(src);(quoted diff) +4
-1@@ -1657,9 +1665,12 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, VM_BUG_ON_PAGE(!PageLRU(page), page); + nr_pages = 1 << compound_order(page); + total_scan += nr_pages; + if (page_zonenum(page) > sc->reclaim_idx) { list_move(&page->lru, &pages_skipped); - nr_skipped[page_zonenum(page)]++; + nr_skipped[page_zonenum(page)] += nr_pages; continue; }@@ -1669,10 +1680,9 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,Quoted 8 lines
Review static unsigned long isolate_lru_pages(unsigned long nr_to_scan, · line 1683
Quoted 5 lines
(quoted diff) +1
-1* ineligible pages. This causes the VM to not reclaim any * pages, triggering a premature OOM. */ - scan++; + scan += nr_pages;The comment looks to defy the change if we fail to add a huge page to the dst list; otherwise
nr_takenknows how to do the right thing. What I prefer is to let scan to do one thing a time.Quoted 5 lines
I don't get your point. Do you mean the comment "Do not count skipped pages because that makes the function return with no isolated pages if the LRU mostly contains ineligible pages."? I'm supposed the comment is used to explain why not count skipped page.
Quoted 8 lines
Well consider the case where there is a huge page in the second place reversely on the src list along with other 20 regular pages, and we are not able to add the huge page to the dst list. Currently we can go on and try to scan other pages, provided
nr_to_scanis 32; with the units fixed, however, scan goes overnr_to_scan, leaving us no chance to scan any page that may be not busy. I wonder that triggers a premature OOM, because I think scan means the number of list nodes we try to isolate, andnr_takenthe number of regular pages successfully isolated.
Yes, good point. I think I just need roll back to what v3 did here to get scan accounted for each case separately to avoid the possible over-account.
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +0
-2switch (__isolate_lru_page(page, mode)) { case 0: - nr_pages = hpage_nr_pages(page); nr_taken += nr_pages; nr_zone_taken[page_zonenum(page)] += nr_pages; list_move(&page->lru, dst); --1.8.3.1
Best Regards
Hillf
Quoted 75 lines · Yang Shi
Quoted 24 lines · Hillf Danton
Quoted 23 lines · On Fri, 24 May 2019 09:27:02 +0800 Yang Shi wrote:
Quoted 10 lines · Hillf Danton
Quoted 8 lines · On Thu, 23 May 2019 10:27:38 +0800 Yang Shi wrote:
@ -1642,14 +1650,14 @@ static unsigned long isolate_lru_pages(unsigned long
nr_to_scan, unsigned long nr_zone_taken[MAX_NR_ZONES] = { 0 }; unsigned long nr_skipped[MAX_NR_ZONES] = { 0, }; unsigned long skipped = 0;
- unsigned long scan,total_scan,nr_pages;
+ unsigned long scan,total_scan;
+ unsigned longnr_pages;Change for no earn:)
Aha, yes.
Quoted 10 lines
Quoted 10 lines
LIST_HEAD(pages_skipped);
isolate_mode_tmode = (sc->may_unmap? 0 :ISOLATE_UNMAPPED); +total_scan= 0;
scan = 0;
- for (total_scan= 0;
- scan <nr_to_scan&&nr_taken<nr_to_scan&& !list_empty(src);
- total_scan++) {
+ while (scan <nr_to_scan&& !list_empty(src)) { struct page *page;Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
AFAICS scan currently prevents us from looping for ever, while
nr_takenbails us out once we get what's expected, so I doubt it makes much sense to cutnr_takenoff.It is because "scan <
nr_to_scan&&nr_taken>=nr_to_scan" is impossible now with the units fixed.With the units fixed,
nr_takenis no longer checked.It is because scan would be always >=
nr_taken.Quoted 29 lines
Quoted 24 lines
Quoted 16 lines
Quoted 16 lines
page =
lru_to_page(src);(quoted diff) +4
-1@@ -1657,9 +1665,12 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, VM_BUG_ON_PAGE(!PageLRU(page), page); + nr_pages = 1 << compound_order(page); + total_scan += nr_pages; + if (page_zonenum(page) > sc->reclaim_idx) { list_move(&page->lru, &pages_skipped); - nr_skipped[page_zonenum(page)]++; + nr_skipped[page_zonenum(page)] += nr_pages; continue; }@@ -1669,10 +1680,9 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,Quoted 8 lines
Review static unsigned long · line 1684
Quoted 5 lines
(quoted diff) +1
-1* ineligible pages. This causes the VM to not reclaim any * pages, triggering a premature OOM. */ - scan++; + scan += nr_pages;The comment looks to defy the change if we fail to add a huge page to the dst list; otherwise
nr_takenknows how to do the right thing. What I prefer is to let scan to do one thing a time.Quoted 5 lines
I don't get your point. Do you mean the comment "Do not count skipped pages because that makes the function return with no isolated pages if the LRU mostly contains ineligible pages."? I'm supposed the comment is used to explain why not count skipped page.
Quoted 8 lines
Well consider the case where there is a huge page in the second place reversely on the src list along with other 20 regular pages, and we are not able to add the huge page to the dst list. Currently we can go on and try to scan other pages, provided
nr_to_scanis 32; with the units fixed, however, scan goes overnr_to_scan, leaving us no chance to scan any page that may be not busy. I wonder that triggers a premature OOM, because I think scan means the number of list nodes we try to isolate, andnr_takenthe number of regular pages successfully isolated.
Quoted 1 line
Yes, good point. I think I just need roll back to what v3 did here to get scan accounted for each case separately to avoid the possible over-account.
By rethinking the code, I think "scan" here still should mean the number of base pages. If the case you mentioned happens, the right behavior should be to raise priority to give another round of scan.
And, vmscan uses sync isolation (mode = (sc->may_unmap ? 0 : ISOLATE_UNMAPPED)), it returns -EBUSY only when the page is freed somewhere else, so this should not cause premature OOM.
Quoted 12 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +0
-0switch (__isolate_lru_page(page, mode)) {case 0:
-nr_pages=hpage_nr_pages(page);nr_taken+=nr_pages; nr_zone_taken[page_zonenum(page)] +=nr_pages;list_move(&page->lru, dst);Signature · 1 line
1.8.3.1Best Regards
Hillf