Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp405481pxb; Mon, 7 Feb 2022 14:22:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1oDJvflB3zTkuqrFPlnUcP+cKdRwh5ydpBiwnkvfEE7GxtzZmdO1iodGWOfw3RH9+0x1a X-Received: by 2002:a17:906:d553:: with SMTP id cr19mr1355033ejc.700.1644272536886; Mon, 07 Feb 2022 14:22:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644272536; cv=none; d=google.com; s=arc-20160816; b=ftczyRMWLJxQgLKUqGzDg4rkMldIw+e4pVa1ljkTSyQoCX5P8ldN9Euu2yDr+Na5xE puyBjo0bXE/CXgcWL8U0PTuDM9whsnM5YJmtlZu0Ug4er8e9igc94ZbgkrlBgCwkC9nx pzP/GCrRIv8c//RFtt50Hvpy7hw9xQHb9UhWglKlFqkzcGX34rvuh2VLhea9t10hEKn8 soLbRIFjPu8ssSZt5WJMu08kg6nfJUW97Baslg1Ub8GJnmoyt/6Fcd4Lzc4x/i/WF4iE MGjNZiTiNweIAosrpjdDf0UookY525K+F82o6JlkDWZgliYwl9rZN/E4F1aNKN8zSS6Q oJrw== 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=/czcrmGZ5Lo0qcMzS6TZro4gdhOrCfP1KvQi7PFqQEo=; b=vVIyuG9ufPjrydCo0HYv5bIL1sYMmox5QnUHp3DMS7sX4a2Zoz2ZotMZ708V9SQ0Xd tylA6pRK552sjZOlAtqTAdWkBIMzsM51knyLgnxlyjPnJFXn2R+VFFX190JS44nyRRx2 1aH/wQLmf3+W9bZSv7QEgAmynrrofWDnlpC21ENbmvbGmjikdbZPk3dMICyf31xP0SzF Hqgy/lmrXui7Wskg9TqpvGqw4kvDuxVqprHU1h/8r19yup6tUGlTn8w3MdYKBKP0JN3T ZXIsdUuB3xI0br0oSCq+4Q8UhY56EqTmWGH5c55/bPpqbocRalsuM2ysZ/0TOVjGU6lf bwDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=LH3yYlJb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v21si9827270edc.273.2022.02.07.14.21.52; Mon, 07 Feb 2022 14:22:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=LH3yYlJb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353708AbiBGGhx (ORCPT + 99 others); Mon, 7 Feb 2022 01:37:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238054AbiBGGdR (ORCPT ); Mon, 7 Feb 2022 01:33:17 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDDACC0401C3 for ; Sun, 6 Feb 2022 22:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=/czcrmGZ5Lo0qcMzS6TZro4gdhOrCfP1KvQi7PFqQEo=; b=LH3yYlJbFcYdKZGh5fpbD5cyA8 Vi9YtoYPhluVROnMSefSrKmKevym2zgEQKzyNBtBGvATAe8VUR48cN4jBD5HMQTW1fkjFIgPvwP5k Umggu+ttp3KvRZuWB3YwritEyZctL73XUgIeIp84kFtqqjAVIa1nHL8eZdb/s3ZeWRajN43MS0PCv 7jKw3NdrrVnL32Dz4gC+yVCvZgLrqkRqvZhvVQJLq0in2Z7OUlUeyHCGVsYNZ+6qndUu2qyEBA7BI rDRygKQ3epdxXbnGqU4DVbdYEhlInkWtKtvTWpGbVnkcAst6M2ZI1N5itTfd9ygTLnRkdKiTiOYnm ALEETTxQ==; Received: from [2001:4bb8:188:3efc:2cbe:55d7:bb63:46d2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nGxaA-0099KB-Ir; Mon, 07 Feb 2022 06:33:03 +0000 From: Christoph Hellwig To: Andrew Morton , Dan Williams Cc: Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Ben Skeggs , Karol Herbst , Lyude Paul , Jason Gunthorpe , Alistair Popple , Logan Gunthorpe , Ralph Campbell , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, nvdimm@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH 4/8] mm: move free_devmap_managed_page to memremap.c Date: Mon, 7 Feb 2022 07:32:45 +0100 Message-Id: <20220207063249.1833066-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220207063249.1833066-1-hch@lst.de> References: <20220207063249.1833066-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org free_devmap_managed_page has nothing to do with the code in swap.c, move it to live with the rest of the code for devmap handling. Signed-off-by: Christoph Hellwig --- include/linux/mm.h | 1 - mm/memremap.c | 21 +++++++++++++++++++++ mm/swap.c | 23 ----------------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 7b46174989b086..91dd0bc786a9ec 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1092,7 +1092,6 @@ static inline bool is_zone_movable_page(const struct page *page) } #ifdef CONFIG_DEV_PAGEMAP_OPS -void free_devmap_managed_page(struct page *page); DECLARE_STATIC_KEY_FALSE(devmap_managed_key); static inline bool page_is_devmap_managed(struct page *page) diff --git a/mm/memremap.c b/mm/memremap.c index 5f04a0709e436e..55d23e9f5c04ec 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -501,4 +501,25 @@ void free_devmap_managed_page(struct page *page) page->mapping = NULL; page->pgmap->ops->page_free(page); } + +void put_devmap_managed_page(struct page *page) +{ + int count; + + if (WARN_ON_ONCE(!page_is_devmap_managed(page))) + return; + + count = page_ref_dec_return(page); + + /* + * devmap page refcounts are 1-based, rather than 0-based: if + * refcount is 1, then the page is free and the refcount is + * stable because nobody holds a reference on the page. + */ + if (count == 1) + free_devmap_managed_page(page); + else if (!count) + __put_page(page); +} +EXPORT_SYMBOL(put_devmap_managed_page); #endif /* CONFIG_DEV_PAGEMAP_OPS */ diff --git a/mm/swap.c b/mm/swap.c index bcf3ac288b56d5..08058f74cae23e 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1153,26 +1153,3 @@ void __init swap_setup(void) * _really_ don't want to cluster much more */ } - -#ifdef CONFIG_DEV_PAGEMAP_OPS -void put_devmap_managed_page(struct page *page) -{ - int count; - - if (WARN_ON_ONCE(!page_is_devmap_managed(page))) - return; - - count = page_ref_dec_return(page); - - /* - * devmap page refcounts are 1-based, rather than 0-based: if - * refcount is 1, then the page is free and the refcount is - * stable because nobody holds a reference on the page. - */ - if (count == 1) - free_devmap_managed_page(page); - else if (!count) - __put_page(page); -} -EXPORT_SYMBOL(put_devmap_managed_page); -#endif -- 2.30.2