Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp138055pxv; Thu, 15 Jul 2021 00:38:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwXA3/WioU1Nt8cuXfo/kuNq188XamwKzx9jSNjOgp57A6e5Hr0VQb2E6AYS8JVjy94NsE X-Received: by 2002:a05:6e02:5ad:: with SMTP id k13mr1817967ils.284.1626334728015; Thu, 15 Jul 2021 00:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626334728; cv=none; d=google.com; s=arc-20160816; b=IiX1HTNF+Aq5tDEre4YirUoPGqAJLtSZ1/QH/N6o3kdLZLj8XFqXgKgnzKWt5z/exB dJHq5z+j9IrP2MMCI2zTJjd0qdNbUOia06LakqyRTFZEOCIdqBt+qwKLnJS6X/el6zWQ IGISYo2oDOUM2jDp5IFwJIMLCQrbAeKjS38NTF7xKHhDLar9JIUuG2xfzEbJDuvK5AAA Ay5J+2bE7dIJWkzfZk7BUOXFOjAQ5/AmzIqFFYUcKz3dVyNsXi1MdFstUfu0d3I00MDq Rp0II5yAoKIGmuKp/MEhkL/bQutiZ0Hnf/LQJHK1V2Dk+Ni4/sTElPaods6LfDXdwxW+ muIA== 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=InONYvAMt7FtRQ5+AzVzta7XRdKuWUeYcNdU4eMCT0w=; b=rpV7xR5CY8hN6tRBfLYyI0Ha0btSzOHeZqVt7pKNcs8UECxeZQO14fsD+ZsnQmC5DJ BYfrkKaEifxr0BNKGh6i8cjFNFGvXoJJc7N3dFn/bcjTHR3xT0Ns/C5l61QXf/FJ6CKO INpaFoSnkn+ybT+7/6ZTidGMJGyS1pLjj2Hk37s3F1/SEjRCMAtG+M8duPj9hrIC9jA/ PM9OYR3K//D3vOnu433rXSjUa5Y0uWaviMOVoyOMU2Itr6ZKzvgNaTDHdfv2h+93V4i3 KcH51jKDvAoU6Z/vIWwJMVj9rzRHMn4+/AEOImFspBwAe4kkRsNxLXQ/aUeVvkEr7+Kq rKOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="hXJ/Pegc"; 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 b16si6267345ile.135.2021.07.15.00.38.14; Thu, 15 Jul 2021 00:38:48 -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="hXJ/Pegc"; 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 S235967AbhGOE1u (ORCPT + 99 others); Thu, 15 Jul 2021 00:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbhGOE1u (ORCPT ); Thu, 15 Jul 2021 00:27:50 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F32DC06175F; Wed, 14 Jul 2021 21:24:57 -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=InONYvAMt7FtRQ5+AzVzta7XRdKuWUeYcNdU4eMCT0w=; b=hXJ/PegcZoOxuAW9utPLRkzeof m20qtE3DYxoLyxIIecYoLC8TsCuowTmtVVzOrKEnIe+ZOcgSdn2fdeRcUDzlAotQ9x6Aq6O9NSoFn Ilx2q0JjxeURWXPVp6kHYxiWI6s7aQv4xw7Y/MuwMn62pYWH5GhFCrin/JUoqIxzT6D9q5hdeGdvk PeQPF1ADZL4e3vDk0TGVFk+wFJ3SkPTni8mczzmoTCq2zQ5c/WMaCY/fu/QosIGKxqvovEHcWlMFT cZ/c/6JsQih74WjAS6or9Tsp4xY2GtbHdAsn9bEGEGXObQpsmHTIWCqdV8CbYtM9Ow0rIIO9uPdIP G97WWxug==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3suM-002x8u-Tg; Thu, 15 Jul 2021 04:23:47 +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 v14 058/138] mm/swap: Add folio_mark_accessed() Date: Thu, 15 Jul 2021 04:35:44 +0100 Message-Id: <20210715033704.692967-59-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-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 c3137e4e1cd8..d32007fe23b3 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(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_test_referenced(folio)) { + folio_set_referenced(folio); + } else if (folio_test_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_test_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_test_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(folio); + workingset_activation(folio); } - if (page_is_idle(page)) - clear_page_idle(page); + if (folio_test_idle(folio)) + folio_clear_idle(folio); } -EXPORT_SYMBOL(mark_page_accessed); +EXPORT_SYMBOL(folio_mark_accessed); /** * lru_cache_add - add a page to a page list -- 2.30.2