Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp948740pxx; Thu, 29 Oct 2020 19:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNnTY9adVSj/iiZpKIfza6eMwC/iez2SZLNFwK6z5uNys5wr6/lN0IbxVfnlxuHKI0FDLZ X-Received: by 2002:aa7:dcd6:: with SMTP id w22mr64148edu.378.1604026389948; Thu, 29 Oct 2020 19:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604026389; cv=none; d=google.com; s=arc-20160816; b=cFlV1lHVDEKB2mtDd4MC9uTDDmjIUbKQS0dv+gYPee8jP6Nc4B/FIyLvXwN8+lfBkU 12QGY1ib6aSqLvMWeLVb6YGLPjl7Xt0fGXDTqph43TLQ/yX9GyG14DbGkWce17v39fdG 1CdOFNiZmQv349aWRHuQ+YJrYrhZGDkDLcIWWw/+cNUJVmlGuaXDmVNSPZavm1TGFlIV VWCvLE1u6nzs0E3vxCSrwDfJSXtguJ2blN8cSvkxWJwUAjmQMCL3FkMCArczBDu/qCT7 F8RWXEyxD7RztlhLIPSHkxhUUu/UFyuqdEqVz2OJ16DC4FcB0l0uidY2yp+Gfl6TMCWM /K3w== 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:cc:to:from :subject; bh=vhJIh76fS5dB9xzRxVy3CQAVVCHf7KE606mmdc4bExo=; b=lOYY1+24DmhmX0poKnaHj4yYo9ZEk4kRYsIl8baDzzLqwlmimmjlAh6WEVehS6od9r DsHlrAwV6cfnfN3SnZDxPBpsjWodrC6xx8EsczCTO76r5/+DS2+Ipr7SyNQDIJqhgwSn 3tfmfqERgDfKmjtM3FesQGZvNadskh/PFc2CJd3ctEhbIZ7kV8XHalj0k0vA55TZ2EJy tV/c1P1dgRJM5tRBpyNowtyWtcZW5KUdK7ah871FqDUFPV85uO6VX5VwocQO7ystJyVS 8O21J18Y5B9ZK8oJKr4NmLMjXEqafk3s/AdaWj1SE5WEGzfL9UvO+5jaWhUhNCdQEd2C v+iQ== 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 ca27si3399364edb.244.2020.10.29.19.52.47; Thu, 29 Oct 2020 19:53:09 -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 S1726355AbgJ3Cuj (ORCPT + 99 others); Thu, 29 Oct 2020 22:50:39 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:37169 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgJ3Cuh (ORCPT ); Thu, 29 Oct 2020 22:50:37 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;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_---0UDbYOcX_1604026231; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0UDbYOcX_1604026231) by smtp.aliyun-inc.com(127.0.0.1); Fri, 30 Oct 2020 10:50:32 +0800 Subject: Re: [PATCH v20 05/20] mm/thp: Simplify lru_add_page_tail() 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 Cc: =?UTF-8?Q?Mika_Penttil=c3=a4?= References: <1603968305-8026-1-git-send-email-alex.shi@linux.alibaba.com> <1603968305-8026-6-git-send-email-alex.shi@linux.alibaba.com> Message-ID: <5675f78c-5bd2-c413-41b5-a354ca897fab@linux.alibaba.com> Date: Fri, 30 Oct 2020 10:48:25 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <1603968305-8026-6-git-send-email-alex.shi@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org patch changed since varible rename in 4th patch: From 5014c78418284f70be232a37fa3a4660a54e83c0 Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Fri, 10 Jul 2020 12:53:22 +0800 Subject: [PATCH v21 05/20] mm/thp: Simplify lru_add_page_tail() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify lru_add_page_tail(), there are actually only two cases possible: split_huge_page_to_list(), with list supplied and head isolated from lru by its caller; or split_huge_page(), with NULL list and head on lru - because when head is racily isolated from lru, the isolator's reference will stop the split from getting any further than its page_ref_freeze(). So decide between the two cases by "list", but add VM_WARN_ON()s to verify that they match our lru expectations. [Hugh Dickins: rewrite commit log] Signed-off-by: Alex Shi Reviewed-by: Kirill A. Shutemov Acked-by: Hugh Dickins Cc: Kirill A. Shutemov Cc: Andrew Morton Cc: Johannes Weiner Cc: Matthew Wilcox Cc: Hugh Dickins Cc: Mika Penttilä Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/huge_memory.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 32a4bf5b80c8..cedcdbeb98b4 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2354,24 +2354,16 @@ static void lru_add_page_tail(struct page *head, struct page *tail, VM_BUG_ON_PAGE(PageLRU(tail), head); lockdep_assert_held(&lruvec_pgdat(lruvec)->lru_lock); - if (!list) - SetPageLRU(tail); - - if (likely(PageLRU(head))) - list_add_tail(&tail->lru, &head->lru); - else if (list) { + if (list) { /* page reclaim is reclaiming a huge page */ + VM_WARN_ON(PageLRU(head)); get_page(tail); list_add_tail(&tail->lru, list); } else { - /* - * Head page has not yet been counted, as an hpage, - * so we must account for each subpage individually. - * - * Put tail on the list at the correct position - * so they all end up in order. - */ - add_page_to_lru_list_tail(tail, lruvec, page_lru(tail)); + /* head is still on lru (and we have it frozen) */ + VM_WARN_ON(!PageLRU(head)); + SetPageLRU(tail); + list_add_tail(&tail->lru, &head->lru); } } -- 1.8.3.1