From patchwork Tue Feb 12 15:14:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10808111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7E7713A4 for ; Tue, 12 Feb 2019 15:14:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C59172BAF9 for ; Tue, 12 Feb 2019 15:14:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B94BB2BB0E; Tue, 12 Feb 2019 15:14:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFF932BAF9 for ; Tue, 12 Feb 2019 15:14:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8B018E0006; Tue, 12 Feb 2019 10:14:03 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A16778E0001; Tue, 12 Feb 2019 10:14:03 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 891058E0006; Tue, 12 Feb 2019 10:14:03 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by kanga.kvack.org (Postfix) with ESMTP id 166828E0001 for ; Tue, 12 Feb 2019 10:14:03 -0500 (EST) Received: by mail-lf1-f71.google.com with SMTP id y13so341438lfg.14 for ; Tue, 12 Feb 2019 07:14:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:date:message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=+YnQWQrQxrmDkSR8GKuGkhxf0mUW96FaQ/F8qD8cZvs=; b=TsYt6fzzgWPMrArtAxKQzEhZoLZjMqasYh0bJuAumfVPTFwtTTsqD60uhNnjwneTGR 0M6hDFSawo6FAKUrIm/dZIcxxkClr6aunaHLNeobamySfiLygbGXs52eUpnw2PBAzcr8 eIDNMTbASF9hlsXlta4+NE7SQY/BvGzgK5HTKgYcLWXhDpe57E14lguZT1ElCGE4UfNR SYjvZwZ2p1k7cCjGU9CG4kj5gCHBO2G1yuR0gJie8MRlzSdxLveG8pucMT60lML8GG7h s7CDaz7QHcg5BjRx1MEqMZIFtBQtiNwowVZZmRxofi6635pwYm1MPxoB1RTwHFosUkiJ wNdw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: AHQUAuZ3Z0hBFTzU00b2yqNId9z87vRds2GZAr4BfR8wQ8LBbYOS3Ukq PrgueRsAQOidf2xpkDIev8nO5pVxTAjPEuX4aHSR4Ts+xGFmS0O38DAHOOiJu3e9lK+A+RR/YR5 XzTxgOXKGuXRTgGbDspgp3WfJ7B2j58bv2WSoVIjQCppNjcMqct1GJURBTE9D4CgbpA== X-Received: by 2002:ac2:5085:: with SMTP id f5mr2750227lfm.30.1549984442374; Tue, 12 Feb 2019 07:14:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IbmKOyZe9tS/Topf/j96JpZzCxjZF8s7EDJsv5JGh9nlm+vYkpaV/kB4WtgWSmn5yirduQU X-Received: by 2002:ac2:5085:: with SMTP id f5mr2750160lfm.30.1549984441215; Tue, 12 Feb 2019 07:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549984441; cv=none; d=google.com; s=arc-20160816; b=zzrPpml/+1RyxdYbTsYKe68uBAQPWNAniSnWREAR70uR3wRgDAnKhGGMwBrLLOF9X6 0K2ZhMYEPoTQ3G6eKkm3NMyav2JZcPg8xtR8N/cIHiB3YSzMrv8d2tsiLbnQe0qyf8tx FlkN11j2m+E0cBjvXfBnedAOPfAjPbBrGfLnn14hGyq4UTkqo5hJxqGyu8PLRBp6BMPY qrrC5lqPxtpuxObANaGNeWeIgsWPD0Hfb50pC8+coTpGEWxYP+pjjf7rMgrD3V0lWegD JAdT8pdX3tOAnmbFTPEhrtHLpjyQI/ufprlRtPKF8eu0+BzBCKUxW23nGnT7vRnIQJd/ Vx6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:subject; bh=+YnQWQrQxrmDkSR8GKuGkhxf0mUW96FaQ/F8qD8cZvs=; b=KcuOUNkrNu+4RjrDHe/sS8znEwQJKNcn99xlrdbXvFRvR4kCa/p4BvT13OaznOzJSr 0hAp8MMI+juPp0ve6WKJ7dA8gBdUXxqvuPR88+IUybRQmHFfXgQSF5DUXfdx3PRp9JfF H365tMDroTebSP3bSpwKIHCSG8CbAhzQKs+fNOTf1lnqyaoewELvP78IsGWqlAJi6p/z teAozBveICNEALaRXK35dSl4cW5SF8kmjv8dT4YWGEya8sBu1kyZyJhV33ZvevH14qzF 2gKBnBsXPUu2MkSzUU6Z8QfNj0TgR19ZZlDnSxBnMaG2cmMw23pczwtncP99NJzp1yYp mVtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id n21si2210604lfa.98.2019.02.12.07.14.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 07:14:01 -0800 (PST) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gtZl2-0001Yn-Px; Tue, 12 Feb 2019 18:14:00 +0300 Subject: [PATCH 1/4] mm: Move recent_rotated pages calculation to shrink_inactive_list() From: Kirill Tkhai To: akpm@linux-foundation.org, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 12 Feb 2019 18:14:00 +0300 Message-ID: <154998444053.18704.14821278988281142015.stgit@localhost.localdomain> In-Reply-To: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> References: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Currently, struct reclaim_stat::nr_activate is a local variable, used only in shrink_page_list(). This patch introduces another local variable pgactivate to use instead of it, and reuses nr_activate to account number of active pages. Note, that we need nr_activate to be an array, since type of page may change during shrink_page_list() (see ClearPageSwapBacked()). Signed-off-by: Kirill Tkhai --- include/linux/vmstat.h | 2 +- mm/vmscan.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 2db8d60981fe..bdeda4b079fe 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -26,7 +26,7 @@ struct reclaim_stat { unsigned nr_congested; unsigned nr_writeback; unsigned nr_immediate; - unsigned nr_activate; + unsigned nr_activate[2]; unsigned nr_ref_keep; unsigned nr_unmap_fail; }; diff --git a/mm/vmscan.c b/mm/vmscan.c index ac4806f0f332..84542004a277 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1107,6 +1107,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, LIST_HEAD(ret_pages); LIST_HEAD(free_pages); unsigned nr_reclaimed = 0; + unsigned pgactivate = 0; memset(stat, 0, sizeof(*stat)); cond_resched(); @@ -1466,8 +1467,10 @@ static unsigned long shrink_page_list(struct list_head *page_list, try_to_free_swap(page); VM_BUG_ON_PAGE(PageActive(page), page); if (!PageMlocked(page)) { + int type = page_is_file_cache(page); SetPageActive(page); - stat->nr_activate++; + pgactivate++; + stat->nr_activate[type] += hpage_nr_pages(page); count_memcg_page_event(page, PGACTIVATE); } keep_locked: @@ -1482,7 +1485,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, free_unref_page_list(&free_pages); list_splice(&ret_pages, page_list); - count_vm_events(PGACTIVATE, stat->nr_activate); + count_vm_events(PGACTIVATE, pgactivate); return nr_reclaimed; } @@ -1807,7 +1810,6 @@ static int too_many_isolated(struct pglist_data *pgdat, int file, static noinline_for_stack void putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list) { - struct zone_reclaim_stat *reclaim_stat = &lruvec->reclaim_stat; struct pglist_data *pgdat = lruvec_pgdat(lruvec); LIST_HEAD(pages_to_free); @@ -1833,11 +1835,6 @@ putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list) lru = page_lru(page); add_page_to_lru_list(page, lruvec, lru); - if (is_active_lru(lru)) { - int file = is_file_lru(lru); - int numpages = hpage_nr_pages(page); - reclaim_stat->recent_rotated[file] += numpages; - } if (put_page_testzero(page)) { __ClearPageLRU(page); __ClearPageActive(page); @@ -1945,6 +1942,8 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, count_memcg_events(lruvec_memcg(lruvec), PGSTEAL_DIRECT, nr_reclaimed); } + reclaim_stat->recent_rotated[0] = stat.nr_activate[0]; + reclaim_stat->recent_rotated[1] = stat.nr_activate[1]; putback_inactive_pages(lruvec, &page_list); From patchwork Tue Feb 12 15:14:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10808113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 919B213A4 for ; Tue, 12 Feb 2019 15:14:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FBF22BAF9 for ; Tue, 12 Feb 2019 15:14:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73ED92BB0E; Tue, 12 Feb 2019 15:14:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05E0A2BAF9 for ; Tue, 12 Feb 2019 15:14:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED2728E0007; Tue, 12 Feb 2019 10:14:08 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E5B658E0001; Tue, 12 Feb 2019 10:14:08 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4AFD8E0007; Tue, 12 Feb 2019 10:14:08 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by kanga.kvack.org (Postfix) with ESMTP id 852F68E0001 for ; Tue, 12 Feb 2019 10:14:08 -0500 (EST) Received: by mail-lj1-f197.google.com with SMTP id k16-v6so929838lji.5 for ; Tue, 12 Feb 2019 07:14:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:date:message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=2iA42bvrhkhrqeIgwCNrjkP4IG0UzUSmJ+TcZfgtzNU=; b=rRerAikcH8pFKAmRTNcjhbm88dOse84daA6K+KWeyJFGGXgYQdE0jf3t9CDiyJ+pcr orYOMol3p26mr4Z0IkzY/Hs/3IghPRNUbigss7se8HiGsT9r7QKOMvEWJbj6yfDnmiqQ PFUhANUz6O124g01WO9qdR3Uou6vO21UdojeTxSoGl8VS1ry/guFpBcqVdiWL/cCW3WP Hcd8fT7xdRUnxa2Op2GW+MJqjQ2tfJdU/08N+oZvBB0k9OkV9DA5DG5z1Shl7erTEFaC 4Bm/32ikboZd62I5ybsTIuF0Er0M9ZzVtjRW34qaHwfZCOdtzAsa8zy85KppkJrrTtcl XwOw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: AHQUAuY6s/qmd3XkTka99ItZAF8Z4O2X1ZmZttjqpFhekDo6L5PMQ9TA AXR2LfbQ2JCaiszO8EKmxcTSvHcKFy015klG7fTGfMbotOlyNouZJ0PQsNdKbXd6HYQDsgH+bMn LXp0+ZdouhAtjB9bcST47v3GcnBqECronOfhR2NX8taohH1AmgOW14Pr1Hqh8GrXL5Q== X-Received: by 2002:a2e:c41:: with SMTP id o1-v6mr2638088ljd.152.1549984447872; Tue, 12 Feb 2019 07:14:07 -0800 (PST) X-Google-Smtp-Source: AHgI3Iachb2xnLq3QG4oZzKS/yleABfekIMTaX6aqU3pGvQISefMknGXPuwuE0R6gB0+TR7RPBp2 X-Received: by 2002:a2e:c41:: with SMTP id o1-v6mr2638041ljd.152.1549984446791; Tue, 12 Feb 2019 07:14:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549984446; cv=none; d=google.com; s=arc-20160816; b=HpYWiynMaX0CjuPA+cEXZs6bnuDkqFHIdLTH2Xg4VhWrRQKxiaqPSiASjtIxNHMdFk XCflHd4qE+9k1NqjYuHs+HHB9M6SONppaJRRo/ojPRrp2u+Wx500k9KYXlGwrHwwbuEw 7zAshqWkpYbst9OeTzExDRUPI9FD+Q+nAAXkKxN7bM5SKQhr8ko8d9bWUeyuC3NF+CxI c69MRHyF1hY+dxpW35fYoyBLZVoFvZsXeAwM7CKWYx/zW5E/o6vAFa6KoMRn3abR2aO0 EBGchAiS3SPmBX/wNzo0ZjKb5YX3HE4X2G6vCdfuJZw9wsLd/0no/+oO/l1mHWMRCBO4 GUrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:subject; bh=2iA42bvrhkhrqeIgwCNrjkP4IG0UzUSmJ+TcZfgtzNU=; b=GAH28fBmo81Ayr7BucaXMVRBaFO6hEiKIVFK3S4S0rEeeLWNObJY0SGYM4jbkx/wzr kJbHMP9dMEGcMFF+WipARhCRuD0CWLoiCMrtcS5IIjSI9xqTDM9w6DCws9r4aPmk8FD+ ZzwTEccrtKtyW2uAarOb9RluyADipgEi1U0pOJz5g9T34vkCGh1H0zKQMawwOEweKbjR t6ZJTnezTF2t1NjW8YLutrR4O/8pkZXvT+idp3k+N6RjBj8ZYzAmU53DlClj+J142Qp4 RyvC4WH/If6sjS/0ga9/envSemqgiFQRqXaCEYJaQvUg/wv90NGK58H1yc7SzIuYY7ZW ZZLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id t25si3981104lfk.111.2019.02.12.07.14.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 07:14:06 -0800 (PST) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gtZl8-0001Yz-D6; Tue, 12 Feb 2019 18:14:06 +0300 Subject: [PATCH 2/4] mm: Move nr_deactivate accounting to shrink_active_list() From: Kirill Tkhai To: akpm@linux-foundation.org, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 12 Feb 2019 18:14:05 +0300 Message-ID: <154998444590.18704.9387109537711017589.stgit@localhost.localdomain> In-Reply-To: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> References: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We know, which LRU is not active. Signed-off-by: Kirill Tkhai --- mm/vmscan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 84542004a277..8d7d55e71511 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2040,12 +2040,6 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec, } } - if (!is_active_lru(lru)) { - __count_vm_events(PGDEACTIVATE, nr_moved); - count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE, - nr_moved); - } - return nr_moved; } @@ -2137,6 +2131,10 @@ static void shrink_active_list(unsigned long nr_to_scan, nr_activate = move_active_pages_to_lru(lruvec, &l_active, &l_hold, lru); nr_deactivate = move_active_pages_to_lru(lruvec, &l_inactive, &l_hold, lru - LRU_ACTIVE); + + __count_vm_events(PGDEACTIVATE, nr_deactivate); + __count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE, nr_deactivate); + __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); spin_unlock_irq(&pgdat->lru_lock); From patchwork Tue Feb 12 15:14:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10808115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E38E13B5 for ; Tue, 12 Feb 2019 15:14:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BF442BAF9 for ; Tue, 12 Feb 2019 15:14:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F9E42BB0E; Tue, 12 Feb 2019 15:14:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 975C72BAF9 for ; Tue, 12 Feb 2019 15:14:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B6278E0008; Tue, 12 Feb 2019 10:14:14 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 867778E0001; Tue, 12 Feb 2019 10:14:14 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70A738E0008; Tue, 12 Feb 2019 10:14:14 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id 036A28E0001 for ; Tue, 12 Feb 2019 10:14:14 -0500 (EST) Received: by mail-lj1-f200.google.com with SMTP id x18-v6so932396lji.0 for ; Tue, 12 Feb 2019 07:14:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:date:message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=Oxgf0NT9kIH/X4lnwBoqmxmK+tOhc5fNpShonJM1CSU=; b=IJCdc1c5aeu4mHei1mdMJE1ASw16h0NGgEmhqd+QML6BidpLuPEPTYzWmHY2zfOb28 iwK1iqtuCFc/evmrtdHCmHUR/b9xwAGKP0QmXigb3gyI9w3uN5z+bkvcw+I9fhJXVQPB ROT/g4bWVQyR/G/MBgx5iiHMwZgZg3L7eDKruszomDwkI1oDNNRcIJkq81RlEQL20QMs NMhQJNjUiifag534tXxkfUhUtRDDrhHD4IC5Pw5zLIsdd8/JVgsDYUcgDmK637ZnYf4l a+JXEThPZJCndgYOclsgxNF8N7CqiQvvJ1694nvn0w9C3XcGtjUgFgyLije1G6zRjjYp 9sDQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: AHQUAuaHHz7MWZo9CEX0QBkVCSdh8BW8hp836+n0SjRh0+HevSL2v5Uf Ei1vp0VDZiotlqpBvGbg//ZMs3pItKVDiUZpIFGexv1GFwg/lOevVKyCeO67UmI39bmRH4METnQ lrKYu6zQOX2Ep9eIziAYlFO9sSGnxgj0YSa5Cn65o5Bl/qqECvNlhfzkwh/R/TN2yew== X-Received: by 2002:a19:c48e:: with SMTP id u136mr2592437lff.167.1549984453401; Tue, 12 Feb 2019 07:14:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IYBNy1kvFg9CutDtNlB+fxx1LSQRMN7FGVgpZBU3PSZ9zJyrmKllCCENUnDKXITIjYl6epk X-Received: by 2002:a19:c48e:: with SMTP id u136mr2592381lff.167.1549984452246; Tue, 12 Feb 2019 07:14:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549984452; cv=none; d=google.com; s=arc-20160816; b=NlZr/IYA/0If0WNPliWOjxbPyqLDKnVv0WAOl2xC6BiT+/gKWA82ou85ibxjEFtG1D Ie+KI6JPbeD32ZiFC3KoIDYjUnYV0jGa9SobqDE2GP3dK/O0XFi5AnUQ/b4XZml/EP8s F70OE/FOC+6NIQRhV1mijr8uBHtFVY0+cSl8Xl+Ok3MnN7rbL6rD/lBL5gaai8uuYve+ KspY0dQGUUedL+q+VnJoNJ7jDcrnduh90ywX2jdSagk0F6MZEErvtau3fLey3/+NzwIc Yf95eBIPMMPScAcSZO22IxgxKL95kBiKouikKxCLEpSo7dYXHpUoI2sZBUJzuTpx4BnK 6ydA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:subject; bh=Oxgf0NT9kIH/X4lnwBoqmxmK+tOhc5fNpShonJM1CSU=; b=v4QxGLc3c4kIdlq5IRUpEFFdNGIqCGxNdXxYI2LPw43SGgk95WanarMS2al3RwxZ/W bAHuhrn1ofuTD18r5hmMVOX/g8A6Iefgj/fP5GYoAnE81FT6WOiAOMqcevtP3RxndGhP wBuVBzwjl+IBxHLXDC0cXjEPe6xAVLpCvN7aML935xqaJZeAqVW2IZcaGs6MP5ujt8PW Q+gldu+PmLf8W+lH06iIxgdsxVn84Z1L6eaagPDwqWX/m3n4WIKWuhBIlDrX/JAxUV9M RvOgBQSPt7+6x+nL7x8Ib7XJyPt0Q1sQdkhgKK9h0os8YtKRgzjKeH1fbd0bEFP/lEG4 NcVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id w3si11752667lfa.77.2019.02.12.07.14.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 07:14:12 -0800 (PST) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gtZlD-0001ZB-Od; Tue, 12 Feb 2019 18:14:11 +0300 Subject: [PATCH 3/4] mm: Remove pages_to_free argument of move_active_pages_to_lru() From: Kirill Tkhai To: akpm@linux-foundation.org, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 12 Feb 2019 18:14:11 +0300 Message-ID: <154998445148.18704.11244772245027520877.stgit@localhost.localdomain> In-Reply-To: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> References: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP We may use input argument list as output argument too. This makes the function more similar to putback_inactive_pages(). Signed-off-by: Kirill Tkhai --- mm/vmscan.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 8d7d55e71511..88fa71e4c28f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2004,10 +2004,10 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, static unsigned move_active_pages_to_lru(struct lruvec *lruvec, struct list_head *list, - struct list_head *pages_to_free, enum lru_list lru) { struct pglist_data *pgdat = lruvec_pgdat(lruvec); + LIST_HEAD(pages_to_free); struct page *page; int nr_pages; int nr_moved = 0; @@ -2034,12 +2034,17 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec, (*get_compound_page_dtor(page))(page); spin_lock_irq(&pgdat->lru_lock); } else - list_add(&page->lru, pages_to_free); + list_add(&page->lru, &pages_to_free); } else { nr_moved += nr_pages; } } + /* + * To save our caller's stack, now use input list for pages to free. + */ + list_splice(&pages_to_free, list); + return nr_moved; } @@ -2129,8 +2134,10 @@ static void shrink_active_list(unsigned long nr_to_scan, */ reclaim_stat->recent_rotated[file] += nr_rotated; - nr_activate = move_active_pages_to_lru(lruvec, &l_active, &l_hold, lru); - nr_deactivate = move_active_pages_to_lru(lruvec, &l_inactive, &l_hold, lru - LRU_ACTIVE); + nr_activate = move_active_pages_to_lru(lruvec, &l_active, lru); + nr_deactivate = move_active_pages_to_lru(lruvec, &l_inactive, lru - LRU_ACTIVE); + /* Keep all free pages are in l_active list */ + list_splice(&l_inactive, &l_active); __count_vm_events(PGDEACTIVATE, nr_deactivate); __count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE, nr_deactivate); @@ -2138,8 +2145,8 @@ static void shrink_active_list(unsigned long nr_to_scan, __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); spin_unlock_irq(&pgdat->lru_lock); - mem_cgroup_uncharge_list(&l_hold); - free_unref_page_list(&l_hold); + mem_cgroup_uncharge_list(&l_active); + free_unref_page_list(&l_active); trace_mm_vmscan_lru_shrink_active(pgdat->node_id, nr_taken, nr_activate, nr_deactivate, nr_rotated, sc->priority, file); } From patchwork Tue Feb 12 15:14:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10808117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 245B913B5 for ; Tue, 12 Feb 2019 15:14:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1292B2BAF9 for ; Tue, 12 Feb 2019 15:14:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 063862BB0E; Tue, 12 Feb 2019 15:14:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFCD62BAF9 for ; Tue, 12 Feb 2019 15:14:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EE478E0009; Tue, 12 Feb 2019 10:14:20 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 97A2D8E0001; Tue, 12 Feb 2019 10:14:20 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F33A8E0009; Tue, 12 Feb 2019 10:14:20 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by kanga.kvack.org (Postfix) with ESMTP id 112DA8E0001 for ; Tue, 12 Feb 2019 10:14:20 -0500 (EST) Received: by mail-lf1-f72.google.com with SMTP id d8so335773lfa.23 for ; Tue, 12 Feb 2019 07:14:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:date:message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=7zMctRGZ05kE70Bz3WkYp7PAVWydIeKsuSWdzLddV9E=; b=dHBVVkYsVYe49rdnojMsEBQ9j34/nejMpqIZgjA6rwcOCK4yy765PydHmfFyu83wQY 2tA1xLdUNDL6b+x+gbOFVzwaOo7xlMjkq5aK2B+D/NOiwpgwCBiXuXUs6yt1awCf0E9E dX41E7KZN9NNnb8tx4jKqSFYyQ2pllbMF3c6NT49G7SpwMGeUad2fY2XEnqkkJu6Qn2O qPaVRfiEhXhWJ/DvG4M+WBtTAfcPQRua0/OT/ldPenkOxSqARzjlLqxqiuyRoexyog9/ 0upCiEUExeFAqO4RIUrUIa1KeKWuJgNYNguvvGzbKXrXnqX5xjBuXJ4ognhpaqNkZc9c wv0A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: AHQUAuZzjV5qtUgeA18UacsY78FWjlp/OwzlWnGfuGhW2x9yQvcPXpQd 8Oc0ZkXp9ojgbwTMuH4wwiuxA36XyNwSVO0i3CgNP6RlCLWDC8ID0QlTfzG0UrrKFIYPiqBjgNh aWCr0kfrF3cv6snD9mA9DAgAufgKzbmeOt8utcEvd8idTWAolAWZxkljMCcf1E+VfPw== X-Received: by 2002:a2e:2f15:: with SMTP id v21-v6mr2657395ljv.56.1549984459399; Tue, 12 Feb 2019 07:14:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IaOuUBkqHBtfc5hc2FvAaGmztyafYPtxngcTbeXnCDOtx1h3rx/SAQRs57TNu3TBlc6CLIe X-Received: by 2002:a2e:2f15:: with SMTP id v21-v6mr2657325ljv.56.1549984457981; Tue, 12 Feb 2019 07:14:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549984457; cv=none; d=google.com; s=arc-20160816; b=DU5zYjnelJVrRj1cVoTslPV/9jW9LqUm/M0NvAnjDpzSPED0prRquRYAIS8g9D1Bws vSxLu1wIVXynXJ4Hgxq5DBSdvL1NZqNDRjptJ0hgQI6uV2AIf6Nbul751J5GIvwDxx87 mFVO4rTvSbRum4qn8waMpYTA8we+2FS0OimEvGGW3cQYplo5Ed/JCr5aVoUYFGYmT4ae fWU9hosf5hOtPPfVFjka2sOFcO7JREjZb/1hA0/xjus8HyplrmrSV91RL2GFFzb+rAil r4cvEHvCHTbS0Ti7snRJ4SeXjhHafNpVow4s1RPkH4B5PHOmfbvfx+iSvj6FKxeE/XAQ K9wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:subject; bh=7zMctRGZ05kE70Bz3WkYp7PAVWydIeKsuSWdzLddV9E=; b=zvmRndHBY+CmjWcpQfO7+NbkhumkSYlv9SVfPgVpppK4RpJYHUDKno0VOkPfKlHzWR dElfTVuhtHKz9XYhMO5JaTIWS8ZTk62BfoBV0Lb7CP3BEEsl3E7x0UN0Zhw72QxOVcNE jQnbZ+zlre4Y6jRPF23npq3I24qs60K4KVMsH5c5bIVQR6uH7RoxYugjqncf0QH8oOB+ cjpqPqpyqiZz7HQp3/denA2k/GiGsvLXyKAMJph7dB6MUiSOBzbcwI+lD5GN/w9+lT4l dWjAGJT/0pPPsP6N8ft+YqAI2L+xACdhhlK40Uo9wAWdYshRzvmjF5mt0PKccNibgag4 4APA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id n21si2211060lfa.98.2019.02.12.07.14.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 07:14:17 -0800 (PST) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gtZlJ-0001ZP-Gv; Tue, 12 Feb 2019 18:14:17 +0300 Subject: [PATCH 4/4] mm: Generalize putback scan functions From: Kirill Tkhai To: akpm@linux-foundation.org, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 12 Feb 2019 18:14:16 +0300 Message-ID: <154998445694.18704.16751838197928455484.stgit@localhost.localdomain> In-Reply-To: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> References: <154998432043.18704.10326447825287153712.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This combines two similar functions move_active_pages_to_lru() and putback_inactive_pages() into single move_pages_to_lru(). This remove duplicate code and makes object file size smaller. Before: text data bss dec hex filename 57082 4732 128 61942 f1f6 mm/vmscan.o After: text data bss dec hex filename 55112 4600 128 59840 e9c0 mm/vmscan.o Signed-off-by: Kirill Tkhai --- mm/vmscan.c | 124 ++++++++++++++++++++--------------------------------------- 1 file changed, 41 insertions(+), 83 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 88fa71e4c28f..66e70cf1dd94 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1807,33 +1807,53 @@ static int too_many_isolated(struct pglist_data *pgdat, int file, return isolated > inactive; } -static noinline_for_stack void -putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list) +/* + * This moves pages from @list to corresponding LRU list. + * + * We move them the other way if the page is referenced by one or more + * processes, from rmap. + * + * If the pages are mostly unmapped, the processing is fast and it is + * appropriate to hold zone_lru_lock across the whole operation. But if + * the pages are mapped, the processing is slow (page_referenced()) so we + * should drop zone_lru_lock around each page. It's impossible to balance + * this, so instead we remove the pages from the LRU while processing them. + * It is safe to rely on PG_active against the non-LRU pages in here because + * nobody will play with that bit on a non-LRU page. + * + * The downside is that we have to touch page->_refcount against each page. + * But we had to alter page->flags anyway. + * + * Returns the number of pages moved to the given lruvec. + */ + +static unsigned noinline_for_stack move_pages_to_lru(struct lruvec *lruvec, + struct list_head *list) { struct pglist_data *pgdat = lruvec_pgdat(lruvec); + int nr_pages, nr_moved = 0; LIST_HEAD(pages_to_free); + struct page *page; + enum lru_list lru; - /* - * Put back any unfreeable pages. - */ - while (!list_empty(page_list)) { - struct page *page = lru_to_page(page_list); - int lru; - - VM_BUG_ON_PAGE(PageLRU(page), page); - list_del(&page->lru); + while (!list_empty(list)) { + page = lru_to_page(list); if (unlikely(!page_evictable(page))) { + list_del_init(&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); + VM_BUG_ON_PAGE(PageLRU(page), page); SetPageLRU(page); lru = page_lru(page); - add_page_to_lru_list(page, lruvec, lru); + + 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); @@ -1847,13 +1867,17 @@ putback_inactive_pages(struct lruvec *lruvec, struct list_head *page_list) spin_lock_irq(&pgdat->lru_lock); } else list_add(&page->lru, &pages_to_free); + } else { + nr_moved += nr_pages; } } /* * To save our caller's stack, now use input list for pages to free. */ - list_splice(&pages_to_free, page_list); + list_splice(&pages_to_free, list); + + return nr_moved; } /* @@ -1945,7 +1969,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, reclaim_stat->recent_rotated[0] = stat.nr_activate[0]; reclaim_stat->recent_rotated[1] = stat.nr_activate[1]; - putback_inactive_pages(lruvec, &page_list); + move_pages_to_lru(lruvec, &page_list); __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); @@ -1982,72 +2006,6 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, return nr_reclaimed; } -/* - * This moves pages from the active list to the inactive list. - * - * We move them the other way if the page is referenced by one or more - * processes, from rmap. - * - * If the pages are mostly unmapped, the processing is fast and it is - * appropriate to hold zone_lru_lock across the whole operation. But if - * the pages are mapped, the processing is slow (page_referenced()) so we - * should drop zone_lru_lock around each page. It's impossible to balance - * this, so instead we remove the pages from the LRU while processing them. - * It is safe to rely on PG_active against the non-LRU pages in here because - * nobody will play with that bit on a non-LRU page. - * - * The downside is that we have to touch page->_refcount against each page. - * But we had to alter page->flags anyway. - * - * Returns the number of pages moved to the given lru. - */ - -static unsigned move_active_pages_to_lru(struct lruvec *lruvec, - struct list_head *list, - enum lru_list lru) -{ - struct pglist_data *pgdat = lruvec_pgdat(lruvec); - LIST_HEAD(pages_to_free); - struct page *page; - int nr_pages; - int nr_moved = 0; - - while (!list_empty(list)) { - page = lru_to_page(list); - lruvec = mem_cgroup_page_lruvec(page, pgdat); - - VM_BUG_ON_PAGE(PageLRU(page), page); - SetPageLRU(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); - mem_cgroup_uncharge(page); - (*get_compound_page_dtor(page))(page); - spin_lock_irq(&pgdat->lru_lock); - } else - list_add(&page->lru, &pages_to_free); - } else { - nr_moved += nr_pages; - } - } - - /* - * To save our caller's stack, now use input list for pages to free. - */ - list_splice(&pages_to_free, list); - - return nr_moved; -} - static void shrink_active_list(unsigned long nr_to_scan, struct lruvec *lruvec, struct scan_control *sc, @@ -2134,8 +2092,8 @@ static void shrink_active_list(unsigned long nr_to_scan, */ reclaim_stat->recent_rotated[file] += nr_rotated; - nr_activate = move_active_pages_to_lru(lruvec, &l_active, lru); - nr_deactivate = move_active_pages_to_lru(lruvec, &l_inactive, lru - LRU_ACTIVE); + nr_activate = move_pages_to_lru(lruvec, &l_active); + nr_deactivate = move_pages_to_lru(lruvec, &l_inactive); /* Keep all free pages are in l_active list */ list_splice(&l_inactive, &l_active);