From patchwork Thu Feb 14 10:35:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10812327 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 B375C922 for ; Thu, 14 Feb 2019 10:35:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A02E82D09F for ; Thu, 14 Feb 2019 10:35:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 944072D564; Thu, 14 Feb 2019 10:35:32 +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 DCBAF2D563 for ; Thu, 14 Feb 2019 10:35:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C66E18E0003; Thu, 14 Feb 2019 05:35:30 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BECA78E0001; Thu, 14 Feb 2019 05:35:30 -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 ADEA88E0003; Thu, 14 Feb 2019 05:35:30 -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 4108C8E0001 for ; Thu, 14 Feb 2019 05:35:30 -0500 (EST) Received: by mail-lf1-f72.google.com with SMTP id i203so558733lfg.10 for ; Thu, 14 Feb 2019 02:35:30 -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=CAV5JrJk5VzPBdBegT7Rv/NudD3qrGSx97JRxyoZycw=; b=Zd51afL3BwggL32W0ERQ/fJ7EYS9wejpY4l0apYY8KBCMFa703Vcp/gmOqYs3NuM8J jYYEbe6gRqD6l4KVS8IUqKcp6SkBujn99Jmh73T49psNEYr7VfcZBWsnWr1NxMklAgVW WFBSAwHa6FgCAMkIYmXDQsAzi2sc1sJdA3TwKFxavmMexneDq6McjAJ+0nRZjPhCTlx/ jbic94V6J1NQbpcb96lmUnJajSILFiJOR1fYbCxEMOSIWNpafL41zHoI/zlq+J6ILz9Q 8Z/ixYJ9mnsQS7lsLePw9jtLayll0EFN8HqtTVwy8p0B878mpdd5+3zJsuCsl7CPMOUu R0aA== 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: AHQUAuZuQ+OkK7ZCoT6iHDH5tGnuQXsPuvQPlUtWmkCXjx5kYuSJzR1J 7DuMYEzjtWQhdIoewQz4suEzhZoIFLCCn2Gyu8JvhamHL6/A4YK7BZ9y+8iq0c4pwSRqm9hJH/I jYTQun4f/d8Ja9oB60aZrk64KuuXuWocKiQ+o+febu7AbxCnfnUkJdwI8ujZ3I7CFvQ== X-Received: by 2002:a19:384c:: with SMTP id d12mr1808640lfj.105.1550140529562; Thu, 14 Feb 2019 02:35:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IZDgYvH950Y+J50nJYp5TpqsUK8EiPLN3WtHeNlGpFuglTK/Brs14hRl+XhoZM0NerejXot X-Received: by 2002:a19:384c:: with SMTP id d12mr1808591lfj.105.1550140528370; Thu, 14 Feb 2019 02:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550140528; cv=none; d=google.com; s=arc-20160816; b=Vnu7Xxy/+G1RjCQ5v2zJi7ItW3DAPS9IuOn/vMET/jo/CX+PY7weD4X9f6U9h5UBpk For4pMl+Q7krcAX78SKm5aN4g6V1g9RND8E6na8cNPMy8DYO7mwckvM3uoX1njZvPPq5 +JJ7daIw0gtibEwd0jA1IzZQ+jfGeOF0RxIC9eKVKri4jWFCR51laoPrALc3uOaYqeg3 R6DaGkxy8RtvOJQwC0ug8deMUWeWSWkWyuXJtKemn6TTgnWzO9rQ8os5Q2c/9cu5uaFr GT2EY+YpePPs1G4LVWW2EzGHycz0q89cgTG5gLygKIh8J8orqahuxFnjP6LOJp6Xjak2 M4zQ== 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=CAV5JrJk5VzPBdBegT7Rv/NudD3qrGSx97JRxyoZycw=; b=jihZ49HPHzAbikP3HssN/ub/pWPhRMHKnmsYtBX8ZR+6lAbA+AsOnEx3yuOhEXF3lI cxqrzEHPfPaB4JrNAnKVPXNxA1vQ8b8VatYj/R96yqlw+jE4XzDkvlkNq1K2JpTqcMwr S0es1HT0yeSodWKvxfM7RkYCytQJnI0GfcCP2YZO9+z9t4Rz6jXHZ+SzazhlrjQcptJk dW5jCmvJ7a+qXwxSM69/TG6uSsBFhs+PFijYuqk3qip140VUtkmvRBY7zPBHzBOKYWLM B0R3h7SDkVKlYsi6H5DdPSIU8T7f6+4m4OYv1VpeZnW4Wba44PzalDVJTej8+PJJuC+E awOQ== 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 v13si1823863lfd.11.2019.02.14.02.35.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:35:28 -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 1guEMT-000532-Ia; Thu, 14 Feb 2019 13:35:21 +0300 Subject: [PATCH v2 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: Thu, 14 Feb 2019 13:35:21 +0300 Message-ID: <155014052145.28944.16497030123804725057.stgit@localhost.localdomain> In-Reply-To: <155014039859.28944.1726860521114076369.stgit@localhost.localdomain> References: <155014039859.28944.1726860521114076369.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 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 Thu Feb 14 10:35:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10812329 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 31C3513A4 for ; Thu, 14 Feb 2019 10:35:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E8742D09F for ; Thu, 14 Feb 2019 10:35:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12D8D2D564; Thu, 14 Feb 2019 10:35:36 +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 A9EDA2D09F for ; Thu, 14 Feb 2019 10:35:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D03E8E0004; Thu, 14 Feb 2019 05:35:34 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 757EC8E0001; Thu, 14 Feb 2019 05:35:34 -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 6481C8E0004; Thu, 14 Feb 2019 05:35:34 -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 ECE9A8E0001 for ; Thu, 14 Feb 2019 05:35:33 -0500 (EST) Received: by mail-lj1-f197.google.com with SMTP id p86-v6so1493725lja.2 for ; Thu, 14 Feb 2019 02:35:33 -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=mMg/AVqtFcnKMYwe/4ygFWWdKEl+mZxjuAXpdgR0ndU=; b=Y4M7aZFLX6GH+CQTWasrshtkDGXbcn+oDU2OWqnLCj+4LefyYhgLbKErDtxYWnLk4h K/a0Y/av59zDabMOLM8j6kwPN263S3deDqwWB2GmqM9mVguSUOV5Du7fYMFmpp2FwC3J YA6mIrrgLpyUNjNyBUv4NYD5Q4Y067fvfPYDmW+w5I22LJp/phwlfeyRnDoCrbIMQwUb vJBg6TntioE2BJc2/0sZgY2Kksycge2TB7xiWr3cDtYNtdnz/HWoREqKl7OgoH2fbLRx ikSieI0UMjlN1VUUWFw6idntb8jlcShYevoOUHbBlikoocRhETMz7rNEBY1tZkM3YZg1 Xwjw== 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: AHQUAuZdjBnaSSvDhbXY1KL0qxt4HxluJA2pIUv5cpw0YOfQe4ny6qhL H5yDVcfa3yTAYtQ08+NhVsflEK1t4IT4YQabbiFJ5e2PXeQokLw56NO0V41Ec1dx4e5kryWwOYI yP5de9s55+d4qtd86Ut7cN0JPSETpFrV+fXaXPknZiAwRHEFBd9LqIlSj1Ko0rnbjIA== X-Received: by 2002:a2e:81a:: with SMTP id 26-v6mr1940659lji.14.1550140533374; Thu, 14 Feb 2019 02:35:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IYrdfmnto5tW1APtQL+l+SEwD7+xSc8IQe7dqZ7YAoNtLTq3lCgx7FVP+jzXta73FMygUBc X-Received: by 2002:a2e:81a:: with SMTP id 26-v6mr1940618lji.14.1550140532439; Thu, 14 Feb 2019 02:35:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550140532; cv=none; d=google.com; s=arc-20160816; b=cWuStyvWoUn7JQtaj0DOLvdwXwolZq0TDT+OClIXtPuvBVjFegxVkyR9mu4Db2luXV 8MNxJoYbTTDjphaj2Mw6VpWitGouWD7GjiR2KJaNAwIL1TADZAGlbcInswyr2dSo4tvh EYxOeScz8FwwkSpEpMttMMVNz24rJpsPDk/cNf2mczIdCScLA6lTupaYxPf3vwShtA7Q id9fKzFtpeDBTZRasbhf+0ES3Knr2jpVmPsdWbyrOiJiI7uBGc0rEf9j+W3FO8U/Ry8h ZQFtjaWRH+4fMDK1gNngyukjwHUHFyF3VrjJP20UoowxMILSGVeWSErMbGthaokPM3Tg hjyQ== 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=mMg/AVqtFcnKMYwe/4ygFWWdKEl+mZxjuAXpdgR0ndU=; b=0NY7a7bROsJoFqG2YIqOXp88CAPeLxVNgenZVz3r2MSKXBrQh9iRrIkBDaxo7vL/L1 sdxiY74X2a8Y7XlbPRSdo45dkBYDOBpKBf93dE5EDqszSjaDSXdeD7QpauXETxgdWN0M 780LrnzkjO/C1pnLOL8Pkz4pyR0Ib7aqRso2w9ki/oEtgMThgTTzWDZiC/FP+xE50fZf /aCHuUuyj92gKjSKhhRodurLfoywqd8yPnvoik/FlZ45yb64O3jyCwj7LGsOIf6Wm5O4 aOiGap0cRVXhlqhxMG+8fmhsq9hiiu/QGqyHAjQP8FSqVP1DBf63gQ4x9g6CuZ94ex4+ WbMg== 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 9-v6si1720603lji.166.2019.02.14.02.35.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:35:32 -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 1guEMY-00053G-Sm; Thu, 14 Feb 2019 13:35:26 +0300 Subject: [PATCH v2 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: Thu, 14 Feb 2019 13:35:26 +0300 Message-ID: <155014052676.28944.12905432053578390912.stgit@localhost.localdomain> In-Reply-To: <155014039859.28944.1726860521114076369.stgit@localhost.localdomain> References: <155014039859.28944.1726860521114076369.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 Thu Feb 14 10:35:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10812331 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 AE1F713A4 for ; Thu, 14 Feb 2019 10:35:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC5E2D09F for ; Thu, 14 Feb 2019 10:35:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FD3C2D564; Thu, 14 Feb 2019 10:35:42 +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 2BECC2D09F for ; Thu, 14 Feb 2019 10:35:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29F3A8E0005; Thu, 14 Feb 2019 05:35:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 24FC18E0001; Thu, 14 Feb 2019 05:35:41 -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 1666D8E0005; Thu, 14 Feb 2019 05:35:41 -0500 (EST) 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 A010F8E0001 for ; Thu, 14 Feb 2019 05:35:40 -0500 (EST) Received: by mail-lj1-f198.google.com with SMTP id u13so397733ljj.13 for ; Thu, 14 Feb 2019 02:35:40 -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=0f9owyR/NSRzC8ViUPOE6sLF6LKi2n+ogoDsLA3wDhs=; b=SkJs/6Erenq2jX176t3IdgGXVywbbYzMdq9Gukc0e1raKaWsYJGzURslyK3/PWXIc3 F0+luF8/G8AGesDMnuCcYqG/T3SFhu2cx4KC/vwG1j3qhLIR8DU029mcqg7/ncSy4eVb KM1ovB3Om8P+s5rdHUzrTL07qAUeyTSUR4vk6VMKc9kpCO5zTzfkCXwvcfiSoaHaZJ+M ECofAHBmSxEvjrLX6cRMDWo/7pyjUqDmeV0T3UqLPD66Gx+Hc5TG//viCuaU6oEqZ4Ru u1FVD4fURhxsRz1Ozugu4K0QdIlM0asQtX2luXJcONqebrJDkwoyhWF2ChS7kFr4AwqQ 7YWQ== 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: AHQUAubjtrPKTMiLdAohWuP+elP8Qnt1CwCSfPA45aVL0yROoKnAoVmh fmR4WtItNz2CaUuoE4lRBsU0LV/0RSzHJv4F1ToKaq1+9but4BoR05qiBHdYfPeKAEH381ANoJm XyuKU2l8+jIuglgfJsyaoFY0NBjcwWU2gJYUJ1cu+Kiw65629MqAyFyAiMs3GIhN5CQ== X-Received: by 2002:a2e:9e46:: with SMTP id g6-v6mr1935567ljk.52.1550140539999; Thu, 14 Feb 2019 02:35:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ6FNcaYoF9jig6IRDVPQMoQS5/vWGi0NEg4hEDbkgvvsEVvn0THydxER3Rp0Xyrs8mfhKQ X-Received: by 2002:a2e:9e46:: with SMTP id g6-v6mr1935508ljk.52.1550140538741; Thu, 14 Feb 2019 02:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550140538; cv=none; d=google.com; s=arc-20160816; b=Ee7Ay4NBJTfh9PI6RVqwZJ5xAdZX28sivu0k7gmU1NrUgSGY9V9OJEERph97OVJeqS mLMFHX9E59aiYtDqlUISv5EOtPBRLtd+JA2GHvNb9HvWvRhK3enn9QD4Z9Mc9I0urGKL Wp6QlOte9o90g3slTDeRBArWGyI8zsOsIzbFvcHBfimrrnNiitBAduKk0LO5tU6qEXvj +ijEARzGEjAJ1lxmcIqM8RWS52dky2u/6h2gPUvLP/CS9ftmnCESKCxBisrPFZfxF4zI Lv/gEZXKcIxcCT5hT1yy5sOILf0EUab58TJ4uZ/7Jz2GRAyKfHniUxKnfGhEl83QL4WI hFSQ== 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=0f9owyR/NSRzC8ViUPOE6sLF6LKi2n+ogoDsLA3wDhs=; b=iKslmxJhhO5mZlh5pcJK5Gh+wPNNs86haV/uccAMFlp1/DIzPkTIjn3VeUiiZK76yp 2SLhlIVvuaznwY+Dc7qff0Fgzfa+x4PTGjPn0F+jIbSUxIvKC/nowDLwAKu3pPT4v9C9 J7YNUUQiJ++Bo4oM6uA+t9wUW9Q1K3Y/VPDU7v3y2FibYhWt5x9EXZgF24nqpD4H7hzz mJM4U9Ui+uTzh51FuOo1T103MUO4FasN66IVTexvm9NXr0KX1UVtIPA+DNhLmH2h+zHh 9rv2EuHhZrDI2Sq+qCZK7qcaCpn8qjFNsiYA7DzeQfm6DmZSR2sIvQYC9xnsq39+V5aD EZPA== 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 f26si1741352lfk.147.2019.02.14.02.35.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:35:38 -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 1guEMe-00053T-5r; Thu, 14 Feb 2019 13:35:32 +0300 Subject: [PATCH v2 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: Thu, 14 Feb 2019 13:35:32 +0300 Message-ID: <155014053202.28944.16316170128712977883.stgit@localhost.localdomain> In-Reply-To: <155014039859.28944.1726860521114076369.stgit@localhost.localdomain> References: <155014039859.28944.1726860521114076369.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 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 Thu Feb 14 10:35:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10812333 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 D4EF0922 for ; Thu, 14 Feb 2019 10:35:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1C6D2D563 for ; Thu, 14 Feb 2019 10:35:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B67752D566; Thu, 14 Feb 2019 10:35:48 +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 0957D2D564 for ; Thu, 14 Feb 2019 10:35:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F240E8E0006; Thu, 14 Feb 2019 05:35:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ED3168E0001; Thu, 14 Feb 2019 05:35:46 -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 D9B068E0006; Thu, 14 Feb 2019 05:35:46 -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 6C1628E0001 for ; Thu, 14 Feb 2019 05:35:46 -0500 (EST) Received: by mail-lf1-f72.google.com with SMTP id d6so561075lfk.1 for ; Thu, 14 Feb 2019 02:35:46 -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=p1qhfuMaoIfxu/+MYQ1eQD2AAYZso25tEhR+PZU2LMA=; b=HCHL75QjJN22RENxgsYNW1OPOJJnINh+62iU9xmLx+/8Ubl8VOwMh19VgpPtGrAVMj BkPzw+9UYLSZsQiEzyB4yGUoqQjYCWOY9LOrHnYYY1MaahxSewbPk2afrrbgh4Mb0YfX zLjv5CTLkon1aXIopgF7LPC5VneqaZdGX8R8X78MSnlIUQN/iCddRnkHhp2nmMU+6PRu U3bEikI8a5jUd0eeDiQ87H6lLA0PhniEdCKVmrGfK1JvLAG6d4L8Qmx0nY0G9KozHeAt jRjAEQdpcQ1kZBEKrcpPtcuNN5gsIXJLVMAPfEtrTAGTnjomvyNX8QU5c7wt0EmET3pE DVEQ== 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: AHQUAubmvKvf/mw0aSxNRixGL4062ruT4feKJVOYmT8UGYfoR6CfQLBe J5wHlEIW6FRggQQm239NgA+4coWVFQTFiPf6hjZVSUwFSpyCiu5O9lgFbjO/7p7fi8ELUjKgnHb AD5NyyzyITsujZoKz9O/K4X+ktMcUZ6Ev/A3zBPQh8y3bcTJTGikNouSnMCclberDfg== X-Received: by 2002:a2e:7614:: with SMTP id r20-v6mr1910802ljc.175.1550140545799; Thu, 14 Feb 2019 02:35:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IZwJUbsG2T+Jp+iz1sqKj2r5rf0gpn/R85Kz1mB+CZ6PocqxUPLwF9yjnJYOM+NYejSKdz1 X-Received: by 2002:a2e:7614:: with SMTP id r20-v6mr1910736ljc.175.1550140544470; Thu, 14 Feb 2019 02:35:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550140544; cv=none; d=google.com; s=arc-20160816; b=WZZj+u6eoROe4tICY2fofENvnemqQeHaQmAAtp4EK2Iqga/qMK+0hB0jPtkooz+Tbm rv3sTcMXyVe1DsnXRH7HQhemmyNNfCfu4m4YHIaHBh9W7ACZ1Iyak+yhXe5orbkHjgXf gV1d2/LbQvXAbHOB81sxM1HczyVSATIwb519g+8qOa+A8g6Nh6TMtoRYxdD2BV+oPvZ7 MMKLI6qDk3knJludkrvqRhrlu0oCRVQQ6mc/Q3HG7dXB0wMurYTwn4kiTYxFlDiI9baz ZiOprto7BajCwg9XCdW1nqyQ9Yctw5j0IEv5SFV7BJRpdZlWAO5te1o7VFvVXcbfNX3t igtw== 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=p1qhfuMaoIfxu/+MYQ1eQD2AAYZso25tEhR+PZU2LMA=; b=Mt1iA3cGyeXWZtMXjSVDKOykPQlLaWIwa7F6yIjpzp+cVKXpuCyV/y7f+r+sHudTG1 3JX7FpP3wC/Vwpbgly0EcP8iBK1h2syE9pm/w3kU/MIweXmaaYdhN32OApvB7TJSfPaF xIGB4VaxLHeYdl9HUIKEeCr3nad86/kw4UpNxTQHQp7ASknHv/Jd+IZeoHGG4OgN/zlK W9QcoluvVROGQiv8nZ2vf8+Io/J8S4AVY/5Tvd/ciUK2Piqww7oCpqed+gVkhFqwE6kn L/Y8tPrki700yEiYeUM5Hg2bBijMPUddqmk1OlugfIP3QJ4Wto/HfTAlChkU6wbp/2Do ypJQ== 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 s191si1914141lfs.9.2019.02.14.02.35.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:35:44 -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 1guEMj-00053m-CT; Thu, 14 Feb 2019 13:35:37 +0300 Subject: [PATCH v2 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: Thu, 14 Feb 2019 13:35:37 +0300 Message-ID: <155014053725.28944.7960592286711533914.stgit@localhost.localdomain> In-Reply-To: <155014039859.28944.1726860521114076369.stgit@localhost.localdomain> References: <155014039859.28944.1726860521114076369.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 v2: Move VM_BUG_ON() up. Reviewed-by: Daniel Jordan --- mm/vmscan.c | 122 +++++++++++++++++++---------------------------------------- 1 file changed, 40 insertions(+), 82 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 656a9b5af2a4..fcec2385dda2 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_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); 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);