From patchwork Mon Dec 16 15:53:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13909929 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 6607FE77180 for ; Mon, 16 Dec 2024 15:54:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E78928D0002; Mon, 16 Dec 2024 10:54:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E28E68D0001; Mon, 16 Dec 2024 10:54:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF8F28D0002; Mon, 16 Dec 2024 10:54:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AEA1A8D0001 for ; Mon, 16 Dec 2024 10:54:14 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5B076120E1E for ; Mon, 16 Dec 2024 15:54:14 +0000 (UTC) X-FDA: 82901267946.26.5F3E97A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id F1B651C0011 for ; Mon, 16 Dec 2024 15:53:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QRspj2HJ; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734364433; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=rBBpd22PJzLLmPajy8p7zWHGVvG5LBG4Sj90qfpefx0=; b=cLZb/18JUcntSVTBCvGJP4K0wLY9fIB1a7WHaVk+pT+IRqO38aNvB26dITGq7NZuu/bUcD w1vdJtpYCIcS5pQjM7xGIyUtLmF4SrFelukhs2g5aoIDHF1vxNGxC52uq/GyC/yc3OMW+b JdSMk0YxiJ3d7W+BOxdLrV0/WMg4Yb8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734364433; a=rsa-sha256; cv=none; b=GoddJK+fNbWsW88auxdFH4f+PPOyDu4UT8aTrXFfqxyI6agtkOP8hvtpLWHwPHe2Jka0Tv cw9pZhhBKdlhxrZ3/3f+yK6bM6VGogBj0YxLxEoC8WNHL8gl4qliwLkjmJoQg5o7N61KAh ByTcWmOEOPxvt9xVtJ0RVwfv6oRGfV8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QRspj2HJ; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=rBBpd22PJzLLmPajy8p7zWHGVvG5LBG4Sj90qfpefx0=; b=QRspj2HJzQ59iy5Ci553SMSMuO OpXDIMj4ZSvlXoCYN03XnzN6ZFvokxsuE07B78w44YAdCG4uoQP7ne4uYQVtvJ6Fp0G+KH/MHLMSO r+WK18nJ4hPxUe34Xd3V0v2r60xi/SVkxxmoUec7Uztzmh2gZYsmXANof2/YTzIJz/kl4ispSox8d UVyk6ltKQrRQXBtak8bbmXoZsR22pyG3z4Nz6zMVkenVyxprmo2LWknrCbK155VRWNMKKDY5Lxtx1 Zmxy20RDozu4q2jQnlHlFmK0nu7jdbAndAmNFX1PjXK8nOd87wrH56Z0/hGw1c15b+4RY6yzPV2ye PLjdJjqQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNDQA-000000002B3-0vvD; Mon, 16 Dec 2024 15:54:10 +0000 From: "Matthew Wilcox (Oracle)" To: Dan Williams Cc: "Matthew Wilcox (Oracle)" , Vishal Verma , Dave Jiang , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/2] dax: Remove access to page->index Date: Mon, 16 Dec 2024 15:53:55 +0000 Message-ID: <20241216155408.8102-1-willy@infradead.org> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: F1B651C0011 X-Stat-Signature: 6zrwudp4kz97u4p3n7jeusbp3c5jgyii X-Rspam-User: X-HE-Tag: 1734364421-855191 X-HE-Meta: U2FsdGVkX19Wfn+eeveYMl/U7zQFWgJk7xSwKxOAcqCmH3K7i1fmXSMYyaFsU/hQg6bFzLW2sMdAs0sruwQb8w/Gk/mwY+x+RPY/aA9AHOOFc2rjfdp5KJ+bbzU7yPD6O4bDscrHfvKP9hC0zUw4v99ntaE2ceE2DnRaqQgVhcPapXRf3j7fvc0QeDMOsVcC0c1W+WFtzmStDP8cyPyQR6d0hcOUDcMFvpG4y0a1OD84RvqJirwkao8s3wuiNbiRqJNi1ZCs1X/T4Hq+IJjxEopoxac9etJtkGbcJpHxcVOlIT8IdZ4hjLxmFQl+y8UR6SfU/uBjJO7XzDNH1JDnETS/EIU31rpBC6cwNu92/pkXM0W9Dn7/YhPc2N1ZY/iQ/Lbe+BWp7Q0wKSULC3JafUlFeHcuhi5hUIIuiNIEOp3VW05gMVRoITr8CmIdFuy3FqH6FILYj3Vo3biEOKgXiRR2BsxL2c25v+xtFKMajv5Rsrt0vu+ADeqhg0aLwdwfeM+DmVDBkyQ+s50bxHY0zNLPXaB9E8eIUMNpbaDnQxOblcEBnffB4619JmHCRgPctZKN8lTXdt+31p14uVGSHE//nLS27fihjIR5G5bNzamVa/pasiRNrKl2+WlfUXGm5wXG9uyrpFAhWWTYBdxVOsEmsd8Mh4Pq12y7jbXGB5HG1IK5x21HPo/gPeiQLpP724w6JmnbGYoYgk1GrkX6CftrKs0UZYg8wXgHUqR1XI6OeJMJm/WO2UUKIi75zbl0Wr37Hcl6Ddxd58Fz+wwQIMrrk9Fy2lJ6he6YsR0opt+jdy65lsafnP9RWa19zBlXtQiBoTtL38TvFoQsZq6IcmeidtDlAZuXNBtRpUZ5depqncromBoSSikgCNeRlx0k33DMlJ3KLeuVek+eQTvyGEvNy1H4tiZsoeKN4BTvoPzZKTjTjM9EeEkbN3Nnq64/VnR1ryQjk7UlFHcT+72 TvW4yEvS 96jANIjwd3IhKSf3YlRoozk6O589elidLpAUQ1j4/lkcezOjlV1EU9vMh8c3o9PxoYQ2sNF2etPsq6heE7va5h2cUOB1YjfGjyS4xFizxsTODyi0a19uX32hpdUuvv+x1SQOX/MK+FcKvcvxaket5v7Kqove4TxHSElHRVkAQXnNO0Paa4dQvV+BZ6cwEZfAGNHbMu5TYKo/7ggshR2qMYI02o+3FtAyHYogzbZsOqd4PoUhpg+R6ac/K+8QMuNAWBIXammd20ccz5ltcENOc8gBIyg== 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: List-Subscribe: List-Unsubscribe: This looks like a complete mess (why are we setting page->index at page fault time?), but I no longer care about DAX, and there's no reason to let DAX hold us back from removing page->index. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- drivers/dax/device.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 6d74e62bbee0..bc871a34b9cd 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -89,14 +89,13 @@ static void dax_set_mapping(struct vm_fault *vmf, pfn_t pfn, ALIGN_DOWN(vmf->address, fault_size)); for (i = 0; i < nr_pages; i++) { - struct page *page = pfn_to_page(pfn_t_to_pfn(pfn) + i); + struct folio *folio = pfn_folio(pfn_t_to_pfn(pfn) + i); - page = compound_head(page); - if (page->mapping) + if (folio->mapping) continue; - page->mapping = filp->f_mapping; - page->index = pgoff + i; + folio->mapping = filp->f_mapping; + folio->index = pgoff + i; } } From patchwork Mon Dec 16 15:53:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13909930 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 A003FE7717F for ; Mon, 16 Dec 2024 15:54:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B46CE8D0003; Mon, 16 Dec 2024 10:54:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF3768D0001; Mon, 16 Dec 2024 10:54:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F9EE8D0003; Mon, 16 Dec 2024 10:54:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 689988D0001 for ; Mon, 16 Dec 2024 10:54:15 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E86F9120E1E for ; Mon, 16 Dec 2024 15:54:14 +0000 (UTC) X-FDA: 82901268198.18.6A57B30 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id 26323140008 for ; Mon, 16 Dec 2024 15:53:52 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=T7fJugSM; dmarc=none; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734364425; a=rsa-sha256; cv=none; b=Cv8N+CDin02I/FAGeMSCBlrS2xW+j37KDH4qpCcjhcX5rRXjQvvcCDnyVpGP8VnfxQEDM/ h81pWABRSTzPmp7JI/dctgR4Yl/d7CPuzez5TK1cX+LEw9sjugISIUlPOzQSEjarmz3MVe t+0mg4YgM4M/Vh/cGcxP9cmwj+4nCew= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=T7fJugSM; dmarc=none; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734364425; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iSSfIRVYFh9OixVSiPRYAanTfhJia6O8dwZi1nuoKzs=; b=X5SPag7mh1IyvJ/Va0p+ZSk2829cGzgC7Nx5UY2ue8wuumiW37d1aMvmR40Y/H0mg28zMC 4n50pZ/sPbTAQ/IyH35Ahk8LsuDSaWabpz/ceiO0DmS25YcclOYLPkNBG5NvhU36pp4QRp knh6yTBXndac7UWuKt22xWDONi/AWR8= 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=iSSfIRVYFh9OixVSiPRYAanTfhJia6O8dwZi1nuoKzs=; b=T7fJugSMgUXI/si204QfAuhmxI Q2WBIIzhXzLjb0y/BpZjDG4/CPsZ8+Wn9SVhkAIA0xF7NQMSr+LhbKq5r41nYiHK/f+Kw3iyFd2Xu +gUmCFPB7pp9HLnv9a+Kp9XUFP+DlOnnZHV185ggKJUdyzeGrvqwHUjQwUz/jGUCX/JYjGd6JOv4V IT9i7AyS+tEe+ZwzFcodpliUdsykJlRA8BNheJJP6f/vH+xXazJJeVUgHR8sDAYVuPKidB5HQHeur cc5CqjAtcbwVyBsFIsnIQKZWfxhHgK8fng7sLxDw7zDBTxoj8weqsBdFjn3832M5T2Sfe6klUGmvm qVMExFPA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNDQB-000000002CK-0yMa; Mon, 16 Dec 2024 15:54:11 +0000 From: "Matthew Wilcox (Oracle)" To: Dan Williams Cc: "Matthew Wilcox (Oracle)" , Vishal Verma , Dave Jiang , nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/2] dax: Use folios more widely within DAX Date: Mon, 16 Dec 2024 15:53:56 +0000 Message-ID: <20241216155408.8102-2-willy@infradead.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241216155408.8102-1-willy@infradead.org> References: <20241216155408.8102-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 26323140008 X-Stat-Signature: wf576jqrwuf554s9aaxa51zea5jze31d X-Rspam-User: X-HE-Tag: 1734364432-128984 X-HE-Meta: U2FsdGVkX18g/TdhUk9EMfL//YjsyoLcoo9gBXuGpTedCkqlX0b8uletu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Xuzryxw0AnkdqOTkrfQnCVc7oxlozNrrcH/84epLBWZHUIJq+rHpBL8Qgj0SdvmPcZqR42NGM+3vA+mM+T03ty0HPtxx+Pq8eF6VDsPhGuRPwn9mTYJ8SXmYV9XA1i4tJnWxPpk4u0IFuJNqmQTSaToPdQ== 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: List-Subscribe: List-Unsubscribe: Convert from pfn to folio instead of page and use those folios throughout to avoid accesses to page->index and page->mapping. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- fs/dax.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 21b47402b3dc..972febc6fb9d 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -320,38 +320,39 @@ static unsigned long dax_end_pfn(void *entry) for (pfn = dax_to_pfn(entry); \ pfn < dax_end_pfn(entry); pfn++) -static inline bool dax_page_is_shared(struct page *page) +static inline bool dax_folio_is_shared(struct folio *folio) { - return page->mapping == PAGE_MAPPING_DAX_SHARED; + return folio->mapping == PAGE_MAPPING_DAX_SHARED; } /* - * Set the page->mapping with PAGE_MAPPING_DAX_SHARED flag, increase the + * Set the folio->mapping with PAGE_MAPPING_DAX_SHARED flag, increase the * refcount. */ -static inline void dax_page_share_get(struct page *page) +static inline void dax_folio_share_get(struct folio *folio) { - if (page->mapping != PAGE_MAPPING_DAX_SHARED) { + if (folio->mapping != PAGE_MAPPING_DAX_SHARED) { /* * Reset the index if the page was already mapped * regularly before. */ - if (page->mapping) - page->share = 1; - page->mapping = PAGE_MAPPING_DAX_SHARED; + if (folio->mapping) + folio->page.share = 1; + folio->mapping = PAGE_MAPPING_DAX_SHARED; } - page->share++; + folio->page.share++; } -static inline unsigned long dax_page_share_put(struct page *page) +static inline unsigned long dax_folio_share_put(struct folio *folio) { - return --page->share; + return --folio->page.share; } /* - * When it is called in dax_insert_entry(), the shared flag will indicate that - * whether this entry is shared by multiple files. If so, set the page->mapping - * PAGE_MAPPING_DAX_SHARED, and use page->share as refcount. + * When it is called in dax_insert_entry(), the shared flag will indicate + * that whether this entry is shared by multiple files. If so, set + * the folio->mapping PAGE_MAPPING_DAX_SHARED, and use page->share + * as refcount. */ static void dax_associate_entry(void *entry, struct address_space *mapping, struct vm_area_struct *vma, unsigned long address, bool shared) @@ -364,14 +365,14 @@ static void dax_associate_entry(void *entry, struct address_space *mapping, index = linear_page_index(vma, address & ~(size - 1)); for_each_mapped_pfn(entry, pfn) { - struct page *page = pfn_to_page(pfn); + struct folio *folio = pfn_folio(pfn); if (shared) { - dax_page_share_get(page); + dax_folio_share_get(folio); } else { - WARN_ON_ONCE(page->mapping); - page->mapping = mapping; - page->index = index + i++; + WARN_ON_ONCE(folio->mapping); + folio->mapping = mapping; + folio->index = index + i++; } } } @@ -385,17 +386,17 @@ static void dax_disassociate_entry(void *entry, struct address_space *mapping, return; for_each_mapped_pfn(entry, pfn) { - struct page *page = pfn_to_page(pfn); + struct folio *folio = pfn_folio(pfn); - WARN_ON_ONCE(trunc && page_ref_count(page) > 1); - if (dax_page_is_shared(page)) { + WARN_ON_ONCE(trunc && folio_ref_count(folio) > 1); + if (dax_folio_is_shared(folio)) { /* keep the shared flag if this page is still shared */ - if (dax_page_share_put(page) > 0) + if (dax_folio_share_put(folio) > 0) continue; } else - WARN_ON_ONCE(page->mapping && page->mapping != mapping); - page->mapping = NULL; - page->index = 0; + WARN_ON_ONCE(folio->mapping && folio->mapping != mapping); + folio->mapping = NULL; + folio->index = 0; } }