Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp145123pxv; Thu, 15 Jul 2021 00:49:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC416T2gHQNvgxHyKjyHAExzPBNFnm/441eisFK3TD0miWsznI/RufYCEoMLAsAiDQKf3e X-Received: by 2002:a17:907:9602:: with SMTP id gb2mr4025919ejc.354.1626335352842; Thu, 15 Jul 2021 00:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626335352; cv=none; d=google.com; s=arc-20160816; b=KBpzj1SH4+1xfiw+c8CPYQ7udTdR85bl3nNxzUjB0hgmfPVa+MRI6Z4hHLYmEhpzRE Ek2H9IIKu21qzxkCJr0vkXgWu8SyeEIJg6YcSZdQiXdaa78AqG+OwyDtBJXjiPLqq838 3S3WERGzCyodnCHmEYzBDld+B8xPRIdfbdiQji8G6Klg0X3s1+HXMVsQRfERMHMc5Biu 3N2+9pZbCBk4LX3ZsoTaJrNTSxNCVz7emjemaTuOo1vD2IY5DkCr/wbxnLxMBevEFaiR GOGTllVdzpf2YC/yDGhYNHsVcWC+N7u5eQN15Qzjq3iRHl7Ku0Eb2M/sCcJel78ISLtn p/ug== 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=mn7q/52I4w3t9ii2jzCwCXbdd/SQ2Ju45FWtqep1dhc=; b=sYFfqt4AJitiwdujfazSxN80M9uOHQn9jVapdYAympppb/Kw66J76+7TNPGMJ41NVK g2e+rssDogLjwbfrheFlsts6a/bu93r5yZU3EDPiMRDAtTmfkOVGCG7jk9DgtrvKa2es pZrMcBlmzlvr0oa2L6HCsRThAU2AbTn55md9nxhwdtbGP6dFaswSHLTUhoYEbVxV/4J1 8/cOX3VQerhOFD9sO7b9WyjNqrnLvx4TEChinFEydYdOFgP+F4mbTgZ6/kPLTrSHVPOt nLFVO8P8tnURlUqOs8LWSQsu7bRTs5qfNQL8WTN5wvViybq3WGafdwdaWnJd8w9ium7D 2+hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=lXAsWjCo; 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 r19si6324575ejb.192.2021.07.15.00.48.49; Thu, 15 Jul 2021 00:49:12 -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=lXAsWjCo; 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 S237789AbhGOErr (ORCPT + 99 others); Thu, 15 Jul 2021 00:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237239AbhGOErm (ORCPT ); Thu, 15 Jul 2021 00:47:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62C67C061760; Wed, 14 Jul 2021 21:44:50 -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=mn7q/52I4w3t9ii2jzCwCXbdd/SQ2Ju45FWtqep1dhc=; b=lXAsWjCocKB9Q5BX+yV68fOS3y KABL3fkYPal0NMHPWum8euUfcMt5FdZCVSx1gGVhxMlHcO2yIAWIiphPSJM3wMnQC10y8Gl46mJFk C/5Pyxx9Ap1Dalt+tErEvXQvsM6ZdL3EgSsIuR2P8ugJu1Ko16MJgUYxjvLIXgY3qGQAkNALnRffu LYW0FsGsN4uREMTK9cbZ/CcbmyFjvOgna8Cg4nKJjlLktwokx1qYOWP6VMHMr45ab0Vwdug50Hqa5 rgIxdqk/vPt009VF+LSPcgihUlUauDsIRzXQZhvcF7n++pWmSmh+bv/VnoaLXvkwMNM35nNBi05hF X1GynDNw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3tDi-002yO4-AU; Thu, 15 Jul 2021 04:43:45 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: [PATCH v14 083/138] mm/lru: Add folio_add_lru() Date: Thu, 15 Jul 2021 04:36:09 +0100 Message-Id: <20210715033704.692967-84-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 Reimplement lru_cache_add() as a wrapper around folio_add_lru(). Saves 159 bytes of kernel text due to removing calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- include/linux/swap.h | 1 + mm/folio-compat.c | 6 ++++++ mm/swap.c | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 5e01675af7ab..81801ba78b1e 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -351,6 +351,7 @@ extern unsigned long nr_free_buffer_pages(void); extern void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages); extern void lru_note_cost_folio(struct folio *); +extern void folio_add_lru(struct folio *); extern void lru_cache_add(struct page *); void mark_page_accessed(struct page *); void folio_mark_accessed(struct folio *); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index c1e01bc36d32..6de3cd78a4ae 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -102,3 +102,9 @@ bool redirty_page_for_writepage(struct writeback_control *wbc, return folio_redirty_for_writepage(wbc, page_folio(page)); } EXPORT_SYMBOL(redirty_page_for_writepage); + +void lru_cache_add(struct page *page) +{ + folio_add_lru(page_folio(page)); +} +EXPORT_SYMBOL(lru_cache_add); diff --git a/mm/swap.c b/mm/swap.c index 89d4471ceb80..6f382abeccf9 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -459,29 +459,29 @@ void folio_mark_accessed(struct folio *folio) EXPORT_SYMBOL(folio_mark_accessed); /** - * lru_cache_add - add a page to a page list - * @page: the page to be added to the LRU. + * folio_add_lru - Add a folio to an LRU list. + * @folio: The folio to be added to the LRU. * - * Queue the page for addition to the LRU via pagevec. The decision on whether + * Queue the folio for addition to the LRU. The decision on whether * to add the page to the [in]active [file|anon] list is deferred until the - * pagevec is drained. This gives a chance for the caller of lru_cache_add() - * have the page added to the active list using mark_page_accessed(). + * pagevec is drained. This gives a chance for the caller of folio_add_lru() + * have the folio added to the active list using folio_mark_accessed(). */ -void lru_cache_add(struct page *page) +void folio_add_lru(struct folio *folio) { struct pagevec *pvec; - VM_BUG_ON_PAGE(PageActive(page) && PageUnevictable(page), page); - VM_BUG_ON_PAGE(PageLRU(page), page); + VM_BUG_ON_FOLIO(folio_test_active(folio) && folio_test_unevictable(folio), folio); + VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); - get_page(page); + folio_get(folio); local_lock(&lru_pvecs.lock); pvec = this_cpu_ptr(&lru_pvecs.lru_add); - if (pagevec_add_and_need_flush(pvec, page)) + if (pagevec_add_and_need_flush(pvec, &folio->page)) __pagevec_lru_add(pvec); local_unlock(&lru_pvecs.lock); } -EXPORT_SYMBOL(lru_cache_add); +EXPORT_SYMBOL(folio_add_lru); /** * lru_cache_add_inactive_or_unevictable -- 2.30.2