Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp12584pxk; Wed, 23 Sep 2020 20:32:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpQ3f+hjMh4aw187QN9Rs8SHiNm0WBNST1lJc4YsSKMCwqvpYn9e1sylhYhkUekCkLm3Z5 X-Received: by 2002:a50:9fa1:: with SMTP id c30mr2369795edf.207.1600918352882; Wed, 23 Sep 2020 20:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600918352; cv=none; d=google.com; s=arc-20160816; b=v7jeflIodIDvKEYMAch0u6688ks/4lOJrLFWKNn27qdY0R3IwcsYiRWE9wiFH3SXzg mF/Q0gYY1tP0HPw07nB1yC2YptH55RlI21QDFmJz6sdqdE8OTg1t0VtxxgLRnX1pOLJL 4X/jZqMqx6dSJCrBnmyBW03b3cxqtViFKOwl4952t7no7zLrypSF/Jl7IGL6aHyiv9wO hXlT2Cdk+3lQ4tviaVDLgErXlbI6v6yz/7yXHPiRqfp4NRxGatKOi1m2lHKZbc2okY5Z ZTiRBtx60DA8R0zlnjTuIe3mdShYRQLw6pqc82k7ME03dAwzHgeyX+FlwyC7u+nHVmIR a3+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :to:from; bh=4I9+gHi7v+NS2nDaky965mV05Mxdr0GvOOQF/NrE610=; b=WwiLnRP6HoR0pN1BN40ugrrmFcF+1KpvW7nuPpm/cXFaql+ouVw+6hkLDpksv5VU6k +Mnw37eG2m4Em0SzWVRNSl0PPh9Q9eorJN/95R/tP4tW1F5Z+giY4hKTw7UrEA8rxlNf RVP3SBkkhlW3ttmyJcoC/W0DbiE6N9UijnQWAv3CCbYnd/VkTn9aQzR1cd/R/xrhETgA 2bGivoTMWEC0vE6dRaGzo2NnnXCi2k1jDxi1hgC2hDIDrXsCZTs2oKD7tO3KNAlAxl0z IJU/2svmYhfiJsb6FZZ1Y8MADXKZ2vaw7gL0zAwo093NEXGNTFJt744SSp7Lr99MtoRx S43A== 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 x26si1238130edi.79.2020.09.23.20.32.10; Wed, 23 Sep 2020 20:32:32 -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 S1727179AbgIXD3D (ORCPT + 99 others); Wed, 23 Sep 2020 23:29:03 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:60477 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726732AbgIXD2o (ORCPT ); Wed, 23 Sep 2020 23:28:44 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R471e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=22;SR=0;TI=SMTPD_---0U9w0Ss1_1600918116; Received: from aliy80.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U9w0Ss1_1600918116) by smtp.aliyun-inc.com(127.0.0.1); Thu, 24 Sep 2020 11:28:38 +0800 From: Alex Shi To: akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, hannes@cmpxchg.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com, aaron.lwe@gmail.com Subject: [PATCH v19 03/20] mm/thp: move lru_add_page_tail func to huge_memory.c Date: Thu, 24 Sep 2020 11:28:18 +0800 Message-Id: <1600918115-22007-4-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1600918115-22007-1-git-send-email-alex.shi@linux.alibaba.com> References: <1600918115-22007-1-git-send-email-alex.shi@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The func is only used in huge_memory.c, defining it in other file with a CONFIG_TRANSPARENT_HUGEPAGE macro restrict just looks weird. Let's move it THP. And make it static as Hugh Dickin suggested. Signed-off-by: Alex Shi Reviewed-by: Kirill A. Shutemov Acked-by: Hugh Dickins Cc: Andrew Morton Cc: Johannes Weiner Cc: Matthew Wilcox Cc: Hugh Dickins Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- include/linux/swap.h | 2 -- mm/huge_memory.c | 30 ++++++++++++++++++++++++++++++ mm/swap.c | 33 --------------------------------- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 661046994db4..43e6b3458f58 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -338,8 +338,6 @@ extern void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages); extern void lru_note_cost_page(struct page *); extern void lru_cache_add(struct page *); -extern void lru_add_page_tail(struct page *page, struct page *page_tail, - struct lruvec *lruvec, struct list_head *head); extern void activate_page(struct page *); extern void mark_page_accessed(struct page *); extern void lru_add_drain(void); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index faadc449cca5..211d50f09785 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2318,6 +2318,36 @@ static void remap_page(struct page *page) } } +static void lru_add_page_tail(struct page *page, struct page *page_tail, + struct lruvec *lruvec, struct list_head *list) +{ + VM_BUG_ON_PAGE(!PageHead(page), page); + VM_BUG_ON_PAGE(PageCompound(page_tail), page); + VM_BUG_ON_PAGE(PageLRU(page_tail), page); + lockdep_assert_held(&lruvec_pgdat(lruvec)->lru_lock); + + if (!list) + SetPageLRU(page_tail); + + if (likely(PageLRU(page))) + list_add_tail(&page_tail->lru, &page->lru); + else if (list) { + /* page reclaim is reclaiming a huge page */ + get_page(page_tail); + list_add_tail(&page_tail->lru, list); + } else { + /* + * Head page has not yet been counted, as an hpage, + * so we must account for each subpage individually. + * + * Put page_tail on the list at the correct position + * so they all end up in order. + */ + add_page_to_lru_list_tail(page_tail, lruvec, + page_lru(page_tail)); + } +} + static void __split_huge_page_tail(struct page *head, int tail, struct lruvec *lruvec, struct list_head *list) { diff --git a/mm/swap.c b/mm/swap.c index e7bdf094f76a..1bc2fc5d8b7c 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -935,39 +935,6 @@ void __pagevec_release(struct pagevec *pvec) } EXPORT_SYMBOL(__pagevec_release); -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -/* used by __split_huge_page_refcount() */ -void lru_add_page_tail(struct page *page, struct page *page_tail, - struct lruvec *lruvec, struct list_head *list) -{ - VM_BUG_ON_PAGE(!PageHead(page), page); - VM_BUG_ON_PAGE(PageCompound(page_tail), page); - VM_BUG_ON_PAGE(PageLRU(page_tail), page); - lockdep_assert_held(&lruvec_pgdat(lruvec)->lru_lock); - - if (!list) - SetPageLRU(page_tail); - - if (likely(PageLRU(page))) - list_add_tail(&page_tail->lru, &page->lru); - else if (list) { - /* page reclaim is reclaiming a huge page */ - get_page(page_tail); - list_add_tail(&page_tail->lru, list); - } else { - /* - * Head page has not yet been counted, as an hpage, - * so we must account for each subpage individually. - * - * Put page_tail on the list at the correct position - * so they all end up in order. - */ - add_page_to_lru_list_tail(page_tail, lruvec, - page_lru(page_tail)); - } -} -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ - static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, void *arg) { -- 1.8.3.1