Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2634467pxv; Sun, 11 Jul 2021 20:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0zIaghb3KKM8ALOkCpjYUcoHIX5IA//6VtHDY7FbIBjONzo6mkDyuXao9QcJtOpvYXSOK X-Received: by 2002:a05:6402:26c2:: with SMTP id x2mr63199659edd.10.1626062116903; Sun, 11 Jul 2021 20:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626062116; cv=none; d=google.com; s=arc-20160816; b=nQvW0ng6fxPsYdA4Ochq7vZqu7fSl474jgFTsy0Y8SqRwpeASQiXW71wkGdQvuTTGh 2q/wtVzsyy31ZEYNbiGeIOgRixAWhA38/pZYsO5/YhCHgA1i8pHZIzczfx4h1RDLeiNv vvbXugKVaFlIj8xfoTxDQXySiDXwowMifGPxByByasUDl3cEU4og6ABPxqQkgT8LVtEJ azbNV5w1nQnSrFqRijFYaX7fTdxVM0OiZLh/qSCq9rgblJiIpeJJGWxJrH5/CoycHaPB reUB89pOsKi4Kpu7/8bfO3Ae1hQdsVX/AAaZF3UAyB299b9EmjnA73CyJ+fcPLOApElv cD6Q== 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=Jo+Y05xHWXOoAJU0n/ZYZ1IsaPufgp8LtPQKSPxNC+I=; b=Er5d03las5adC7TNSY9gp5ynzsWwb9miLRm0HEeMjcwv6aFZsAuYSukjALdszQqlmW bDtRciPSMhklKWBkawJ+eRNv0dwJ49U9w6PmjrrS7HCRYvWB1lh7cDRk9VmkMARr/ejg gl38UXC2Cd3k/OvgEWkPjrTLdPkReRC+ILb/gapGUVviwXHnaqag4jGdO+sVkEZHZpXl urAe40TDgqVzLYSoiu50xUxFJatVfBWY5wBhBrIzAHbafnZD30a6yXa0PjmS7oNIOVfl ocZzgNB5JzMTSl8qn3VCzczTsuXrrkt5QCt6LS/AbEQQdqhdlE03r5v0K8fS61J0nvsg 7SdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZganTg8D; 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 f2si4980718edw.161.2021.07.11.20.54.54; Sun, 11 Jul 2021 20:55:16 -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=ZganTg8D; 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 S232952AbhGLDx6 (ORCPT + 99 others); Sun, 11 Jul 2021 23:53:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbhGLDx5 (ORCPT ); Sun, 11 Jul 2021 23:53:57 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BECEC0613DD; Sun, 11 Jul 2021 20:51:10 -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=Jo+Y05xHWXOoAJU0n/ZYZ1IsaPufgp8LtPQKSPxNC+I=; b=ZganTg8DeLHxmlQnCfI8MThZpt bQyoe9YcGESdDej+tcwLWZSNpokM8zckpgTvO8XMbs1pwVzOqRB8zBbV+njJU2JUOxerJZ4bniZdk kn54tId/jVO++JL3NxQTtruD76oCVwlahTkrenaahwXWRZwVN+7oLT6olf2JbnHdWPXb2kSsYbd3y QvAVGJPLsbKKt6MH39Yv/Bs4/O1KUxYmIzgegCJhledUC3NkDPZxnGcBLmQmBKLnNb7pV1j//WREd FAybUO4q4S5cZfpVbMFO5TyCwce8GYKkNYz52Hk6xsU4FrbmyZwjqdeUr7VuKiqh3kOs0aNerjGXl ycD53wnw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2mxI-00Gpoa-BX; Mon, 12 Jul 2021 03:50:13 +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 v13 080/137] mm: Add folio_evictable() Date: Mon, 12 Jul 2021 04:06:04 +0100 Message-Id: <20210712030701.4000097-81-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 This is the folio equivalent of page_evictable(). Unfortunately, it's different from !folio_unevictable(), but I think it's used in places where you have to be a VM expert and can reasonably be expected to know the difference. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- mm/internal.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 08e8a28994d1..4c966a8622cb 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -72,17 +72,28 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start, pgoff_t end, struct pagevec *pvec, pgoff_t *indices); /** - * page_evictable - test whether a page is evictable - * @page: the page to test + * folio_evictable - Test whether a folio is evictable. + * @folio: The folio to test. * - * Test whether page is evictable--i.e., should be placed on active/inactive - * lists vs unevictable list. - * - * Reasons page might not be evictable: - * (1) page's mapping marked unevictable - * (2) page is part of an mlocked VMA + * Test whether @folio is evictable -- i.e., should be placed on + * active/inactive lists vs unevictable list. * + * Reasons folio might not be evictable: + * 1. folio's mapping marked unevictable + * 2. One of the pages in the folio is part of an mlocked VMA */ +static inline bool folio_evictable(struct folio *folio) +{ + bool ret; + + /* Prevent address_space of inode and swap cache from being freed */ + rcu_read_lock(); + ret = !mapping_unevictable(folio_mapping(folio)) && + !folio_mlocked(folio); + rcu_read_unlock(); + return ret; +} + static inline bool page_evictable(struct page *page) { bool ret; -- 2.30.2