From patchwork Wed Apr 29 22:56:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11518931 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C48A0912 for ; Wed, 29 Apr 2020 22:56:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9BD8D2176D for ; Wed, 29 Apr 2020 22:56:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BD8D2176D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D602F8E0006; Wed, 29 Apr 2020 18:56:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D37D38E0001; Wed, 29 Apr 2020 18:56:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4CD18E0006; Wed, 29 Apr 2020 18:56:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0219.hostedemail.com [216.40.44.219]) by kanga.kvack.org (Postfix) with ESMTP id B17178E0001 for ; Wed, 29 Apr 2020 18:56:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7B9AA181AC9C6 for ; Wed, 29 Apr 2020 22:56:42 +0000 (UTC) X-FDA: 76762403844.10.north44_3e64ed8d708 X-Spam-Summary: 2,0,0,7cc8d4879dec2ece,d41d8cd98f00b204,yang.shi@linux.alibaba.com,,RULES_HIT:41:355:379:541:800:960:965:966:973:988:989:1260:1261:1345:1359:1431:1437:1534:1541:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3871:3872:3874:4321:4385:4390:4395:5007:6261:7903:8957:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:13069:13255:13311:13357:14096:14181:14384:14721:21060:21080:21451:21627:21795:21987:30051:30054,0,RBL:115.124.30.130:@linux.alibaba.com:.lbl8.mailshell.net-62.20.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: north44_3e64ed8d708 X-Filterd-Recvd-Size: 3216 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Apr 2020 22:56:41 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Tx2rN9y_1588200990; Received: from localhost(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0Tx2rN9y_1588200990) by smtp.aliyun-inc.com(127.0.0.1); Thu, 30 Apr 2020 06:56:38 +0800 From: Yang Shi To: kirill.shutemov@linux.intel.com, hughd@google.com, aarcange@redhat.com, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [linux-next PATCH 2/2] mm: khugepaged: don't have to put being freed page back to lru Date: Thu, 30 Apr 2020 06:56:22 +0800 Message-Id: <1588200982-69492-2-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1588200982-69492-1-git-send-email-yang.shi@linux.alibaba.com> References: <1588200982-69492-1-git-send-email-yang.shi@linux.alibaba.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When khugepaged successfully isolated and copied data from base page to collapsed THP, the base page is about to be freed. So putting the page back to lru sounds not that productive since the page might be isolated by vmscan but it can't be reclaimed by vmscan since it can't be unmapped by try_to_unmap() at all. Actually khugepaged is the last user of this page so it can be freed directly. So, clearing active and unevictable flags, unlocking and dropping refcount from isolate instead of calling putback_lru_page(). Cc: Kirill A. Shutemov Cc: Hugh Dickins Cc: Andrea Arcangeli Signed-off-by: Yang Shi --- mm/khugepaged.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 0c8d30b..c131a90 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -559,6 +559,17 @@ void __khugepaged_exit(struct mm_struct *mm) static void release_pte_page(struct page *page) { mod_node_page_state(page_pgdat(page), + NR_ISOLATED_ANON + page_is_file_lru(page), -compound_nr(page)); + ClearPageActive(page); + ClearPageUnevictable(page); + unlock_page(page); + /* Drop refcount from isolate */ + put_page(page); +} + +static void release_pte_page_to_lru(struct page *page) +{ + mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + page_is_file_lru(page), -compound_nr(page)); unlock_page(page); @@ -576,12 +587,12 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte, page = pte_page(pteval); if (!pte_none(pteval) && !is_zero_pfn(pte_pfn(pteval)) && !PageCompound(page)) - release_pte_page(page); + release_pte_page_to_lru(page); } list_for_each_entry_safe(page, tmp, compound_pagelist, lru) { list_del(&page->lru); - release_pte_page(page); + release_pte_page_to_lru(page); } }