Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1147486ybz; Wed, 29 Apr 2020 15:59:55 -0700 (PDT) X-Google-Smtp-Source: APiQypKHgTHlc2Gt7AYpuZMiVdKDSaUhFt8jeqR9hv6GX+XSMxNIXLQSnkocgzuESFSHloOVYw4x X-Received: by 2002:a05:6402:8ca:: with SMTP id d10mr252499edz.167.1588201195165; Wed, 29 Apr 2020 15:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588201195; cv=none; d=google.com; s=arc-20160816; b=Xpi7HeNkdnDuhZndnoa8qwLRGTwi/jTFN4ZB+7Wnyv3PVOXHL1j/whxNJCgyCOK5/h QJGdVrvNOxcDYfoSA2AFtFjLPeG1VxXsh1TXtFE8/tuqCq9tONABPutIuyKWEl3KoP0F 0h4NTgbrZQ72OYTwEoCub+wc8tqx+dcyDnIhFHlKUOTzJdRnYWh3UwvLNNN6m567T+iP 7BujS/ceQHEc+bABjdk/ywtYhzlpblw9Bs/AgK42CP5RMYsBHXMfaNbn2tyEqljV/PzF c2w8S1baFb1RYFaE9wNTUODP6lQuDALa2BfUvvKF3TUcL5KQq49XKEjEOGt9zG4LZvgG B0Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7JboQPbd9oIsQBQwjsOFYsYHeLKlpshD8N3Lsw0ynm8=; b=TFr+l67o4bOjztw3Ir1gMhe3melR/W2dQMqRog7A1xOzcFSyapf8jlhOi5yP/YYepc GUAjm7F/unst146jktQk4mmr9mJs0TYIgmDpCEpzLKuHO5iwBYgHL+TI6+b0rSvQSbf5 4Oz+MU/zFdXtLMii6Fd58PJpj1Uu6xAoa1DdAXOEawZsyezcmSILfZNxtu2jLyKNZxOo 2+cc6LGjp1i2hnKmehOWZoNjei/7ZAbgpt3AqDG4k/d+oOBKKWmc+x1oXX/CyBc+ComQ 8M9emz3d0CVABgrlDdl3adMV7d4U2HRPRVqA+BCwSbRDhvHzNkuM/8CnGW4zcnZ1/r+z jG9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id rh26si4675318ejb.81.2020.04.29.15.59.32; Wed, 29 Apr 2020 15:59:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727119AbgD2W4l (ORCPT + 99 others); Wed, 29 Apr 2020 18:56:41 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:47949 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726164AbgD2W4l (ORCPT ); Wed, 29 Apr 2020 18:56:41 -0400 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } } -- 1.8.3.1