From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D901C433DB for ; Sat, 13 Mar 2021 07:58:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D4EC364F1D for ; Sat, 13 Mar 2021 07:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4EC364F1D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 963B56B0072; Sat, 13 Mar 2021 02:58:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 917DC6B0073; Sat, 13 Mar 2021 02:58:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DDF06B0074; Sat, 13 Mar 2021 02:58:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 646676B0072 for ; Sat, 13 Mar 2021 02:58:04 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2548898A6 for ; Sat, 13 Mar 2021 07:58:04 +0000 (UTC) X-FDA: 77914097688.21.2879E5B Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf21.hostedemail.com (Postfix) with ESMTP id 6CF9DE009A79 for ; Sat, 13 Mar 2021 07:58:01 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id 6so32056594ybq.7 for ; Fri, 12 Mar 2021 23:58:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=773qLo/LiVz4n2L5CNuvuPAbdhL5vI+dQXWkGfq22YM=; b=s62F923cqY3HHxlJ4hYL4HxcRTUA1o1Vmr0HgcffuxiRKFFBC1czWP98NMUIxWHBf1 ZTyWeNYix1pSuyOzyeK0NFpxLIWOmX10rPMvqWp8DuHg1yJhrNIGNko3fZT0atoX3aT9 tvbuoR86gyhnQZ8eh7p7K/l32hNMDiL/9yg2skyWxrtzqXc2LkdkDBaiklyidpzGD9Xo glkEqmmHlh+PbMf1URYMZzEcs1zoLYSWmku5OQ0gpaw9yflCHjp7u8qrrfyCRliYK3I/ Tc+BFkGgrB7u8ficVc0QKkIHZrZFoWgOnbQ0s8MxrT5IfVlLG0WbP3MEYNuJZFSmG8zL SKVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=773qLo/LiVz4n2L5CNuvuPAbdhL5vI+dQXWkGfq22YM=; b=Ep5Y0mJGZnG5vgZYhyWRUtwcRYHRG8IjiTtUBmfUTPoWaxESn5FTXfMrLpW2LuaqkT hFOWWw2RE3XcxIKkClH26A2nNjplVG3xRxh49REQ8efX925FRPhCJNiSQHq772XO4esQ lUVKGAVZIbZY6wbHLoFtCK/XXhTSjh2fceLk1g7iymIEEBCMEqPzAwW1SHIqTF5rIU7F Ln+AfD5bKqRKbc03reA33wSjUqEXIh5S7d2GQbGtcYvvRCZ5fWXxNsP/XnXjwsINHmOu rLgpfGzSYvu2talMvH2K0O1eXA+RxufpNkI5jY61QB1KWswrKNIanP6JPmeVlUyHTaXA xfMw== X-Gm-Message-State: AOAM533JQ9WsgJJllsot5JK96n7TQ3m8pXv02D/7QP4Pcw5WnTf7X93e GO+SNytiCwv0nF+A7Y7UXYwocdARpUzuSpUTTtqhBMNrVbPoaAXtwglR22wkxXW8jzi6D+YEKPn X8asQ7YmPcqTknWVYaP7feN2te7D0KceqUiKRM4EUrnmcw91uft0aSBHi X-Google-Smtp-Source: ABdhPJyM3uGtugEuR+BtqyW7Pcf+QxhuRuUSNVC/LK4e6LJubLVomvaz1At1w7Vl14tsop0cWxsmMMW22Kg= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:f931:d3e4:faa0:4f74]) (user=yuzhao job=sendgmr) by 2002:a25:d84b:: with SMTP id p72mr22707445ybg.272.1615622282832; Fri, 12 Mar 2021 23:58:02 -0800 (PST) Date: Sat, 13 Mar 2021 00:57:38 -0700 In-Reply-To: <20210313075747.3781593-1-yuzhao@google.com> Message-Id: <20210313075747.3781593-6-yuzhao@google.com> Mime-Version: 1.0 References: <20210313075747.3781593-1-yuzhao@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v1 05/14] mm/swap.c: export activate_page() From: Yu Zhao To: linux-mm@kvack.org Cc: Alex Shi , Andrew Morton , Dave Hansen , Hillf Danton , Johannes Weiner , Joonsoo Kim , Matthew Wilcox , Mel Gorman , Michal Hocko , Roman Gushchin , Vlastimil Babka , Wei Yang , Yang Shi , Ying Huang , linux-kernel@vger.kernel.org, page-reclaim@google.com, Yu Zhao Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6CF9DE009A79 X-Stat-Signature: 7156xeixe3ozdo3cxar1fqbuddkq98pd Received-SPF: none (flex--yuzhao.bounces.google.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from="<3inBMYAYKCKUdZeMFTLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--yuzhao.bounces.google.com>"; helo=mail-yb1-f201.google.com; client-ip=209.85.219.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615622281-766122 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: Export activate_page(), which is a merger between the existing activate_page() and __lru_cache_activate_page(), so it can be used to activate pages that are already on lru or queued in lru_pvecs.lru_add. Signed-off-by: Yu Zhao --- include/linux/swap.h | 1 + mm/swap.c | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 4cc6ec3bf0ab..de2bbbf181ba 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -344,6 +344,7 @@ extern void lru_add_drain_cpu(int cpu); extern void lru_add_drain_cpu_zone(struct zone *zone); extern void lru_add_drain_all(void); extern void rotate_reclaimable_page(struct page *page); +extern void activate_page(struct page *page); extern void deactivate_file_page(struct page *page); extern void deactivate_page(struct page *page); extern void mark_page_lazyfree(struct page *page); diff --git a/mm/swap.c b/mm/swap.c index 31b844d4ed94..f20ed56ebbbf 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -334,7 +334,7 @@ static bool need_activate_page_drain(int cpu) return pagevec_count(&per_cpu(lru_pvecs.activate_page, cpu)) != 0; } -static void activate_page(struct page *page) +static void activate_page_on_lru(struct page *page) { page = compound_head(page); if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { @@ -354,7 +354,7 @@ static inline void activate_page_drain(int cpu) { } -static void activate_page(struct page *page) +static void activate_page_on_lru(struct page *page) { struct lruvec *lruvec; @@ -368,11 +368,22 @@ static void activate_page(struct page *page) } #endif -static void __lru_cache_activate_page(struct page *page) +/* + * If the page is on the LRU, queue it for activation via + * lru_pvecs.activate_page. Otherwise, assume the page is on a + * pagevec, mark it active and it'll be moved to the active + * LRU on the next drain. + */ +void activate_page(struct page *page) { struct pagevec *pvec; int i; + if (PageLRU(page)) { + activate_page_on_lru(page); + return; + } + local_lock(&lru_pvecs.lock); pvec = this_cpu_ptr(&lru_pvecs.lru_add); @@ -421,16 +432,7 @@ void mark_page_accessed(struct page *page) * evictable page accessed has no effect. */ } else if (!PageActive(page)) { - /* - * If the page is on the LRU, queue it for activation via - * lru_pvecs.activate_page. Otherwise, assume the page is on a - * pagevec, mark it active and it'll be moved to the active - * LRU on the next drain. - */ - if (PageLRU(page)) - activate_page(page); - else - __lru_cache_activate_page(page); + activate_page(page); ClearPageReferenced(page); workingset_activation(page); } -- 2.31.0.rc2.261.g7f71774620-goog