Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2629316pxv; Sun, 11 Jul 2021 20:42:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzVd3aOdWqeY5c0kYEKM9/h5C+In6HMkdn6PDHbH/Eoqe8R4Gt11ZsAhQklciWmrG/fWCW X-Received: by 2002:a05:6402:40c2:: with SMTP id z2mr61327750edb.134.1626061364028; Sun, 11 Jul 2021 20:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626061364; cv=none; d=google.com; s=arc-20160816; b=0Q5p0luzVYaiLQ6sSJThr6iEBXNSoeMuUR0CooXBsaaoZN2sS+c18u0MrcsiPvrrwJ reOaEqehjZyk22gtLoA0aW+eFTTFAckuec3SBn8NwTl4aLLB3wQ+okX+p7sSx8pqvmKy L9+BISWMZ4+VATgtEK+H7JCIDtpkjlZGWd4dlmobr94nUlZuIuKb3GlSPlRuDy3YhC0T 6Tk/MvNQJfcn477dZZW8+h6YK5BgRHwmBR7aDqVLoGSCChHOLvoLJ5mFVFFz5c6NUVUS gdL0VEwytjoutfuUHqsstI+z0ZYTdP5EjysdLwMy77IlGQZq9lZHmvDLZjrdAcDqnpS/ pZoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nqXwHrGW5fkYuF2j97j08SczEABbmY2HqwB4/BmmJqo=; b=sUnDHFEZeR/dBLjZfy7GB8wn4urqG1fAVuh1bl+7HHj7polhkQSx9f93oEzHtrbABL EaA3zFh6/0OULsGTAxBuEi4SzFO5iQGTHgkWWkX3lH9LyTffYJVR3TxtpwOBv3rL6Xqw lbmLJ2P0WuzDxAUD4bhHYL4MvzMMF27TBEPR+45dwPLMp1/+dAwvYKOWnb798vEuSQem 0P4e8dsuW0GVGXc2eAGCNHyTVwnojrAm42NuLuBq5G0YDGbJinxyJOmZ0uhnf7Js2QnG 8xypTrSUniOPdNSCNdxnf59//HuHnkFHhQGdLGXhpo/uSjU13Sc6k5v78RRDBMBj2vPv 7DHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=lH7OfgxV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi14si15641207ejb.441.2021.07.11.20.42.21; Sun, 11 Jul 2021 20:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=lH7OfgxV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232974AbhGLDmN (ORCPT + 99 others); Sun, 11 Jul 2021 23:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbhGLDmM (ORCPT ); Sun, 11 Jul 2021 23:42:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B492EC0613DD; Sun, 11 Jul 2021 20:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=nqXwHrGW5fkYuF2j97j08SczEABbmY2HqwB4/BmmJqo=; b=lH7OfgxVZ5U0fpJT0j8/ojM7Vg gvmMmBt0301CoNYmec/EJxHxf8gM+d4hHJhRpNyhNmqAA95LcuY9NQs7JmzKMEzboj8+I2HlPNTnM eXbjboi3nOCTLck+pkBAJMHFd7YkuiM6KugTfv/bjjcKP8+CDfhVDudEBOHTUSaB5rXoO+Btcenbv 12y39sFO+ftX4NmQX+/OvjHm33e8zuTDFmC32+2wN+whb0/LnkJ/fbdmEc390sCA/eEZtrR2hR/cC saEfWCYX4hMH7YLAIl9eqfLmIVKANMJIC4HR0CSVPaXpw50s4+9SX+7F09Kpckb7tv2YpQ++bytbE 0AFBegyA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2mlk-00Goz9-07; Mon, 12 Jul 2021 03:38:34 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v13 058/137] mm/swap: Add folio_mark_accessed() Date: Mon, 12 Jul 2021 04:05:42 +0100 Message-Id: <20210712030701.4000097-59-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210712030701.4000097-1-willy@infradead.org> References: <20210712030701.4000097-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert mark_page_accessed() to folio_mark_accessed(). It already operated on the entire compound page, but now we can avoid calling compound_head quite so many times. Shrinks the function from 424 bytes to 295 bytes (shrinking by 129 bytes). The compatibility wrapper is 30 bytes, plus the 8 bytes for the exported symbol means the kernel shrinks by 91 bytes. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/swap.h | 3 ++- mm/folio-compat.c | 7 +++++++ mm/swap.c | 34 ++++++++++++++++------------------ 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 989d8f78c256..c7a4c0a5863d 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -352,7 +352,8 @@ extern void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages); extern void lru_note_cost_page(struct page *); extern void lru_cache_add(struct page *); -extern void mark_page_accessed(struct page *); +void mark_page_accessed(struct page *); +void folio_mark_accessed(struct folio *); extern atomic_t lru_disable_count; diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 7044fcc8a8aa..a374747ae1c6 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -5,6 +5,7 @@ */ #include +#include struct address_space *page_mapping(struct page *page) { @@ -41,3 +42,9 @@ bool page_mapped(struct page *page) return folio_mapped(page_folio(page)); } EXPORT_SYMBOL(page_mapped); + +void mark_page_accessed(struct page *page) +{ + folio_mark_accessed(page_folio(page)); +} +EXPORT_SYMBOL(mark_page_accessed); diff --git a/mm/swap.c b/mm/swap.c index 253ac77792dc..b49e10e75af5 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -390,7 +390,7 @@ static void folio_activate(struct folio *folio) } #endif -static void __lru_cache_activate_page(struct page *page) +static void __lru_cache_activate_folio(struct folio *folio) { struct pagevec *pvec; int i; @@ -411,8 +411,8 @@ static void __lru_cache_activate_page(struct page *page) for (i = pagevec_count(pvec) - 1; i >= 0; i--) { struct page *pagevec_page = pvec->pages[i]; - if (pagevec_page == page) { - SetPageActive(page); + if (pagevec_page == &folio->page) { + folio_set_active_flag(folio); break; } } @@ -430,36 +430,34 @@ static void __lru_cache_activate_page(struct page *page) * When a newly allocated page is not yet visible, so safe for non-atomic ops, * __SetPageReferenced(page) may be substituted for mark_page_accessed(page). */ -void mark_page_accessed(struct page *page) +void folio_mark_accessed(struct folio *folio) { - page = compound_head(page); - - if (!PageReferenced(page)) { - SetPageReferenced(page); - } else if (PageUnevictable(page)) { + if (!folio_referenced(folio)) { + folio_set_referenced_flag(folio); + } else if (folio_unevictable(folio)) { /* * Unevictable pages are on the "LRU_UNEVICTABLE" list. But, * this list is never rotated or maintained, so marking an * evictable page accessed has no effect. */ - } else if (!PageActive(page)) { + } else if (!folio_active(folio)) { /* * 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)) - folio_activate(page_folio(page)); + if (folio_lru(folio)) + folio_activate(folio); else - __lru_cache_activate_page(page); - ClearPageReferenced(page); - workingset_activation(page_folio(page)); + __lru_cache_activate_folio(folio); + folio_clear_referenced_flag(folio); + workingset_activation(folio); } - if (page_is_idle(page)) - clear_page_idle(page); + if (folio_idle(folio)) + folio_clear_idle_flag(folio); } -EXPORT_SYMBOL(mark_page_accessed); +EXPORT_SYMBOL(folio_mark_accessed); /** * lru_cache_add - add a page to a page list -- 2.30.2