Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1636827rwn; Thu, 15 Sep 2022 20:39:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6YGGqLVHDDWH9LC70QGVFBnCtqtMQKQHciZ3dUi9eD2LIlwrGtnUS8MqGtxz/6OXMTQyAo X-Received: by 2002:a17:902:b206:b0:173:c58:dc74 with SMTP id t6-20020a170902b20600b001730c58dc74mr2709048plr.65.1663299558263; Thu, 15 Sep 2022 20:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663299558; cv=none; d=google.com; s=arc-20160816; b=im1DC3yEL6jy0ntMedTawFkNVYct+gjOwUuCIvsBm9K6WYur2afai1otaV4rrmY6hW jrLVLmmw+rTemyca8texTXs7LH1hpo6TSE03WrNbwctbEnzcKnDSuu8FdNXzFaOz00Hu L5X6f5nzGOSVdq0YkO5gYvItwj0/UZH4KIggHM0CuUarIVcBYcVKQVgA6ASj9+VhBok6 mJLmddweP3FV26DSH3MMe78ZAWMecErYKr2nftOXijqNbDh26M87nDu6DbOXNIHMzMYv h3hp5Llbu9GJXr70C/uT8vLnFyAZTHljcNGKvA0NBsH1eX61a5JemSzgotqffu1yaBJI a81Q== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=JfbF5N6ejI3xx1xkFO8ghG2Kg/m+EIGT4GrHdEZXoxo=; b=v0vUDDFZx9X6N4Y3nTqnSbO5+6da3Wig4CBH8JbYtdA9Ch5gAswe/ncCGp0j6lXRd7 CmKJklzWULtNtSrlCYcMVR1rGX3pWkuG9BwBdj6LrMoUIfy0oB57qGQjgXwKgG5hZmHk J0i6V/hwfeEK/Gbmuy5y4FjAud23zw6H7PRG2MzsoszBOx86Qyv1YALnyPqJm0qLHwt8 tRKc4F+x3c4RWa9pBN9Ihx1Y6RDeTL5PWbRL9kLP8LHur3TYrCw7FGPD6QAwj3J0DuaA FrtvsM2FkomeKW+7NvAp+awkVjRaEDACwmML4j1CCVNs50rs7HNjIbnEabXX68RlI3pk vmGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M7BW1+Ez; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j191-20020a636ec8000000b00434ecfaa04csi22304422pgc.665.2022.09.15.20.39.06; Thu, 15 Sep 2022 20:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@intel.com header.s=Intel header.b=M7BW1+Ez; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230039AbiIPDgr (ORCPT + 99 others); Thu, 15 Sep 2022 23:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbiIPDg2 (ORCPT ); Thu, 15 Sep 2022 23:36:28 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1139D126; Thu, 15 Sep 2022 20:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663299386; x=1694835386; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ajaFzvrRPG16T180cU73eT4NP/l2RlRiUDdGWZj7wgU=; b=M7BW1+EzIhNgpVsBTrNRSxKsaN2T/mazZoEBrJxq+h5Oxk59wtKgHC4V uV7mKLkszUHF9dPikfeweM2+81CAq/yWd2GwEzHvLADFuKqvasA325CVf nFt6s1kv1MmREQpFwhQ4WK0wGXZ/Yckb9k9C7AtyOz22p3nMcEZTb6FWr AM2JZ89R/kREtAqLd8lis0oSzI7tBZkN/0KPlXaq9CzN5MWuZKrrDkCsu 4k4hqj4FnMgKpNVx7BrIXDwV6dWmT/VsS+PygiUsdUYOmlHdLx5RFeHfM Gyeym6sGIpV86x1AtnngNrmb+V10+q7pqGoFXlwNLq4Bwb1KYV0JhqLZw g==; X-IronPort-AV: E=McAfee;i="6500,9779,10471"; a="325170450" X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="325170450" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:36:26 -0700 X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="679809498" Received: from colinlix-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.29.52]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:36:25 -0700 Subject: [PATCH v2 13/18] dax: Prep mapping helpers for compound pages From: Dan Williams To: akpm@linux-foundation.org Cc: Matthew Wilcox , Jan Kara , "Darrick J. Wong" , Jason Gunthorpe , Christoph Hellwig , John Hubbard , linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Date: Thu, 15 Sep 2022 20:36:25 -0700 Message-ID: <166329938508.2786261.5544204703263725154.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> References: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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-ext4@vger.kernel.org In preparation for device-dax to use the same mapping machinery as fsdax, add support for device-dax compound pages. Presently this is handled by dax_set_mapping() which is careful to only update page->mapping for head pages. However, it does that by looking at properties in the 'struct dev_dax' instance associated with the page. Switch to just checking PageHead() directly in the functions that iterate over pages in a large mapping. Cc: Matthew Wilcox Cc: Jan Kara Cc: "Darrick J. Wong" Cc: Jason Gunthorpe Cc: Christoph Hellwig Cc: John Hubbard Signed-off-by: Dan Williams --- drivers/dax/Kconfig | 1 + drivers/dax/mapping.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index 205e9dda8928..2eddd32c51f4 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -9,6 +9,7 @@ if DAX config DEV_DAX tristate "Device DAX: direct access mapping device" depends on TRANSPARENT_HUGEPAGE + depends on !FS_DAX_LIMITED help Support raw access to differentiated (persistence, bandwidth, latency...) memory via an mmap(2) capable character diff --git a/drivers/dax/mapping.c b/drivers/dax/mapping.c index 70576aa02148..5d4b9601f183 100644 --- a/drivers/dax/mapping.c +++ b/drivers/dax/mapping.c @@ -345,6 +345,8 @@ static vm_fault_t dax_associate_entry(void *entry, for_each_mapped_pfn(entry, pfn) { struct page *page = pfn_to_page(pfn); + page = compound_head(page); + if (flags & DAX_COW) { dax_mapping_set_cow(page); } else { @@ -353,6 +355,9 @@ static vm_fault_t dax_associate_entry(void *entry, page->index = index + i++; page_ref_inc(page); } + + if (PageHead(page)) + break; } return 0; @@ -372,6 +377,9 @@ static void dax_disassociate_entry(void *entry, struct address_space *mapping, for_each_mapped_pfn(entry, pfn) { page = pfn_to_page(pfn); + + page = compound_head(page); + if (dax_mapping_is_cow(page->mapping)) { /* keep the CoW flag if this page is still shared */ if (page->index-- > 0) @@ -383,6 +391,9 @@ static void dax_disassociate_entry(void *entry, struct address_space *mapping, } page->mapping = NULL; page->index = 0; + + if (PageHead(page)) + break; } if (trunc && !dax_mapping_is_cow(page->mapping)) { @@ -660,11 +671,16 @@ static struct page *dax_zap_pages(struct xa_state *xas, void *entry) for_each_mapped_pfn(entry, pfn) { struct page *page = pfn_to_page(pfn); + page = compound_head(page); + if (zap) page_ref_dec(page); if (!ret && !dax_page_idle(page)) ret = page; + + if (PageHead(page)) + break; } if (zap)