From patchwork Fri Oct 14 23:59:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 13007538 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5093C433FE for ; Fri, 14 Oct 2022 23:59:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5444E6B0088; Fri, 14 Oct 2022 19:59:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F3DD6B0089; Fri, 14 Oct 2022 19:59:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36E9F6B0095; Fri, 14 Oct 2022 19:59:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 25E866B0088 for ; Fri, 14 Oct 2022 19:59:22 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 04B4DC0BC9 for ; Fri, 14 Oct 2022 23:59:21 +0000 (UTC) X-FDA: 80021224164.24.182FF0F Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf25.hostedemail.com (Postfix) with ESMTP id 5A6DCA002C for ; Fri, 14 Oct 2022 23:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665791961; x=1697327961; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=35GC+dPtkI8JDDm0wyE1ckiLPki/MRlOI+/f8wSKCbo=; b=SRbdeGR5SKNfb3IHE7rs4VjlcUmx5VETg/0wVerhEJC9Q7sq5z1DHLsf CbBpGkY0o76TF3FB8oCYb9KyxDP1iQ21ONd0IiLpaMTA3pe/d8TgxmncK 2HHa8GJhscpxmB3yuBWO8lbSE5U0O+Mx3nJPVwqvKP33/gzkbevCtEhLY 3weSnBXznNm5PO80JDMjlqYkJp2iZVIFuibojtp6eMlc4rAjG4p8EwA16 5jKL/aXm8UYT7jcjggDyAFrkfc7SZs6BztwVhMFR3whDRmi3i3flaFL1R jHAM/QEsy2daaYvwjcgA6mkTc13fworOwB2tbZOEPiAipdnRTK0Ky9a1k g==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="292862208" X-IronPort-AV: E=Sophos;i="5.95,185,1661842800"; d="scan'208";a="292862208" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 16:59:18 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="605541393" X-IronPort-AV: E=Sophos;i="5.95,185,1661842800"; d="scan'208";a="605541393" Received: from uyoon-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.90.112]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 16:59:18 -0700 Subject: [PATCH v3 24/25] mm/meremap_pages: Delete put_devmap_managed_page_refs() From: Dan Williams To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , "Darrick J. Wong" , Christoph Hellwig , John Hubbard , Alistair Popple , Jason Gunthorpe , david@fromorbit.com, nvdimm@lists.linux.dev, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org Date: Fri, 14 Oct 2022 16:59:17 -0700 Message-ID: <166579195789.2236710.7946318795534242314.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166579181584.2236710.17813547487183983273.stgit@dwillia2-xfh.jf.intel.com> References: <166579181584.2236710.17813547487183983273.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=SRbdeGR5; spf=pass (imf25.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665791961; a=rsa-sha256; cv=none; b=3JM2ABs1k0FdyNcnTiTtRAkFzoNhgcQsOg6yPVKw73s+tSDlsm2NBROMr0ACImk3MA6oWU Pw7GKQzt6uboSoTHIG22AYcFzMdLSg5SIj8Wk2g6dmzd65u8WXSx/l1RCoC4bVHsJmKpVO /evye6n7SmNdK5kdC57N++NA1BDoXp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665791961; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cU4eOD6MLCuou/7Qj3Q/RfaPVAx7u8AUElaY9eyGc2o=; b=rtjQtXjIPWpTirhv/XwDI1CNZ3kLFbLe23nG5Iffx+GikPg1Sjb5CTFeaZfNx5VrQytY54 ZRI/r/7B+nuIEgGxfIERY7SDbQOmZxUQ96rbVpihzSOsz97fcQko8b1yLrAGwpE2C+ONtd /BlYkK2bySLZC2uJP+FCOucSGpmRg/w= X-Rspamd-Queue-Id: 5A6DCA002C X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=SRbdeGR5; spf=pass (imf25.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam04 X-Stat-Signature: fadgnz4tj45d7usxfm8tci45rkezs3oo X-HE-Tag: 1665791961-961267 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now that fsdax DMA-idle detection no longer depends on catching transitions of page->_refcount to 1, and all users of pgmap pages get access to them via pgmap_request_folios(), remove put_devmap_managed_page_refs() and associated infrastructure. This includes the pgmap references taken at the beginning of time for each page because those @pgmap references are now arbitrated via pgmap_request_folios(). Cc: Matthew Wilcox Cc: Jan Kara Cc: "Darrick J. Wong" Cc: Christoph Hellwig Cc: John Hubbard Cc: Alistair Popple Cc: Jason Gunthorpe Signed-off-by: Dan Williams Reviewed-by: Alistair Popple --- include/linux/mm.h | 30 ------------------------------ mm/gup.c | 6 ++---- mm/memremap.c | 38 -------------------------------------- mm/swap.c | 2 -- 4 files changed, 2 insertions(+), 74 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 8bbcccbc5565..c63dfc804f1e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1082,30 +1082,6 @@ vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf); * back into memory. */ -#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) -DECLARE_STATIC_KEY_FALSE(devmap_managed_key); - -bool __put_devmap_managed_page_refs(struct page *page, int refs); -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - if (!static_branch_unlikely(&devmap_managed_key)) - return false; - if (!is_zone_device_page(page)) - return false; - return __put_devmap_managed_page_refs(page, refs); -} -#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - return false; -} -#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ - -static inline bool put_devmap_managed_page(struct page *page) -{ - return put_devmap_managed_page_refs(page, 1); -} - /* 127: arbitrary random number, small enough to assemble well */ #define folio_ref_zero_or_close_to_overflow(folio) \ ((unsigned int) folio_ref_count(folio) + 127u <= 127u) @@ -1202,12 +1178,6 @@ static inline void put_page(struct page *page) { struct folio *folio = page_folio(page); - /* - * For some devmap managed pages we need to catch refcount transition - * from 2 to 1: - */ - if (put_devmap_managed_page(&folio->page)) - return; folio_put(folio); } diff --git a/mm/gup.c b/mm/gup.c index ce00a4c40da8..e49b1f46faa5 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -87,8 +87,7 @@ static inline struct folio *try_get_folio(struct page *page, int refs) * belongs to this folio. */ if (unlikely(page_folio(page) != folio)) { - if (!put_devmap_managed_page_refs(&folio->page, refs)) - folio_put_refs(folio, refs); + folio_put_refs(folio, refs); goto retry; } @@ -184,8 +183,7 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags) refs *= GUP_PIN_COUNTING_BIAS; } - if (!put_devmap_managed_page_refs(&folio->page, refs)) - folio_put_refs(folio, refs); + folio_put_refs(folio, refs); } /** diff --git a/mm/memremap.c b/mm/memremap.c index 368ff41c560b..53fe30bb79bb 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -94,19 +94,6 @@ bool pgmap_pfn_valid(struct dev_pagemap *pgmap, unsigned long pfn) return false; } -static unsigned long pfn_end(struct dev_pagemap *pgmap, int range_id) -{ - const struct range *range = &pgmap->ranges[range_id]; - - return (range->start + range_len(range)) >> PAGE_SHIFT; -} - -static unsigned long pfn_len(struct dev_pagemap *pgmap, unsigned long range_id) -{ - return (pfn_end(pgmap, range_id) - - pfn_first(pgmap, range_id)) >> pgmap->vmemmap_shift; -} - static void pageunmap_range(struct dev_pagemap *pgmap, int range_id) { struct range *range = &pgmap->ranges[range_id]; @@ -138,10 +125,6 @@ void memunmap_pages(struct dev_pagemap *pgmap) int i; percpu_ref_kill(&pgmap->ref); - if (pgmap->type != MEMORY_DEVICE_PRIVATE && - pgmap->type != MEMORY_DEVICE_COHERENT) - for (i = 0; i < pgmap->nr_range; i++) - percpu_ref_put_many(&pgmap->ref, pfn_len(pgmap, i)); wait_for_completion(&pgmap->done); @@ -267,9 +250,6 @@ static int pagemap_range(struct dev_pagemap *pgmap, struct mhp_params *params, memmap_init_zone_device(&NODE_DATA(nid)->node_zones[ZONE_DEVICE], PHYS_PFN(range->start), PHYS_PFN(range_len(range)), pgmap); - if (pgmap->type != MEMORY_DEVICE_PRIVATE && - pgmap->type != MEMORY_DEVICE_COHERENT) - percpu_ref_get_many(&pgmap->ref, pfn_len(pgmap, range_id)); return 0; err_add_memory: @@ -584,21 +564,3 @@ void pgmap_release_folios(struct folio *folio, int nr_folios) for (iter = folio, i = 0; i < nr_folios; iter = folio_next(folio), i++) folio_put(iter); } - -#ifdef CONFIG_FS_DAX -bool __put_devmap_managed_page_refs(struct page *page, int refs) -{ - if (page->pgmap->type != MEMORY_DEVICE_FS_DAX) - return false; - - /* - * fsdax 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 (page_ref_sub_return(page, refs) == 1) - wake_up_var(page); - return true; -} -EXPORT_SYMBOL(__put_devmap_managed_page_refs); -#endif /* CONFIG_FS_DAX */ diff --git a/mm/swap.c b/mm/swap.c index 955930f41d20..0742b84fbf17 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1003,8 +1003,6 @@ void release_pages(struct page **pages, int nr) unlock_page_lruvec_irqrestore(lruvec, flags); lruvec = NULL; } - if (put_devmap_managed_page(&folio->page)) - continue; if (folio_put_testzero(folio)) free_zone_device_page(&folio->page); continue;