Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1639832pxk; Fri, 25 Sep 2020 23:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8H1mvvfJ3/FgOv8hHxAntS3gYVfjDmJ4kd1KBCydiP/cQMHB5Fnb2eYZQvs5FaC/DGGNa X-Received: by 2002:a17:906:cc8d:: with SMTP id oq13mr6042130ejb.280.1601100819413; Fri, 25 Sep 2020 23:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601100819; cv=none; d=google.com; s=arc-20160816; b=E+tkCsYdqZPiDUKiscZUjllts/w0bJLcMKXfMN2i/WJMxL2bLDutIrH6fhr8l2ezPu kNsi6OGFJRHdhwIwRXZObXeqajX3oS+AnvLRy7iJrKr/4gNzw57aQYx5LXIXPHFq7785 4YAuZGgpaD9e2+Ejj6iSiMhYQ8VxbcJwFmaMz0vEytsKVrWklFHJc1Xhmxpu/SgVSTgt ld8tJzKoz7eMMEzQ7ethLx2ReMW60uCP1XYNYfsSBxD9LNjYyjZUmGTWc2CUmOfUV78X OlgdAEPAVWkc2S62RGVC3LToAxhDzyZ4S7evDdV6GsQhXidswoFYweslbvCSJEvKW+Mg KGvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:to:from:subject; bh=rfmsclvm28khn6rTmtI2xDOq0cccwofwafhbMkH70us=; b=djvaMi4rn5YEPyWTekBARYRZ2cMCT6RG7IoR+/zmuB6rRbaBGjRgwSkhbNR1R76BbD FOTRkEKmMHhQi2z5waTI6/74rjYjLOV3X39OXlY//5f1Qk8A2CJLGArzhxEmxFCGLKLm 2Zr7+WqHEj4t7O2DURdbqTG62AAVInh4OC1mZlJET5j9gdR37gbHedy6kGhbz7/xDn+8 bhMeuXvA8EGAhZ7lzejCHUrMkd5+VWpZE65tb+hhCCpBKn0VxdrbLwhzIdLJg+UA39sJ YeeCfFkVZcO2/FsZTy63TWjSw0pWwDoOhnEYAcUAqc66h60tL4YUDgMGDZNglvDCQTZe McxA== 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 j33si3515505edc.537.2020.09.25.23.12.49; Fri, 25 Sep 2020 23:13:39 -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 S1726587AbgIZGJC (ORCPT + 99 others); Sat, 26 Sep 2020 02:09:02 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:49725 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbgIZGJB (ORCPT ); Sat, 26 Sep 2020 02:09:01 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R651e4;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_---0UA5m6jr_1601100506; Received: from IT-FVFX43SYHV2H.lan(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0UA5m6jr_1601100506) by smtp.aliyun-inc.com(127.0.0.1); Sat, 26 Sep 2020 14:08:27 +0800 Subject: Re: [PATCH v19 03/20] mm/thp: move lru_add_page_tail func to huge_memory.c 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 References: <1600918115-22007-1-git-send-email-alex.shi@linux.alibaba.com> <1600918115-22007-4-git-send-email-alex.shi@linux.alibaba.com> Message-ID: <539cb371-faac-12b2-06d2-a050a541382d@linux.alibaba.com> Date: Sat, 26 Sep 2020 14:06:05 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1600918115-22007-4-git-send-email-alex.shi@linux.alibaba.com> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a bit conflict when I try to rebase it to today's akpm branch So update a rebasable one. Thanks Alex From 3aa78f872deac10861aba86ddf362082afef947d Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Tue, 26 May 2020 16:45:09 +0800 Subject: [PATCH v19 03/20] mm/thp: move lru_add_page_tail func to huge_memory.c 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 667935c0dbd4..5e1e967c225f 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 mark_page_accessed(struct page *); extern void lru_add_drain(void); extern void lru_add_drain_cpu(int cpu); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 6bb4a7657129..a6d25ceb95ea 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2320,6 +2320,36 @@ static void remap_page(struct page *page, unsigned int nr) } } +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 d8313a389c84..8fd850d97df0 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -976,39 +976,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