Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1025065ybb; Wed, 8 Apr 2020 14:55:43 -0700 (PDT) X-Google-Smtp-Source: APiQypLw2K51AVrq+1cWCIXlv+YbnxoGWu0q39KGd62riaeuP/Y9nJaMDIbnzS+9QhvUVuHyx0uW X-Received: by 2002:aca:598a:: with SMTP id n132mr1469882oib.111.1586382943248; Wed, 08 Apr 2020 14:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586382943; cv=none; d=google.com; s=arc-20160816; b=eva6jssRRnRxQJBozYmg66jaeB4jt7U8I9PJAwMp7BVupil03UVz5uR+ikeOZqNXhK YY8vrwuTkmLcKv/MIA/UNLb3djZguDHOxGFXvjwOcCbW4W8hugypR5Zbfvggt1m98zto Vh1iow4drqJuu89+W6ghsfPCdcAsrH2PZqfD+3eCeq9Sqd8eVnpPcIiJNuBdoWM5O8yz 9HfxQ9b9mVMsdCI/AF205geB9cGq7yrmnR4M6xiRw/cvtcfNDozU+FBfIQ2DIAmr6e4Q BJQgW9BrVG0/T2LgHewkPZpileVLDTdpFHfbX40JeBFG/lef8EHDux2Tg69q7QW71SlS 8pmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ow+d8Keh+B0j+dqogF8+BzDxhf+aARU2zrjfBkFvbRw=; b=Ou5wubJ8zbHrEX2+ryAB8mM/7kuJb6O7gQaG6hg6CeU2aaHXobHmMUgz2y/DLmdbu5 g9bN9abDCYFmN68QEjSCHRF8Uo758WvTw1suKz5ENuiFKXfnhPFx8n/TZ3+q0DvN+x3m as2pBuGYtZmE574gqcAbKiMY3YyJWaKUHrL9aFCz2YTwauTjilV0WYYYZfOlNBJq9klg hxvrhXCT+piVXJ/x1/LItkk9bAjXbYVlUUv+OSYGczkTC8QdbjqSNrvdzkbYoXhJSPOA iLsFwCrBvTn5ZfUCdMAvC8vpQz6QbTyhnH35LWZol/PRI3BQMtzXv6D51mTIIBHFfSDO 9/oA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l24si3258112otn.57.2020.04.08.14.55.31; Wed, 08 Apr 2020 14:55:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729143AbgDHSnE (ORCPT + 99 others); Wed, 8 Apr 2020 14:43:04 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:41845 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgDHSnE (ORCPT ); Wed, 8 Apr 2020 14:43:04 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Tv.3hCG_1586371377; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0Tv.3hCG_1586371377) by smtp.aliyun-inc.com(127.0.0.1); Thu, 09 Apr 2020 02:43:00 +0800 Subject: Re: [PATCHv2 4/8] khugepaged: Drain LRU add pagevec after swapin To: "Kirill A. Shutemov" Cc: akpm@linux-foundation.org, Andrea Arcangeli , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" References: <20200403112928.19742-1-kirill.shutemov@linux.intel.com> <20200403112928.19742-5-kirill.shutemov@linux.intel.com> <620a61ed-be87-f60e-f562-379cd3adbe08@linux.alibaba.com> <20200408130532.ktztqf5fabo3x3cd@box> From: Yang Shi Message-ID: <4b63e949-16bc-f239-89ec-93898cb4d772@linux.alibaba.com> Date: Wed, 8 Apr 2020 11:42:55 -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: <20200408130532.ktztqf5fabo3x3cd@box> Content-Type: text/plain; charset=utf-8; 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 4/8/20 6:05 AM, Kirill A. Shutemov wrote: > On Mon, Apr 06, 2020 at 11:29:11AM -0700, Yang Shi wrote: >> >> On 4/3/20 4:29 AM, Kirill A. Shutemov wrote: >>> __collapse_huge_page_isolate() may fail due to extra pin in the LRU add >>> pagevec. It's petty common for swapin case: we swap in pages just to >>> fail due to the extra pin. >>> >>> Drain LRU add pagevec on sucessfull swapin. >>> >>> Signed-off-by: Kirill A. Shutemov >>> --- >>> mm/khugepaged.c | 5 +++++ >>> 1 file changed, 5 insertions(+) >>> >>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c >>> index fdc10ffde1ca..57ff287caf6b 100644 >>> --- a/mm/khugepaged.c >>> +++ b/mm/khugepaged.c >>> @@ -940,6 +940,11 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm, >>> } >>> vmf.pte--; >>> pte_unmap(vmf.pte); >>> + >>> + /* Drain LRU add pagevec to remove extra pin on the swapped in pages */ >>> + if (swapped_in) >>> + lru_add_drain(); >> There is already lru_add_drain() called in swap readahead path, please see >> swap_vma_readahead() and swap_cluster_readahead(). > But not for synchronous case. See SWP_SYNCHRONOUS_IO branch in > do_swap_page(). Aha, yes. I missed the synchronous case. > > Maybe we should drain it in swap_readpage() or in do_swap_page() after > swap_readpage()? I donno. It may be better to keep it as is. Draining lru for every page for synchronous case in do_swap_page() path sounds not very productive. Doing it in khugepaged seems acceptable. We just drain lru cache again for non-synchronous case, but the cache may be already empty so it should take very short time since nothing to drain. >