Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8546445ybl; Wed, 25 Dec 2019 01:05:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwbucSPwK0wCmqDiG9ZnvH837f7vZd9Oq1nxqIMP4EvYBq/QMgjZSjEocC36cZ3LQk2hE1H X-Received: by 2002:a9d:6d10:: with SMTP id o16mr44752027otp.28.1577264742735; Wed, 25 Dec 2019 01:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577264742; cv=none; d=google.com; s=arc-20160816; b=fKl3+GDHqhEaR9ljkHH1K+8PPQDwa/siVcMwBVlrJtaR3lxtfXGz4EGobXj7M5N42q 03pXx6Blkgs2EcV+n5TYvN1eM5TWqUlyb3uZaHdpKtvnTBjGuGVBT/1DwZX/SBAAoPX/ jZIHIe6CbtDEblBNDrdp4MMbJFjA3f5Cq24eDbSaLl92hp8YCYUHW4B8Nz/BlZdaCSXO 29LGncdNb551k6huoILaytrr91kqLumjccnTVT74/mgoRFG3RZbCqapG0Q4GO9JHxt9L 73t3rUNzx0vEKjTKldWyUdQTQUi3e9P2ERX6v/+hpySTIC7xRvU7cC4ARXXyGi0NDmby 6Ihg== 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=epTiYSjC3x+6pZJDN+2r46D/Y5EZMOLEg+5K6hJFqW4=; b=AigII8jGreSnhjOaUXkWqfQ44Dpy1Hlzd1wajIVj2TnYA541KECXQ4ecH5x74GDSnF T3bcDqO/pGvJ8OV0mPkdFtPrLWk1gIgz9i0FvxfgEabQ98QuFm0N6Ukajv+eVCaVHC1S f27g/rF2k5rodZlnhBI7wsJAqiAX1YI8OEGwcbVh+5f7SrTrfHx3GGJYbj5z8KmKvy+x LRzJuPcIl1weZrn0vjhtTcUKvf66NZMj/Tkh+uLokLA/qmfwUCi7TjlZiAnXX+nVyvuo p4Ndi7uAchGoMo5rXL0NBd3pmw1Z4Xx+whwIq/4BVrfS1U05desHQnGrdnPgGEKvGSB7 OwuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id i20si8164023oie.119.2019.12.25.01.05.30; Wed, 25 Dec 2019 01:05:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726469AbfLYJEq (ORCPT + 99 others); Wed, 25 Dec 2019 04:04:46 -0500 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:39195 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbfLYJEo (ORCPT ); Wed, 25 Dec 2019 04:04:44 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0TltPEgd_1577264680; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TltPEgd_1577264680) by smtp.aliyun-inc.com(127.0.0.1); Wed, 25 Dec 2019 17:04:40 +0800 From: Alex Shi To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, willy@infradead.org, shakeelb@google.com, hannes@cmpxchg.org Cc: yun.wang@linux.alibaba.com Subject: [PATCH v7 01/10] mm/vmscan: remove unnecessary lruvec adding Date: Wed, 25 Dec 2019 17:04:17 +0800 Message-Id: <1577264666-246071-2-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1577264666-246071-1-git-send-email-alex.shi@linux.alibaba.com> References: <1577264666-246071-1-git-send-email-alex.shi@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't have to add a freeable page into lru and then remove from it. This change saves a couple of actions and makes the moving more clear. The SetPageLRU needs to be kept here for list intergrity. Otherwise: #0 mave_pages_to_lru #1 release_pages if (put_page_testzero()) if (put_page_testzero()) !PageLRU //skip lru_lock list_add(&page->lru,); else list_add(&page->lru,) //corrupt Signed-off-by: Alex Shi Cc: Andrew Morton Cc: Johannes Weiner Cc: Hugh Dickins Cc: yun.wang@linux.alibaba.com Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/vmscan.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 572fb17c6273..8719361b47a0 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1852,26 +1852,18 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, while (!list_empty(list)) { page = lru_to_page(list); VM_BUG_ON_PAGE(PageLRU(page), page); + list_del(&page->lru); if (unlikely(!page_evictable(page))) { - list_del(&page->lru); spin_unlock_irq(&pgdat->lru_lock); putback_lru_page(page); spin_lock_irq(&pgdat->lru_lock); continue; } - lruvec = mem_cgroup_page_lruvec(page, pgdat); - SetPageLRU(page); - lru = page_lru(page); - - nr_pages = hpage_nr_pages(page); - update_lru_size(lruvec, lru, page_zonenum(page), nr_pages); - list_move(&page->lru, &lruvec->lists[lru]); if (put_page_testzero(page)) { __ClearPageLRU(page); __ClearPageActive(page); - del_page_from_lru_list(page, lruvec, lru); if (unlikely(PageCompound(page))) { spin_unlock_irq(&pgdat->lru_lock); @@ -1880,6 +1872,12 @@ static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, } else list_add(&page->lru, &pages_to_free); } else { + lruvec = mem_cgroup_page_lruvec(page, pgdat); + lru = page_lru(page); + nr_pages = hpage_nr_pages(page); + + update_lru_size(lruvec, lru, page_zonenum(page), nr_pages); + list_add(&page->lru, &lruvec->lists[lru]); nr_moved += nr_pages; } } -- 1.8.3.1