Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1820720ybb; Thu, 9 Apr 2020 09:36:30 -0700 (PDT) X-Google-Smtp-Source: APiQypIrrTvZCACACzLQukTBqGnN44LCQSYiN9QbdJupoXpb7XlWGJZ1ZdVVX4jbEC/fRHMG9Nay X-Received: by 2002:a37:54e:: with SMTP id 75mr713870qkf.257.1586450190061; Thu, 09 Apr 2020 09:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586450190; cv=none; d=google.com; s=arc-20160816; b=F0P/kno1wlTfA85yE3NoStwH8+7q0zKXOfbIELJ+Axo6FRqbkd675syusf4tUKS1qX ptQ3Ax+ERio+SApvTHtUqbEijtxkCJvfQCacWbWEI8f04hMW9wQpcvBHHzZY0YalseBp TQ+0CGFZ3/kODbM/pVJzPP58VZNLww/RpzAcF6r1EzYSjE4vXIYuFlvbDgDcPBJJMoDF 3Wg8utbKZ5YXtHiDU3ZxyfFVqdouo29mlozQTnPVzVFFsjaF9P7Gp2piZVUeqIPHGAVt 8rvvK1Q5pI0zfvCJhvLeRcNg11CNplZZzeM8OIZj9zyx+7MnxnZUMi2FGw1CNqFPUyph vSgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8Vgk6oCSYvrjAGKLtGVWWkRAQatuTUuM8JMEQf5SJx8=; b=AajcSE71VrwJGqfD9uN/erjkdrUoXkTQ9JA5x6tWtOoJliFdaBgdB2/d8wovwMHO10 pHckB2SfA5LBWxmhBTzYLbeUr1fJMAM1k+iOucL4cT7w5go4iN3lKfMNqComBrorIbDq s9NM2AwChjZfkrW+NY3atDh9iHzuAE8HQ+GSpVVhXpOXC/P+zayRv+BfIK71qUsV9Acz ATwaj//B8BAjza/jk9QmYD9QIAjN8CYT5Vj3RPJL5QOqC6U+y5sjpSyHuANWML97FoZV a/JiQut9I8Q7pXO4R93Mb4DFAGfxKbOSlAQS9kEI51NBVfPqz6JeH5bf8PRBakxsJukI yXDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=TLYqu91y; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si5524063qtr.324.2020.04.09.09.36.13; Thu, 09 Apr 2020 09:36:30 -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; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=TLYqu91y; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbgDINeS (ORCPT + 99 others); Thu, 9 Apr 2020 09:34:18 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36305 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgDINeS (ORCPT ); Thu, 9 Apr 2020 09:34:18 -0400 Received: by mail-lj1-f193.google.com with SMTP id b1so11493630ljp.3 for ; Thu, 09 Apr 2020 06:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8Vgk6oCSYvrjAGKLtGVWWkRAQatuTUuM8JMEQf5SJx8=; b=TLYqu91yttSM47tfXSXCvp8mRTc65L/D8DOJUGMEQnu1y8K0MpMsczORR6nAwU3JDJ A5hT+JM9h2BJ947I3czDycOfQG+bLBbBhOR0sZvzLUimmsq1hW51Hi1FASkh0WhziVg+ L07IgEmyAepQsUmc5cF2srADXQuzWXx4d3T5FdxTCRb7TUBmcn7EPgc03P+gXiG3kaht NBQ3NN9rrA97R6v/X1zodcJ/MReRg8vkVBisOufvjDXmj3b+RFdDkT+Ztx747MMl+40F GaTIns4U387kUaH0PRNFMdKpkta/8YdDFaybmqi9p10ejiExU5S73xG4onS/L5MT43+2 0kTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8Vgk6oCSYvrjAGKLtGVWWkRAQatuTUuM8JMEQf5SJx8=; b=AqKTqW/U3b7CWcCuKBz27UaxmEIp1rnCfcOdMfGuIp1f+u47fFeV7eLpz682WR8S3E sh9RDussEJXjiO+/ldisSWsX36xNhO+APJaQUXFAte4GioXCsWw3VtE8XjQpHOilJTDY l1SPLJGCyquOB64de5GmBKsjkAwSZH7/AvdOb+7oKggs2Z95HnTmrkG7m8XWthWGviur SuZT0n64mFVIfOnRCdpKV0y+tHlPM7PWh/1sBpCDOfevdRxOVh4i/slIEUiTLtflpzR6 D0+1XSKoC7N5h8UTJXVcvc/2erdW3w67PwZ+C5WH//+KhiaA7m63S0QzsrrijzEsBlIs I3jA== X-Gm-Message-State: AGi0PuZxg3dvBSbIJKcsmyvvyaiW6KBh0NEOjKN7wBXINoGSTWepTxIi unNMvCh6bpI4G7TqwJ18kvWCjg== X-Received: by 2002:a2e:909a:: with SMTP id l26mr5767532ljg.177.1586439256849; Thu, 09 Apr 2020 06:34:16 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id s8sm1717523lfd.61.2020.04.09.06.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 06:34:15 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id DAB8F102132; Thu, 9 Apr 2020 16:34:14 +0300 (+03) Date: Thu, 9 Apr 2020 16:34:14 +0300 From: "Kirill A. Shutemov" To: Ralph Campbell Cc: akpm@linux-foundation.org, Andrea Arcangeli , Zi Yan , Yang Shi , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: Re: [PATCHv2 2/8] khugepaged: Do not stop collapse if less than half PTEs are referenced Message-ID: <20200409133414.hcynyxggt24nitd5@box> References: <20200403112928.19742-1-kirill.shutemov@linux.intel.com> <20200403112928.19742-3-kirill.shutemov@linux.intel.com> <7d3af6a4-b0ee-9497-da0b-b93e050c5a4c@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7d3af6a4-b0ee-9497-da0b-b93e050c5a4c@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 06, 2020 at 12:53:00PM -0700, Ralph Campbell wrote: > > On 4/3/20 4:29 AM, Kirill A. Shutemov wrote: > > __collapse_huge_page_swapin() check number of referenced PTE to decide > > if the memory range is hot enough to justify swapin. > > > > The problem is that it stops collapse altogether if there's not enough > > referenced pages, not only swappingin. > > > > Signed-off-by: Kirill A. Shutemov > > Fixes: 0db501f7a34c ("mm, thp: convert from optimistic swapin collapsing to conservative") > > Reviewed-by: Zi Yan --- > > mm/khugepaged.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index 99bab7e4d05b..14d7afc90786 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -905,7 +905,8 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm, > > /* we only decide to swapin, if there is enough young ptes */ > > if (referenced < HPAGE_PMD_NR/2) { > > trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0); > > The trace point is recording the return value. Shouldn't you s/0/1 to match? Good catch. > > > - return false; > > + /* Do not block collapse, only skip swapping in */ > > + return true; > > } > > vmf.pte = pte_offset_map(pmd, address); > > for (; vmf.address < address + HPAGE_PMD_NR*PAGE_SIZE; > > > > So "referenced < HPAGE_PMD_NR/2" means swapped out pages aren't faulted back in > but there could still be no swapped out pages, just "old" pages so collapse could > succeed. Seems like this check could have been made in khugepaged_scan_pmd() when > "referenced" is being computed and "unmapped" is available. Just skip setting > "ret = 1" if unmapped > 0 && referenced < HPAGE_PMD_NR/2. Good point. I'll change the code to address it. -- Kirill A. Shutemov