From patchwork Mon Mar 18 09:27:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10857033 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 D0996139A for ; Mon, 18 Mar 2019 09:28:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF167292C0 for ; Mon, 18 Mar 2019 09:28:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2D13292F7; Mon, 18 Mar 2019 09:28:11 +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 50808292C0 for ; Mon, 18 Mar 2019 09:28:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99C146B0006; Mon, 18 Mar 2019 05:28:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 949F16B0007; Mon, 18 Mar 2019 05:28:08 -0400 (EDT) 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 7A0CF6B0008; Mon, 18 Mar 2019 05:28:08 -0400 (EDT) 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 0A8A16B0006 for ; Mon, 18 Mar 2019 05:28:08 -0400 (EDT) Received: by mail-lj1-f200.google.com with SMTP id m1so4254997ljg.8 for ; Mon, 18 Mar 2019 02:28:07 -0700 (PDT) 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=FX0gVhFldv7yNZHPcrpb+JGxeafUZWLGZiFUUsr4fhk=; b=Y8SJwakA8Tk5yPKAx6aIGqsPLp/WzynQyyKgKffWDCe73gXr7uVC5oUL/dZfM34oaX MPHq+2HKgm/7VGJ6RtOYLyiE1geoJkH/GkAWzO0LU6nUFHpUWbg5wR7UUa8PrSzvkjWk S+rL5iHt/WOTlVGPHYrZkj1v1CUNNs3cQF+A2ZUaHBmkSKLai0Bp2vrSfKJaaxCtTKA2 6jWNpMVZkyXfoV7Cdz+Ne0Fd0Mp4pUZtshXPrKYIxS77Cqq6OKH619KsMj2uCbDP3aUJ ltJx1QObxpuAHsylHIpJPlQtVoJIjr2Gd6MkwiUXOL509PalFad0nBE1k2OXYsyaGRRQ VhPw== 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: APjAAAVR6otBcxuClsowSmolJ0W7Wr59ZPNY8MvJ/z2yEEpiQQr7MNf2 mFMnL3F6nTarES0+Mz8CkrAAHZMpo/r4piX+6Zy5tgJ7ExnYjyqBPQPPXhGyB0ZynlyatFFKDcM /BhXWx/n0kA9aYEYB+xGtQ+9P5VnhArFJVc5e2iY9c3pSqZ4pcwZnOKvieKCg6dNCUg== X-Received: by 2002:a2e:9a95:: with SMTP id p21mr9309905lji.127.1552901287301; Mon, 18 Mar 2019 02:28:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFdO7qL6ZKAQaPzPQrMe84cmXleX/F7ZPpSb49veKm4RmtK6/tJUGk8X9pJtIMGuJMTCcV X-Received: by 2002:a2e:9a95:: with SMTP id p21mr9309859lji.127.1552901286135; Mon, 18 Mar 2019 02:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901286; cv=none; d=google.com; s=arc-20160816; b=RK47/sJyYkvRXcQgQnBJ1QhukpFarwuwcxjPPCbbebrhlsrxdjfieHOUT3CC6XWQ2+ 8zhL51zVgpbcmW3laRJaoTru3dd71hes8rr6dov+43BDRS9nVUbYKnepkln6wg89vQC3 vFJyufZHtCPFrAOFNjxtqzEaup2Llosn2b3DzVr5JztJEkfYTjrnR6+WE3NkSq9tPKBa rtOoyEySaa2q0pyux9ottUtipBUbfYTuJM5MboXLKsYRU+3G69+fFfhUTxmex5Nd7V2s DzpROqHIx5Rcs3IY7P0RA/Wv2ylu+zq6LSDKRNe+7qC25953e1VGhqB54ZSXTFlMwPIo /BbA== 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=FX0gVhFldv7yNZHPcrpb+JGxeafUZWLGZiFUUsr4fhk=; b=N5yshPCEQS6T9JQ3wFjPFA1HoZAHW/1kbxYQMuLjolzI7UqJGqWBRzHUpO/0bpaI+Y lBG96x1HpoJul3AqLlqy151l60fJ79RBPHEPjC0BZ0YUq3Pyk8ShtdXzrWVPgqWqaSlH 1thkvROSVhW2cSeQJoq9kIEz3W5+SCnTxyF8ViLm5QYqAUChLN5i1E/yWaXzJ6FE2qSc y5MxVgrlUxiBc1LouQd60GKQg4YPuTUceKjCDkkqq0d+thc6i7MY1c8vcwO2YJmMgCLx SqKWKtP0q8RpbgUr1BWMgaxcQG5AAeUV4hxadAHnmxfeDFzjm0FuysFUzhXH+81ukCdg zx1g== 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 c10si6773174lfh.71.2019.03.18.02.28.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 02:28:06 -0700 (PDT) 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 1h5oYp-000553-Tz; Mon, 18 Mar 2019 12:27:59 +0300 Subject: [PATCH REBASED 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 Mar 2019 12:27:59 +0300 Message-ID: <155290127956.31489.3393586616054413298.stgit@localhost.localdomain> In-Reply-To: <155290113594.31489.16711525148390601318.stgit@localhost.localdomain> References: <155290113594.31489.16711525148390601318.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 07f74e9507b6..e610737b36df 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 Mar 18 09:28: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: 10857035 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 C293C139A for ; Mon, 18 Mar 2019 09:28:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A19A0292A2 for ; Mon, 18 Mar 2019 09:28:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95A2A292F6; Mon, 18 Mar 2019 09:28:14 +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 0E170292A2 for ; Mon, 18 Mar 2019 09:28:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04EC36B0007; Mon, 18 Mar 2019 05:28:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EEEB86B0008; Mon, 18 Mar 2019 05:28:12 -0400 (EDT) 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 DDFB46B000A; Mon, 18 Mar 2019 05:28:12 -0400 (EDT) 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 785FF6B0007 for ; Mon, 18 Mar 2019 05:28:12 -0400 (EDT) Received: by mail-lj1-f200.google.com with SMTP id 28so514311ljv.14 for ; Mon, 18 Mar 2019 02:28:12 -0700 (PDT) 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=ZQqLxxNSiNaN6i8+GsS7rp+8ipVxb8cl6tZ4lbzG+3o=; b=kDlK5vYSAQyOLojOvZCBW1Ieet6vLLHxCx1jniiiin/1LeASLwotrppUr8kMl9BpSu j7NFnf8m/S1JJGGVrO11xZRxU5tGYBJ+4N0DS1oE++brnxF2dX62e9XiKVsr/bB87/+7 vEzODED4PsEl03tu5bvnLjZIVdW8viU6muNCgsiv4G5ekYRFzkGCHNoFRj7M6G0CPXxM rEdypzj+SQ+F+pY6qZI6YStGYMCRqTHEcatP3Ll1fPjsHIhARK2alBCJRKm1K0WzCPyH zzHOelkxwLh25x7m8m6sUZCV92XGrW9Ndc4j0Gv6z4w1SnTJbfgAeOs7fpD0QRuQLd7F sBLA== 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: APjAAAWFi7z0wssQfuFksZvlw9NnrZ5D6XjwBv3ViuXLF8VvgZpe3/Eg 2Tv81ArAs3Ju+eTGy8LpGS6KBCKlLoW97gSLv0BQJhPVkmWYleLuihuPaXBW7zONfsHB1uRwDyu c/JdkMwifMR3G9BmZThGmUJCWhO8XblREH2pyMgEVbFAJ48H7Ke1007aEMrEiZaf9uQ== X-Received: by 2002:a19:968c:: with SMTP id y134mr1801174lfd.140.1552901291826; Mon, 18 Mar 2019 02:28:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOP83ImYmUSgX0a0JibEabExnl6C24czZwMQsl9okgEbJAiaI8VI+GpjsnT2xhEM7FEBla X-Received: by 2002:a19:968c:: with SMTP id y134mr1801135lfd.140.1552901290894; Mon, 18 Mar 2019 02:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901290; cv=none; d=google.com; s=arc-20160816; b=hUGBMt4JMg/wPOTHbFqTYqMwCjOE8O2O15wU13vrXQ19EGzl0j6ntNu9c363qTYXzk vpYt3gKTvfd3dptmSuTz8O0Xuv97W84j+0Vcgm1yCBl8Q9cnKCWrJWh8LKnG8S3qj0ud J+nXf9ZVKUfxAQs3Bp5PZG+PqshIDhGwAiQ84mAKXhxF8UGFGxLBmbrcfSXsMTfv1Zi4 Rzg1tbXUUwsIiPeucqEwHyRXLYlTS1bxTttDPnNbT4MyCeShk8k8skyD9KPfIo9k08GK oR8VbL43UdF7mzkAnJY33TAgJ10f9hG5ogCi+Ng2wH43lXAt0MAmnUFSvRnMVTFsFw2n Mylw== 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=ZQqLxxNSiNaN6i8+GsS7rp+8ipVxb8cl6tZ4lbzG+3o=; b=U7pKx3fO1mbh5wPGdm+MrYzOAwQBmPPXGbF/j3jx7x4NKuzxkDiHjjmBztOpzTSHGW OYLKhcc06nmxqkBE/ePUIcwHZQH9sAkzpj4R1vIOFAHJHdfnO72ZRyygjeq5Sba+D6a4 PHFQmn4W0SwdiB9yY3+oh4w7Qa8tD2cyFpDyKYiDxQPa/vqsTpnwR8SYKJLJIGjdRLJl Af2KFN5X/mVJXrQx5qEpELsDtldwf2LzgA/cNjoAmGI6vFBfvlGB6UVfA9hsNfL6R2m1 C3jR/2FuZ1LcXQsOY101C8iOdrjS9M+PHxfOx/DxME+8fvMFRjNELSuCz3l63Mzjsco+ V2MQ== 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 d187si7467545lfg.54.2019.03.18.02.28.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 02:28:10 -0700 (PDT) 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 1h5oYv-00055C-LZ; Mon, 18 Mar 2019 12:28:05 +0300 Subject: [PATCH REBASED 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 Mar 2019 12:28:05 +0300 Message-ID: <155290128498.31489.18250485448913338607.stgit@localhost.localdomain> In-Reply-To: <155290113594.31489.16711525148390601318.stgit@localhost.localdomain> References: <155290113594.31489.16711525148390601318.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 e610737b36df..d2adabe4457d 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 Mar 18 09:28:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10857037 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 CCFB46C2 for ; Mon, 18 Mar 2019 09:28:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9B5C292A2 for ; Mon, 18 Mar 2019 09:28:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DC65292F6; Mon, 18 Mar 2019 09:28:20 +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 2CE95292A2 for ; Mon, 18 Mar 2019 09:28:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 249946B0008; Mon, 18 Mar 2019 05:28:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1A7B86B000A; Mon, 18 Mar 2019 05:28:19 -0400 (EDT) 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 097CB6B000C; Mon, 18 Mar 2019 05:28:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by kanga.kvack.org (Postfix) with ESMTP id 98BF96B0008 for ; Mon, 18 Mar 2019 05:28:18 -0400 (EDT) Received: by mail-lj1-f198.google.com with SMTP id 6so4387lje.9 for ; Mon, 18 Mar 2019 02:28:18 -0700 (PDT) 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=mxNbg2U9QVpDsyt9B3ggL6erGUHadMnByeZtoBypyi4=; b=UmBN1SOBAzrAypt4GlthbnZ9DQ3YCY/BiTcaxNoVyqEiBrLvXGvJbEcbcFwigGi8DL X1fgnWHQ/s5nRpHQQuMl61WENWhz8bT3Kb3vvt5WiMEZOxK2fWMLksSWgsVhMfUW4pRN LEDvTs0R/EdG3pS77jHA/5W5+gqA1frMvzT1IbGYzAN1lPBPMvdB+Ne7gPabagCb79o7 zYZUfajTK5V+72uQ/l9/93iWzaog3DkJnh6XGO2DCLgCKEKBdD76BLU6cbTQZQNQQMZY vX/6otMimr8sfP2BkMdSTcR96FUW+U5kld3MtJSSk+b6Cdp0eo1R5R0Usw1u1hNzDggy YOEw== 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: APjAAAX2pOKIopJhwrEEVOZXzJ44B7kQnPK0CzhXTO+9Zzm9WRtzYVe9 4Z3CTI4eFrp4wAmUQ0IHqRepAvZs9LbkEGSI6pACRav65HeGxRTZd/zYVv+WKp3mTvAJ+DPFIgX 5wjo9gb4NFVmoRRbnrEJvt7Cdb2Yn+cOETjQBxPuHSt8Q/yxvEg8B7ZrUrsFgeMymVw== X-Received: by 2002:a2e:9e57:: with SMTP id g23mr6213727ljk.124.1552901297897; Mon, 18 Mar 2019 02:28:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTwuO7Eq6oPaoidt0hWl9uGQSr4DKGW8z3Kg3ZT3hY3hRt1LilvSx9Sj7HZMiWSZlokgqS X-Received: by 2002:a2e:9e57:: with SMTP id g23mr6213663ljk.124.1552901296260; Mon, 18 Mar 2019 02:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901296; cv=none; d=google.com; s=arc-20160816; b=uY4eUMwD4iQ/jvin7nfzsEOoeaLk4vLjwat0B2I5ZbkK0olobFb9/Y5XL98XH8/V0+ KQh+Lyuh14K92TkbricwO86Urh+eMzHBU8vBVahKJeXPRIBvjPwtlSZFeo6NQp7vC9T2 ahnHC7fDPSXSiWxSJrpXDlCIDrdIO+aUQtxVW3xoGXTSEpzfN6slLKn51OB9hLtAXXrz GZRw509Z7XfnEnis9u1KtxCLzc8gBsRRlkSuVy8w9lKhUTwpoQJ/LLweoxEixU9ExgSr itmsQJZRA/AtprdD4wYaVIvGNDLfi7/UBuHG/5Lt+oK18VmELpSIifm3uw1lr2cEw4IP MeAw== 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=mxNbg2U9QVpDsyt9B3ggL6erGUHadMnByeZtoBypyi4=; b=yKeSCfHB9GXqwzzY6d8ssJS5Tzx+JkGHM6jbN1nu/xsJyZTbDGG2/Zo1CFtywQOicU O48VsB94O9SsQGN+uXW2GkkJIW772Gb1g2733kUFdJWZDt5i6wkfBV8P6fSJBG382jay DqWl0lg7oo25dpjAUTAn3GZrq+ZWm4fymQr5v5a4n2JjVG3LFfGzHFjATvu9BSQOiAH4 B5ku8R79XrGAilV9BnMEUvG64lPhZxF3Gcb3kiYoYKZBecKa1OCoqK6rd30MXOx6E/Ye h4/pYkvF52DgAWxMGq7u08VSWxhKGzwyOPvQIfJaHozVYkZm0fl1KvLK0oAjxV2vuMpW SwVw== 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 1si7239935ljd.130.2019.03.18.02.28.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 02:28:16 -0700 (PDT) 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 1h5oZ1-00055N-4M; Mon, 18 Mar 2019 12:28:11 +0300 Subject: [PATCH REBASED 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 Mar 2019 12:28:10 +0300 Message-ID: <155290129079.31489.16180612694090502942.stgit@localhost.localdomain> In-Reply-To: <155290113594.31489.16711525148390601318.stgit@localhost.localdomain> References: <155290113594.31489.16711525148390601318.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 d2adabe4457d..1794ec7b21d8 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 Mar 18 09:28: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: 10857039 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 73E4F139A for ; Mon, 18 Mar 2019 09:28:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E9F6292A2 for ; Mon, 18 Mar 2019 09:28:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41BAF292F6; Mon, 18 Mar 2019 09:28:27 +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 817E5292A2 for ; Mon, 18 Mar 2019 09:28:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79EE56B000A; Mon, 18 Mar 2019 05:28:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 74EF56B000C; Mon, 18 Mar 2019 05:28:25 -0400 (EDT) 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 664B26B000D; Mon, 18 Mar 2019 05:28:25 -0400 (EDT) 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 F30986B000A for ; Mon, 18 Mar 2019 05:28:24 -0400 (EDT) Received: by mail-lf1-f72.google.com with SMTP id z187so1491695lfa.21 for ; Mon, 18 Mar 2019 02:28:24 -0700 (PDT) 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=JpABL/NJyXGgYckGkxEeeeHpNf9ZSEcd/+27GWn8BZM=; b=GtoPtMKYDkSwInvkUueAbo4kHq7qx8MBe/N/yRkz2/m2SNrc4nm+k83sgpIVqC+iiU MSTF5NymBixjFoQL8oPDZJJVUTSXz7piyECEhdyBWf1jcX5XfIYA48FRPlAzso+s7tWL Y/2Xl7WQ8V/f2GvPu2UTnCPtXTYVi2ed04yjj4QVZkhOgcv6ciSQD9VN4o22mUwVCY35 7b5gUw4xTvsW3hjnpBWSDjuMzQc1nAN+ZJW7dJKbb0Izg9VjhT2u79Ut51EBQe15gFYS 7jhnVxi9s10siXOcJhbBVdn9WUXP0TGlgDqfvYWuTpF1skJXakQYNfJ1uICXMrm1hoMC I4Kw== 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: APjAAAXXQuhm2XxptLLM6EvTIb5PcXR4vnRnYi7HOJXFPlnY0GAUGs01 9DYq495o/8S2btybjsy7dAUpH4rExA6QJJlyD2apwXkZ8AIOW0NwaEYB84+Bno2kX9WPdt0RfV7 e5icbFz4kzH5VpLR7aeNkzMmU5OWSuxBlKb8yoYG1bmrgHx+P7zqMMxcoqL1XFXHqiA== X-Received: by 2002:a2e:9154:: with SMTP id q20mr89012ljg.30.1552901304244; Mon, 18 Mar 2019 02:28:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOWUpMAzWUOhaUe3hOrTjFCJ4GttHDK/UrfihDrI7vc5Aeg8xoUJ9YlhveQTN3PuOGxYps X-Received: by 2002:a2e:9154:: with SMTP id q20mr88965ljg.30.1552901303006; Mon, 18 Mar 2019 02:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901303; cv=none; d=google.com; s=arc-20160816; b=Y/+X5OsNAZ7Jzmiv8DnBxea8yTvuIoSTm5KjMCYYkJdLAXwottYHCQlbRpxziFoYiL r1sX4+rqd+L+BPQtE5CfPO7hj4nsRzQpBBVrn4kDGIqTUolbb9ZaLFfWSdUDq0xpjC9K 8JdFGowHcQ9rCJIoxt9uztvG1kuzua6BiQ/9w8aTecnENv4v+8aWCsUxzuadiLwpgxRU SD5QdvOoIDE6Mz9Ql2mkf0vAqdI7pGmA1hzE0BRaFWxnVV046eQcFidjFCxn7r8xBDN1 JarfQ/qZTBmCXbhcue9LN6+Wqaj59RlqIzrVdkx4iO+hxR77KS49qzzlSV4Bcc/ZjKU0 z2oQ== 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=JpABL/NJyXGgYckGkxEeeeHpNf9ZSEcd/+27GWn8BZM=; b=xlMC5/oNTwir+ymC8LT4dRU4CsL53cHejExKwqflRDO9WI0qTOCQPnS4GqoybSwNdh HLNkXzdbL72vh4ZkpKErVLBWIvCaQUI0gWr4noU/DZdVxW4xqiVWD2s0fLZZcezdXamF cxh21WRKvjaU+EIE4+VODhKHbePawab70we37mxiirb+j+u2mhofw/J38Uawq80J627K 45nvItrMyO8MzePC4yWdY5PKy3r2cb4Vv4Au0PiipJogHpFNPT5YSxbksa5dYRB+ctPR 8zNIIcaAFi96g6Xtq84zi9VL1PAj25LNAv6eJa/SDaKtsDiDwaIjOcjn9SiA8oHP0z2i g6hg== 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 y22si7039779lji.93.2019.03.18.02.28.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 02:28:22 -0700 (PDT) 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 1h5oZ7-00055e-3U; Mon, 18 Mar 2019 12:28:17 +0300 Subject: [PATCH REBASED 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 Mar 2019 12:28:16 +0300 Message-ID: <155290129627.31489.8321971028677203248.stgit@localhost.localdomain> In-Reply-To: <155290113594.31489.16711525148390601318.stgit@localhost.localdomain> References: <155290113594.31489.16711525148390601318.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 1794ec7b21d8..f6b9b45f731d 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 pgdat->lru_lock across the whole operation. But if - * the pages are mapped, the processing is slow (page_referenced()) so we - * should drop pgdat->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);