From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76CEEC04A6B for ; Fri, 10 May 2019 15:41:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 470F12175B for ; Fri, 10 May 2019 15:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727650AbfEJPlt (ORCPT ); Fri, 10 May 2019 11:41:49 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:59099 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727510AbfEJPlt (ORCPT ); Fri, 10 May 2019 11:41:49 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R891e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0TRM5wdz_1557502897; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TRM5wdz_1557502897) by smtp.aliyun-inc.com(127.0.0.1); Fri, 10 May 2019 23:41:39 +0800 Subject: Re: [PATCH] mm: vmscan: correct nr_reclaimed for THP To: "Huang, Ying" Cc: hannes@cmpxchg.org, mhocko@suse.com, mgorman@techsingularity.net, kirill.shutemov@linux.intel.com, hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1557447392-61607-1-git-send-email-yang.shi@linux.alibaba.com> <87y33fjbvr.fsf@yhuang-dev.intel.com> <1fb73973-f409-1411-423b-c48895d3dde8@linux.alibaba.com> <87tve3j9jf.fsf@yhuang-dev.intel.com> From: Yang Shi Message-ID: Date: Fri, 10 May 2019 08:41:34 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <87tve3j9jf.fsf@yhuang-dev.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/9/19 8:03 PM, Huang, Ying wrote: > Yang Shi writes: > >> On 5/9/19 7:12 PM, Huang, Ying wrote: >>> Yang Shi writes: >>> >>>> Since commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after >>>> swapped out"), THP can be swapped out in a whole. But, nr_reclaimed >>>> still gets inc'ed by one even though a whole THP (512 pages) gets >>>> swapped out. >>>> >>>> This doesn't make too much sense to memory reclaim. For example, direct >>>> reclaim may just need reclaim SWAP_CLUSTER_MAX pages, reclaiming one THP >>>> could fulfill it. But, if nr_reclaimed is not increased correctly, >>>> direct reclaim may just waste time to reclaim more pages, >>>> SWAP_CLUSTER_MAX * 512 pages in worst case. >>>> >>>> This change may result in more reclaimed pages than scanned pages showed >>>> by /proc/vmstat since scanning one head page would reclaim 512 base pages. >>>> >>>> Cc: "Huang, Ying" >>>> Cc: Johannes Weiner >>>> Cc: Michal Hocko >>>> Cc: Mel Gorman >>>> Cc: "Kirill A . Shutemov" >>>> Cc: Hugh Dickins >>>> Signed-off-by: Yang Shi >>>> --- >>>> I'm not quite sure if it was the intended behavior or just omission. I tried >>>> to dig into the review history, but didn't find any clue. I may miss some >>>> discussion. >>>> >>>> mm/vmscan.c | 6 +++++- >>>> 1 file changed, 5 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/mm/vmscan.c b/mm/vmscan.c >>>> index fd9de50..7e026ec 100644 >>>> --- a/mm/vmscan.c >>>> +++ b/mm/vmscan.c >>>> @@ -1446,7 +1446,11 @@ static unsigned long shrink_page_list(struct list_head *page_list, >>>> unlock_page(page); >>>> free_it: >>>> - nr_reclaimed++; >>>> + /* >>>> + * THP may get swapped out in a whole, need account >>>> + * all base pages. >>>> + */ >>>> + nr_reclaimed += (1 << compound_order(page)); >>>> /* >>>> * Is there need to periodically free_page_list? It would >>> Good catch! Thanks! >>> >>> How about to change this to >>> >>> >>> nr_reclaimed += hpage_nr_pages(page); >> Either is fine to me. Is this faster than "1 << compound_order(page)"? > I think the readability is a little better. And this will become > > nr_reclaimed += 1 > > if CONFIG_TRANSPARENT_HUAGEPAGE is disabled. Good point. Will update in v2 soon. > > Best Regards, > Huang, Ying > >>> Best Regards, >>> Huang, Ying