From patchwork Sun Sep 4 02:16:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12965102 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 6C62EC6FA82 for ; Sun, 4 Sep 2022 02:17:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0957780178; Sat, 3 Sep 2022 22:17:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 044D88015A; Sat, 3 Sep 2022 22:17:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4F5E80178; Sat, 3 Sep 2022 22:17:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D58678015A for ; Sat, 3 Sep 2022 22:17:00 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B3D6E1C5F93 for ; Sun, 4 Sep 2022 02:17:00 +0000 (UTC) X-FDA: 79872790200.23.0F4F20E Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf06.hostedemail.com (Postfix) with ESMTP id 24650180052 for ; Sun, 4 Sep 2022 02:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662257820; x=1693793820; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JRd33zR9nL8ko8mlBX12iNdK9JcdjXgX57uT6RLRguc=; b=Es4qupQNn6NUteg53i3EfLM78ZeCI2ok8isNg1JOs0n1Y8eF0RAHoadu a0x587YKVjAQPg6b/CsEQrv5Fw+dr4k52021zbjTo2LfDhumkWvfu7wi3 vaZs9vXNYBDeeqF6qr9K3cVIHFnqd1hdMKXzcatQqjG269EwdKwsOZG1D g/gJgtfyWztbqFmq14efbMsJ7BmAMsJEogM9n0Tb75JzMaVd9RKg8E0/Q a4JOSXJJGdk8UFg69aIAu31YuQC6h3App3EV43+A55a1a6X2MY0+JRne2 188Rr8YTBZVyVZFc5kU9A/ohtozApKPiqxvP2le/kDd//MLBrqkBqeLsc Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10459"; a="294943598" X-IronPort-AV: E=Sophos;i="5.93,288,1654585200"; d="scan'208";a="294943598" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2022 19:16:58 -0700 X-IronPort-AV: E=Sophos;i="5.93,288,1654585200"; d="scan'208";a="590497054" Received: from pg4-mobl3.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.212.132.198]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2022 19:16:58 -0700 Subject: [PATCH 10/13] dax: Prep dax_{associate, disassociate}_entry() 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-mm@kvack.org, nvdimm@lists.linux.dev, linux-fsdevel@vger.kernel.org Date: Sat, 03 Sep 2022 19:16:58 -0700 Message-ID: <166225781800.2351842.4542681429835252305.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166225775968.2351842.11156458342486082012.stgit@dwillia2-xfh.jf.intel.com> References: <166225775968.2351842.11156458342486082012.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662257820; a=rsa-sha256; cv=none; b=7h2ly6GX97IPQZ7bOXt/8l6qITNIDxEmswqFUMuqrwHs5Gf7ClCuXRh+hfRrCua6OyJ+0h xyuPm+cGq3b4KCRdKpu9DPe8xEnC/ewbMYFdKY30Go2WT2fsMyB/9Le+TS9EFPDNLGoQD8 m3xLQlOksZUDyrqilFQ1khlnTvYVQQs= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Es4qupQN; spf=softfail (imf06.hostedemail.com: 192.55.52.120 is neither permitted nor denied by domain of dan.j.williams@intel.com) smtp.mailfrom=dan.j.williams@intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662257820; 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=nau4jCbY8zYXDsjg0lWLMSS2xXdrAFw9g+oAIu7ziOc=; b=CxhCjKnsR0DjzpxWMLww2aj/IOfZSmhB+kOTk+LTu9B6b8m8HHMYlPw+OmW2UT87lfAsbZ JJRobXNfwfiYxYyRpBR4z36vNIiwLqiIlsITEhLA9O4apd+VfdfsL/zeGCLLjOI7o1qZHh RReGFOAO4Vw2qB95mTUIrr1iDHEVuQ0= X-Rspam-User: X-Stat-Signature: qfty3afa7345o6o7unfyxjzi693mia8q X-Rspamd-Queue-Id: 24650180052 X-Rspamd-Server: rspam10 Authentication-Results: imf06.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=Es4qupQN; spf=softfail (imf06.hostedemail.com: 192.55.52.120 is neither permitted nor denied by domain of dan.j.williams@intel.com) smtp.mailfrom=dan.j.williams@intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-HE-Tag: 1662257819-181237 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: 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. 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 | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index 3ed4da3935e5..2dcc8744277d 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -10,6 +10,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 0810af7d9503..6bd38ddba2cb 100644 --- a/drivers/dax/mapping.c +++ b/drivers/dax/mapping.c @@ -351,6 +351,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 { @@ -358,6 +360,13 @@ static vm_fault_t dax_associate_entry(void *entry, page->mapping = mapping; page->index = index + i++; } + + /* + * page->mapping and page->index are only manipulated on + * head pages + */ + if (PageHead(page)) + break; } return 0; @@ -380,6 +389,8 @@ 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); + WARN_ON_ONCE(trunc && page_maybe_dma_pinned(page)); if (dax_mapping_is_cow(page->mapping)) { /* keep the CoW flag if this page is still shared */ @@ -389,6 +400,13 @@ static void dax_disassociate_entry(void *entry, struct address_space *mapping, WARN_ON_ONCE(page->mapping && page->mapping != mapping); page->mapping = NULL; page->index = 0; + + /* + * page->mapping and page->index are only manipulated on + * head pages + */ + if (PageHead(page)) + break; } }