From patchwork Mon Feb 18 08:20:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10817463 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 132F16CB for ; Mon, 18 Feb 2019 08:21:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2F372A35C for ; Mon, 18 Feb 2019 08:21:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6D502A374; Mon, 18 Feb 2019 08:21:02 +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 36E7B2A35C for ; Mon, 18 Feb 2019 08:21:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 254298E0005; Mon, 18 Feb 2019 03:21:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 119F48E0001; Mon, 18 Feb 2019 03:21:01 -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 006608E0005; Mon, 18 Feb 2019 03:21:00 -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 86CCF8E0001 for ; Mon, 18 Feb 2019 03:21:00 -0500 (EST) Received: by mail-lf1-f72.google.com with SMTP id i19so1293513lfi.4 for ; Mon, 18 Feb 2019 00:21:00 -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=j6lf0s+rCUNA4g/UtrK/iEyQd+zeh9+HicFeiMIFdjA=; b=reTchkWKtir7BMd8QIDzimARplMMGVAGutoPpvHCzOnfTF6YFmVFSy7lEJ/V75riyV 3ZUddlZn4QG0MOZgsuXJIRz6ZPLhlwtTpch1RVhR+6G8/fGHetfcMdltzDY9ogmTlyWa XqJuz+cP0oAuegbGr7QORUBvxOAIygAlP7Vja+vCfoqjM1ywqt07sC2jwO7k2cflTGCn wp625eJW9hCSBUWvh+oMMvN/0MzARUl1gENMZrrNoGJZkUqRW13esz+LnS0DzX3FPNtX dOPCiaJW/7TYfBqzs8ra9ATt9bXUtRshzjUwZ90verO6YSpmXfESgGvo0xqzwa/XHFKp vhvg== 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: AHQUAub6ZbljL9zQLg/G3rbYfKUMSjWB7aRBK21jcYmeTmEULApc5xI6 Tkj9N0KnH8LjQ9R4EasfRlB24ngQbp/22Nfq5VLOLbKbQtHfmejQR4QDFPBCS0UHxWDGSMfk55O Xiu1S6OxISIi0lNEqfZhe8lUXhdyhvaZwkr9cpKce9Lgf1oGxcY+G8FdwtFK/lROHiQ== X-Received: by 2002:a2e:9a09:: with SMTP id o9-v6mr13243356lji.132.1550478059768; Mon, 18 Feb 2019 00:20:59 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibc0sGnkwUGcR6tsNljbZmgU8EwYql49FbFt9asu7W6EPhkcSjfd3em10iYwqMObF0zLdNX X-Received: by 2002:a2e:9a09:: with SMTP id o9-v6mr13243294lji.132.1550478058294; Mon, 18 Feb 2019 00:20:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550478058; cv=none; d=google.com; s=arc-20160816; b=RpH4OeB86Fi5/yz7Z0NFjqrcQ7Jwz6TNeoYZNLbpwPtnTMQ9Gs2JUT84VfSXhsBdK2 f2cdCq4caMl0CJbKk4Hm2LnPHGOSiel42RqBpTC1FNIarJg5g/7PZOW6nRaZaTjcPKXT CemqYm3D3o0jqLq8NnbSg/9LLVwoTyHrDeXdodM1ZgfvlzDJ8Bt4xLe39L2GiY3d3PFo IO3ZzAlRT/z8f+SO3/M5dHXGJccQHygsa5I2jBSQABQIn4ra1qG0qs/KLf4HaECTFA0f atCnsUQP6podu2Un8mBKfA8G52EYgPcXIZok1gTdfqlbmBjNNVaHhKZKM1BuKeZGjUYj 7FrA== 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=j6lf0s+rCUNA4g/UtrK/iEyQd+zeh9+HicFeiMIFdjA=; b=j9er5V3TnSIYWc6300y7iaRQgjiMeJk44w29+Nku2D5MLo6AXU8yFhD/NyXHpX74HP OQ3xz4cA7cASGDXuvpO0+7aNvRtbbZdamSntcz8Nx4GPcB+B52x2adw3OGuVDVjfkwQ0 PNDLdHAiVpqZX3DStcj6qH3l2qvJZazaHcOPUMh7rSxEeQHo6bQzqvemZPz0jfkJDrg4 b6MZosZFTNlo1v9wrJ0+YI1XQqsqRycPLLLdR7JAP0jPms9dM1Dn6oWVDyTjauTbvJyK xkQ9SeONYCisVrH/kM9X9wWG4h2CzTncPriKUhspudBQpLt/ZJXRjkZXa5hecKis+7EB DBRw== 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 i13si11197753lfc.125.2019.02.18.00.20.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 00:20:57 -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 1gveAU-0007pQ-2n; Mon, 18 Feb 2019 11:20:50 +0300 Subject: [PATCH v3 1/4] mm: Move recent_rotated pages calculation to shrink_inactive_list() From: Kirill Tkhai To: akpm@linux-foundation.org, daniel.m.jordan@oracle.com, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 18 Feb 2019 11:20:49 +0300 Message-ID: <155047804982.13111.9002323194452834079.stgit@localhost.localdomain> In-Reply-To: <155047790692.13111.18025172438615659583.stgit@localhost.localdomain> References: <155047790692.13111.18025172438615659583.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 The patch moves the calculation from putback_inactive_pages() to shrink_inactive_list(). This makes putback_inactive_pages() looking more similar to move_active_pages_to_lru(). To do that, we account activated pages in reclaim_stat::nr_activate. Since a page may change its LRU type from anon to file cache inside shrink_page_list() (see ClearPageSwapBacked()), we have to account pages for the both types. So, nr_activate becomes an array. Previously we used nr_activate to account PGACTIVATE events, but now we account them into pgactivate variable (since they are about number of pages in general, not about sum of hpage_nr_pages). Signed-off-by: Kirill Tkhai Reviewed-by: Daniel Jordan v2.5: Update comment. v2: Update trace events. --- .../trace/postprocess/trace-vmscan-postprocess.pl | 7 ++++--- include/linux/vmstat.h | 2 +- include/trace/events/vmscan.h | 13 ++++++++----- mm/vmscan.c | 15 +++++++-------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl index 66bfd8396877..995da15b16ca 100644 --- a/Documentation/trace/postprocess/trace-vmscan-postprocess.pl +++ b/Documentation/trace/postprocess/trace-vmscan-postprocess.pl @@ -113,7 +113,7 @@ my $regex_kswapd_wake_default = 'nid=([0-9]*) order=([0-9]*)'; my $regex_kswapd_sleep_default = 'nid=([0-9]*)'; my $regex_wakeup_kswapd_default = 'nid=([0-9]*) zid=([0-9]*) order=([0-9]*) gfp_flags=([A-Z_|]*)'; my $regex_lru_isolate_default = 'isolate_mode=([0-9]*) classzone_idx=([0-9]*) order=([0-9]*) nr_requested=([0-9]*) nr_scanned=([0-9]*) nr_skipped=([0-9]*) nr_taken=([0-9]*) lru=([a-z_]*)'; -my $regex_lru_shrink_inactive_default = 'nid=([0-9]*) nr_scanned=([0-9]*) nr_reclaimed=([0-9]*) nr_dirty=([0-9]*) nr_writeback=([0-9]*) nr_congested=([0-9]*) nr_immediate=([0-9]*) nr_activate=([0-9]*) nr_ref_keep=([0-9]*) nr_unmap_fail=([0-9]*) priority=([0-9]*) flags=([A-Z_|]*)'; +my $regex_lru_shrink_inactive_default = 'nid=([0-9]*) nr_scanned=([0-9]*) nr_reclaimed=([0-9]*) nr_dirty=([0-9]*) nr_writeback=([0-9]*) nr_congested=([0-9]*) nr_immediate=([0-9]*) nr_activate_anon=([0-9]*) nr_activate_file=([0-9]*) nr_ref_keep=([0-9]*) nr_unmap_fail=([0-9]*) priority=([0-9]*) flags=([A-Z_|]*)'; my $regex_lru_shrink_active_default = 'lru=([A-Z_]*) nr_scanned=([0-9]*) nr_rotated=([0-9]*) priority=([0-9]*)'; my $regex_writepage_default = 'page=([0-9a-f]*) pfn=([0-9]*) flags=([A-Z_|]*)'; @@ -212,7 +212,8 @@ $regex_lru_shrink_inactive = generate_traceevent_regex( "vmscan/mm_vmscan_lru_shrink_inactive", $regex_lru_shrink_inactive_default, "nid", "nr_scanned", "nr_reclaimed", "nr_dirty", "nr_writeback", - "nr_congested", "nr_immediate", "nr_activate", "nr_ref_keep", + "nr_congested", "nr_immediate", "nr_activate_anon", + "nr_activate_file", "nr_ref_keep", "nr_unmap_fail", "priority", "flags"); $regex_lru_shrink_active = generate_traceevent_regex( "vmscan/mm_vmscan_lru_shrink_active", @@ -407,7 +408,7 @@ sub process_events { } my $nr_reclaimed = $3; - my $flags = $12; + my $flags = $13; my $file = 0; if ($flags =~ /RECLAIM_WB_FILE/) { $file = 1; 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/include/trace/events/vmscan.h b/include/trace/events/vmscan.h index a1cb91342231..4f0e45e90cfc 100644 --- a/include/trace/events/vmscan.h +++ b/include/trace/events/vmscan.h @@ -358,7 +358,8 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive, __field(unsigned long, nr_writeback) __field(unsigned long, nr_congested) __field(unsigned long, nr_immediate) - __field(unsigned long, nr_activate) + __field(unsigned int, nr_activate0) + __field(unsigned int, nr_activate1) __field(unsigned long, nr_ref_keep) __field(unsigned long, nr_unmap_fail) __field(int, priority) @@ -373,20 +374,22 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive, __entry->nr_writeback = stat->nr_writeback; __entry->nr_congested = stat->nr_congested; __entry->nr_immediate = stat->nr_immediate; - __entry->nr_activate = stat->nr_activate; + __entry->nr_activate0 = stat->nr_activate[0]; + __entry->nr_activate1 = stat->nr_activate[1]; __entry->nr_ref_keep = stat->nr_ref_keep; __entry->nr_unmap_fail = stat->nr_unmap_fail; __entry->priority = priority; __entry->reclaim_flags = trace_shrink_flags(file); ), - TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate=%ld nr_ref_keep=%ld nr_unmap_fail=%ld priority=%d flags=%s", + TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate_anon=%d nr_activate_file=%d nr_ref_keep=%ld nr_unmap_fail=%ld priority=%d flags=%s", __entry->nid, __entry->nr_scanned, __entry->nr_reclaimed, __entry->nr_dirty, __entry->nr_writeback, __entry->nr_congested, __entry->nr_immediate, - __entry->nr_activate, __entry->nr_ref_keep, - __entry->nr_unmap_fail, __entry->priority, + __entry->nr_activate0, __entry->nr_activate1, + __entry->nr_ref_keep, __entry->nr_unmap_fail, + __entry->priority, show_reclaim_flags(__entry->reclaim_flags)) ); 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 Mon Feb 18 08:20:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10817465 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 A64796CB for ; Mon, 18 Feb 2019 08:21:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 931162A35C for ; Mon, 18 Feb 2019 08:21:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 861842A366; Mon, 18 Feb 2019 08:21: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 EF2492A35C for ; Mon, 18 Feb 2019 08:21:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFC118E0006; Mon, 18 Feb 2019 03:21:08 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E85A18E0001; Mon, 18 Feb 2019 03:21: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 D73B38E0006; Mon, 18 Feb 2019 03:21:08 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by kanga.kvack.org (Postfix) with ESMTP id 684788E0001 for ; Mon, 18 Feb 2019 03:21:08 -0500 (EST) Received: by mail-lj1-f199.google.com with SMTP id v4so187756ljc.21 for ; Mon, 18 Feb 2019 00:21: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=UDYt67lC/nUEnY97sYoZYYeAB57EoEaThBbl3sDwSL0=; b=OU3DOkLxNZII5l8asVQm1jeKd7YxxzxUdjmIDtZ171oOuExZIvEsL3u3oLAJLwIERY k0AWewbWepBVQjJiMR7z6W7eJuQTStqvU1HOg2W8R+1zFuofuYRWgG7koP32o6S6M8MR 1j35TDuvEWQXmSSMDDAM6Nl2gjYNvAnGjRXFY8TgjK0GoFRDun24w9b2Z8M7H5yVT60+ LVYF3TrcEzUPjormsDOo7TxnyF462inNlH6bODZbqnRTXpa4Ea98k+mu/anyrvNDdPg5 kKfz9UYxlZ19H6qGYn37XghDHiFZvzJObCx9LJ9b9aen1dD3fbRDWFJ5YFP+VucjKHRb 2c2g== 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: AHQUAuY2LKofkEdrf7Y5GmwkUm+ZVeYflRxnMOh196ZmiUbcdMFd/HoW ckd+PKb1lkSooFODifsIH1BpJPE/hOi4VqW+FYHQmjFfrCH923+TJs3kLjnyl1BeKN1nZ/V00YI s4WiEcUYivYR3CedqMlEqTMskLfOB/4PZ1w+XJE05AEMrnlKFUSeRo61xukgVcujXSg== X-Received: by 2002:a2e:9a8b:: with SMTP id p11mr13264950lji.66.1550478067779; Mon, 18 Feb 2019 00:21:07 -0800 (PST) X-Google-Smtp-Source: AHgI3IbG0yRnrzUYP355WbCvYKgNUXKQLfovpOrV4PCdUTlOCYqGn4KWFHhtGGjgvYoNms45Hpdr X-Received: by 2002:a2e:9a8b:: with SMTP id p11mr13264909lji.66.1550478066744; Mon, 18 Feb 2019 00:21:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550478066; cv=none; d=google.com; s=arc-20160816; b=DUF7FlyGgVw14/S/yZyMcib/n3Os9pzhz243NcX68+IX5Rm/96UhGfWsTTsDgNV58n ZhAA2Ehv0JdjFl0P4xWj+oHaf+eR7uhr33C6FcBNTiH5sz+WbU4XnEQMura1U4K01v03 FWhAawjlw8G21Jpddni08Xkex+vI2NXizP7PTnZU38B+ZUDXHv1TeOkOEgisMw/HOK17 9QpasFxPAHWLhepVVJ8GduI8GND4V2KGq8wOgjd2jDh5uLg/A+N+TI/L/hSYhUc31Xb5 x0SQMDqEfB2TsyeY/6Eo0mjHgd5EtQBIGyaEuJJdVJBk6MVN1uxiGV0WkeJgRks54wCQ BXpg== 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=UDYt67lC/nUEnY97sYoZYYeAB57EoEaThBbl3sDwSL0=; b=Oi/ouaMBSDBcuOW1fyyUwHCRYNqJzOH2SG5JZ67Dv8Gh8pHduo4AxtYPY4pUW+OR3c Ce7bwdLpPS/kEDhwt1LFPZuw8ZtAwMlVHPFpxO45pQ5pc+oOCbCp0QFsktBcqCN98yoM xujlO07VHrEPwL0TUK6MEg4f0lvALUqNcnhTia28bScV3wFeFs5obi6fcKjwOUfQv25k x6d/9MC5JBApemAVqtfINQO/aGYn8N9+qFiUgEzKWKcxy7QeQOMS7HC2uqecmWaUjnt/ Tmp81G4JzWRBk8EpTURp62y9bj0vx1Zy7uALg6W3xUt7ZEaGYhsluBJ7o/kpxQJRfuG4 qP+w== 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 g14-v6si9827874ljk.201.2019.02.18.00.21.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 00:21: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 1gveAZ-0007pa-FX; Mon, 18 Feb 2019 11:20:55 +0300 Subject: [PATCH v3 2/4] mm: Move nr_deactivate accounting to shrink_active_list() From: Kirill Tkhai To: akpm@linux-foundation.org, daniel.m.jordan@oracle.com, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 18 Feb 2019 11:20:55 +0300 Message-ID: <155047805525.13111.10290320587729090284.stgit@localhost.localdomain> In-Reply-To: <155047790692.13111.18025172438615659583.stgit@localhost.localdomain> References: <155047790692.13111.18025172438615659583.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 Reviewed-by: Daniel Jordan --- 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 Mon Feb 18 08:21: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: 10817467 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 03CA96CB for ; Mon, 18 Feb 2019 08:21:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E58502A35C for ; Mon, 18 Feb 2019 08:21:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D99532A366; Mon, 18 Feb 2019 08:21:15 +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 728B52A35C for ; Mon, 18 Feb 2019 08:21:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 428D88E0007; Mon, 18 Feb 2019 03:21:14 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3AEFA8E0001; Mon, 18 Feb 2019 03:21: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 251698E0007; Mon, 18 Feb 2019 03:21: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 A73E88E0001 for ; Mon, 18 Feb 2019 03:21:13 -0500 (EST) Received: by mail-lj1-f200.google.com with SMTP id p86-v6so3973614lja.2 for ; Mon, 18 Feb 2019 00:21: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=tdC0mzs80WGKatTqNZ8P/CEriCSP6hwO50kzHXGiqkM=; b=PQJrYAxpEyvaK+goALji35Kl3cexoWAtpLY054Rp2UWu0fFZ9aDHN0w2pCgVKTXEbv 8rLP0YnPbDGjqBPK602vvLOVhi1TeC0bVcqmEyl3knBIgh+kC58D7T2NzTZberPyDinC sl+osh8bFJ97N9KzboDZXYONcfvrg4qkbS9aHmZNnPRPncVt9Hsiz48TYj+3+rBFo3Sd dB7EHbf74oRvIs9XxLnhPCPlw6YpgMzr8rZb1n0QMex3HEY4Mxq3S8W97UxcKO7c381n DQABcOwLJsz+ndT1CrOpCLit2Eo4QGJPQGIttTtLc3uSfNUYpEI5hUB/Ui9nMTgNdbfr WZ0g== 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: AHQUAuYnkQNv0cVS1K0OnedrI5/isWNLoia88FcigrdQX7fRv6N9XN4h kXQZ+XFT5qYqGd+pPnRGOQ2ty91uh/0s8xuwmJwe52ExwbouFF6A1IZRot/xMag/UlPGP0KqjjW ydBWc85YZsMYKtXWYXS1Hs4Z7sR7Ty83cxT45jhZjbu3+AX3v6edA3fbPQAKpDqD6ww== X-Received: by 2002:a19:645e:: with SMTP id b30mr12965474lfj.15.1550478072978; Mon, 18 Feb 2019 00:21:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IZe6hk6GLToPRmftmAI3ooFDbtsLLl6uxh+cVxaiyI9opoaN7WtuO0TtF5b5JhnDZ1B8ZlT X-Received: by 2002:a19:645e:: with SMTP id b30mr12965433lfj.15.1550478071833; Mon, 18 Feb 2019 00:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550478071; cv=none; d=google.com; s=arc-20160816; b=gAVwhCDS766qyvmLHzh5X4Vchd9l1PGKi2k1B7N3OMJF8zlK+yMAShrhETsuNuWNVk Lr9tLiD1xri6fJgMLwfOH7TJ1jeD4159IUtC7wlHl5fsK72Dl56B2OT+1wTl8eZDsALc rrRGaleRP/pqML8YUWdSQekd09neT12U79EARgckTaiZZNN/tyVkavrPLzYVaWH4dDRO wX99MC+XuCVsTwRQ//oktaJCZXlnjPjCp6zCT34+WrJU2zrvklfTrQiXAB0NEKWoIFHT iQ4T8mpd+QldSOlNCugLLMIuR3xuGC7Wt5KnpsbpWvQUfAMDOz3VWN7Xzr1hrW7bBTiJ sAUQ== 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=tdC0mzs80WGKatTqNZ8P/CEriCSP6hwO50kzHXGiqkM=; b=w2Z5Zpu58TTfJ6IxOhScWijlHNqYTPq0jjYfPKk17iOtLPOaWYcRHz7C3ZMwOJmg1S 0yL0PbybVQtjl+Kc0RTladTY8Ji07YnAnlvSvrSMKU9hUFmrFLY7d8WKL1KCym/W2pO3 BNWLegauWvimQFduYBCKe/mUSEh+l70nJ+s/TrEyI4wA9sRMUrlIBEJP+n7alhn5azok tTb604MUw1JSiP1rVgHXtQkmkes2pYl9cDqAErnUAcK3qAauIippuJBmiTjh11c4x4m6 8WG/0ug9M+0W3/thhKUhVJwJ1Zcj1HRC+K1z7mXZv8Yb9Gdxi4Mbc4c2Bx7Eex1mMrs2 pCJg== 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 j18si2410743lji.101.2019.02.18.00.21.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 00:21:11 -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 1gveAe-0007pn-M3; Mon, 18 Feb 2019 11:21:00 +0300 Subject: [PATCH v3 3/4] mm: Remove pages_to_free argument of move_active_pages_to_lru() From: Kirill Tkhai To: akpm@linux-foundation.org, daniel.m.jordan@oracle.com, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 18 Feb 2019 11:21:00 +0300 Message-ID: <155047806056.13111.495183724111676749.stgit@localhost.localdomain> In-Reply-To: <155047790692.13111.18025172438615659583.stgit@localhost.localdomain> References: <155047790692.13111.18025172438615659583.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 Reviewed-by: Daniel Jordan v2: Fix comment spelling. --- mm/vmscan.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 8d7d55e71511..656a9b5af2a4 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 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 Mon Feb 18 08:21: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: 10817469 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 3231413A4 for ; Mon, 18 Feb 2019 08:21:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F0092A35C for ; Mon, 18 Feb 2019 08:21:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 130EA2A366; Mon, 18 Feb 2019 08:21:19 +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 60E982A35C for ; Mon, 18 Feb 2019 08:21:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27D768E0008; Mon, 18 Feb 2019 03:21:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 18F498E0001; Mon, 18 Feb 2019 03:21:16 -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 F23BA8E0008; Mon, 18 Feb 2019 03:21:15 -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 7ED5D8E0001 for ; Mon, 18 Feb 2019 03:21:15 -0500 (EST) Received: by mail-lj1-f197.google.com with SMTP id w16-v6so3237269ljw.6 for ; Mon, 18 Feb 2019 00:21:15 -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=AtemCwdeLG1Nam5mqgEFvhwIWzJZyCew+qz/C63f2pE=; b=QufwhPH+af5TzK4bOokPRdtODWuLujIMjdCfACe/yGoKq9HKyrRYMm/Z5xyDWZcZBj km74a29pjnnNBZzZxMWvqW4XVyLumXQmuHzmrL/XjKSNqM7FN6lXcr/Jlj3G83RzMoXa LqOS4JFbz+XZsjF6Fbm0isN0GL3YUzeWOugkjgL2rHmvKFRcttD+HKo8cxwzC0uSzMVN 5A4GD5QPemMSjRwd42nggGocxE0mI8NQmPBfZFtxSshq+msz9YtihQZXdVMJrTMrDqDJ 0lR08qXnkah7/7Db9M3jaqrO0PJNh79cBcwfsTeNb8xpLOZQ6C74rrVQzn3Q4XZP5tqb QxXA== 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: AHQUAuYdwSrg9IVL/QTR9X9dL61ArC+xwqOn9qQ/cmPjtOp/NyCltbls Wke0nPUFoNc2pwj7C+EMhg7aS5wdcUNQWxxQQpOlEhCyqhbpwDvrbmJPaAfI8dt79aqr518HsQa IhwVt9IT1QBKi4s+oN/Eb5UfOtstGvLSBrc0eL2FpdAf+f3JL/7GZl0XoBBcdD94SwQ== X-Received: by 2002:a19:4847:: with SMTP id v68mr12781449lfa.136.1550478074825; Mon, 18 Feb 2019 00:21:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IbTQk6jZgXArSAknBPzSKQB2HMqWfWb9Kaa0Z4d6zcOdbb2A4qg11Kn/bldbgR3Kgil+pyU X-Received: by 2002:a19:4847:: with SMTP id v68mr12781389lfa.136.1550478073315; Mon, 18 Feb 2019 00:21:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550478073; cv=none; d=google.com; s=arc-20160816; b=ETO7GSi0BE9yG6c+/as7g/oQMMIffJ/s5pk3zszrtDrf3fSIkYRr+AFmlK3XJxXQLe Fw6U2tiDtpKyR2jMoF83Soh+zWgqF+aLbgE3m6+09nbD0z26mcJ2qw9CTwBiB2gP9VkM 4OG+T15uCWoZMtWcbts/H28JhZrwGdyN5ILxMGH2RDV1PwGXAvcptRo+K4q+z1N6/0lV 9S8p7bAExfp1vQEwdZxdUuHc2pbrgfAxLaZAPVTt4QEiduOvRz+4JxZAZotsIGATSq2A ehXHhk7wNtYgcmwRyd/bbzBU525Ti+s8eDSUSkdqj+GNey6TGsVyjFAzTp3N7zp0CEfN 6ipQ== 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=AtemCwdeLG1Nam5mqgEFvhwIWzJZyCew+qz/C63f2pE=; b=tiYw0Gyipt7tlSJEzMmPTidgBX9RGD7hdOBqyl0jbULG2T70DYmiN4JmZPcac+zjN0 GzUsR2m5dprYf1/99pC4YHzzLPjM3r4Gch6cnn0ZR1mTQW4JDP+Zi9b5KnDI0zAC3h3W iLUAcwjzahWIK0+vAjQI0u2cEDB4JBpyGFgE3i7F0+MARXTfhfbGVG1wbm2UPI+2SslC 1pdmOnjxxtN1+lP2nP3FTjwbHVwWSxJ/osI32IzYAv1SGE3c0Qc47mSG6yWFr3AI5Yrz 2FVDb1ap9JKECbP+LINNwA7qgGuHOYACu6MXnhjzplLozoCMWvZiza32NwdL4gofTe6v 89cQ== 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 k76si10959931lfg.12.2019.02.18.00.21.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Feb 2019 00:21:13 -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 1gveAj-0007pv-S6; Mon, 18 Feb 2019 11:21:05 +0300 Subject: [PATCH v3 4/4] mm: Generalize putback scan functions From: Kirill Tkhai To: akpm@linux-foundation.org, daniel.m.jordan@oracle.com, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 18 Feb 2019 11:21:05 +0300 Message-ID: <155047806576.13111.9663490902206172043.stgit@localhost.localdomain> In-Reply-To: <155047790692.13111.18025172438615659583.stgit@localhost.localdomain> References: <155047790692.13111.18025172438615659583.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 Note, that now we are checking for !page_evictable() coming from shrink_active_list(), which shouldn't change any behavior since that path works with evictable pages only. Signed-off-by: Kirill Tkhai Reviewed-by: Daniel Jordan v3: Replace list_del_init() with list_del() v2: Move VM_BUG_ON() up. --- mm/vmscan.c | 122 +++++++++++++++++++---------------------------------------- 1 file changed, 40 insertions(+), 82 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 656a9b5af2a4..5647727919bc 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; - + 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); - 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 in l_active list */ list_splice(&l_inactive, &l_active);