Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753409AbbHCOzu (ORCPT ); Mon, 3 Aug 2015 10:55:50 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:36688 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752403AbbHCOzs (ORCPT ); Mon, 3 Aug 2015 10:55:48 -0400 MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 X-AuditID: cbfee690-f796f6d000005054-65-55bf80f2dea1 Content-transfer-encoding: 8BIT Message-id: <55BF80F2.2020602@samsung.com> Date: Mon, 03 Aug 2015 23:55:46 +0900 From: Jaewon Kim User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 To: Minchan Kim Cc: akpm@linux-foundation.org, mgorman@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com Subject: Re: [PATCH] vmscan: reclaim_clean_pages_from_list() must count mlocked pages References: <1438597107-18329-1-git-send-email-jaewon31.kim@samsung.com> <20150803122509.GA29929@bgram> In-reply-to: <20150803122509.GA29929@bgram> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRmVeSWpSXmKPExsVy+t8zTd1PDftDDdat17CYs34Nm0X35pmM Fpd3zWGzuLfmP6vF5HfPGC2WfX3P7sDmsXPWXXaPTas62Tw2fZrE7nFixm8Wj82nqz0+b5IL YIvisklJzcksSy3St0vgyjhx8xpjwTHZii3/37I0MF4S72Lk5JAQMJFYNOM7G4QtJnHh3nog m4tDSGAlo8S61z+Yuhg5wIp+vNOEiM9ilLhz+Tw7SAOvgKDEj8n3WEBqmAXkJY5cygYJMwuo S0yat4gZov4+o8TLrq1sEPVaEgt/7ASzWQRUJX7O2MkMYrMJaEu8XzCJFcQWFYiQ+LDqK1iN iICKxJ+n/xghhlZJfLqwFaxGWCBc4uXKNlaQvUICmRJXH8aDhDmBxjS/PMIOsldC4BK7xLyH LV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Oi9icxS osn5wHSTVxJvaGxiZmRpZGZsYm5srCTOK7thc6iQQHpiSWp2ampBahFMHxMHp1QDI5+QR3WY YfXeP4LT83/yvXw591ahKC9zy75w1pQY58uyqiuWtPLPeRfR6HLK0kTH8fNOh5O711w6PCWk U2B9PMOfs2e+flaYfSKhJu6awIuPr7LX3U9xa+JO6pkXrTnBNv//mpsbTBwU7l2I5NFRXp5Q 7tpXIJA53/LD0dW+KkndkwX9XYI/KLEUZyQaajEXFScCAHujtoT/AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3927 Lines: 109 On 2015년 08월 03일 21:27, Minchan Kim wrote: > Hello, > > On Mon, Aug 03, 2015 at 07:18:27PM +0900, Jaewon Kim wrote: >> reclaim_clean_pages_from_list() decreases NR_ISOLATED_FILE by returned >> value from shrink_page_list(). But mlocked pages in the isolated >> clean_pages page list would be removed from the list but not counted as >> nr_reclaimed. Fix this miscounting by returning the number of mlocked >> pages and count it. > > If there are pages not able to reclaim, VM try to migrate it and > have to handle the stat in migrate_pages. > If migrate_pages fails again, putback-fiends should handle it. > > Is there anyting I am missing now? > > Thanks. > Hello Only pages in cc->migratepages will be handled by migrate_pages or putback_movable_pages, and NR_ISOLATED_FILE will be counted properly. However mlocked pages will not be put back into cc->migratepages, and also not be counted in NR_ISOLATED_FILE because putback_lru_page in shrink_page_list does not increase NR_ISOLATED_FILE. The current reclaim_clean_pages_from_list assumes that shrink_page_list returns number of pages removed from the candidate list. i.e) isolate_migratepages_range : NR_ISOLATED_FILE += 10 reclaim_clean_pages_from_list : NR_ISOLATED_FILE -= 5 (1 mlocked page) migrate_pages : NR_ISOLATED_FILE -=4 => NR_ISOLATED_FILE increased by 1 Thank you. >> >> Signed-off-by: Jaewon Kim >> --- >> mm/vmscan.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index 5e8eadd..5837695 100644 >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -849,6 +849,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, >> unsigned long *ret_nr_congested, >> unsigned long *ret_nr_writeback, >> unsigned long *ret_nr_immediate, >> + unsigned long *ret_nr_mlocked, >> bool force_reclaim) >> { >> LIST_HEAD(ret_pages); >> @@ -1158,6 +1159,7 @@ cull_mlocked: >> try_to_free_swap(page); >> unlock_page(page); >> putback_lru_page(page); >> + (*ret_nr_mlocked)++; >> continue; >> >> activate_locked: >> @@ -1197,6 +1199,7 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, >> .may_unmap = 1, >> }; >> unsigned long ret, dummy1, dummy2, dummy3, dummy4, dummy5; >> + unsigned long nr_mlocked = 0; >> struct page *page, *next; >> LIST_HEAD(clean_pages); >> >> @@ -1210,8 +1213,10 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, >> >> ret = shrink_page_list(&clean_pages, zone, &sc, >> TTU_UNMAP|TTU_IGNORE_ACCESS, >> - &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, true); >> + &dummy1, &dummy2, &dummy3, &dummy4, &dummy5, >> + &nr_mlocked, true); >> list_splice(&clean_pages, page_list); >> + ret += nr_mlocked; >> mod_zone_page_state(zone, NR_ISOLATED_FILE, -ret); >> return ret; >> } >> @@ -1523,6 +1528,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, >> unsigned long nr_unqueued_dirty = 0; >> unsigned long nr_writeback = 0; >> unsigned long nr_immediate = 0; >> + unsigned long nr_mlocked = 0; >> isolate_mode_t isolate_mode = 0; >> int file = is_file_lru(lru); >> struct zone *zone = lruvec_zone(lruvec); >> @@ -1565,7 +1571,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, >> >> nr_reclaimed = shrink_page_list(&page_list, zone, sc, TTU_UNMAP, >> &nr_dirty, &nr_unqueued_dirty, &nr_congested, >> - &nr_writeback, &nr_immediate, >> + &nr_writeback, &nr_immediate, &nr_mlocked, >> false); >> >> spin_lock_irq(&zone->lru_lock); >> -- >> 1.9.1 >> > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/