Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2573878imm; Mon, 16 Jul 2018 10:12:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf3+RroZHg6NR/E4wz7cLxAd8LEJiXVWMmXm45UwgjhRtgHW49qMby1LGHCEIaDJbys9GPP X-Received: by 2002:a63:6383:: with SMTP id x125-v6mr16197870pgb.127.1531761144828; Mon, 16 Jul 2018 10:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531761144; cv=none; d=google.com; s=arc-20160816; b=lwnIgtmClmaIXlO20JgdEvkGtOTCUN2P09mBUw8EVqSVFc2c32KHyK6vmIVRgm7tjD 8LZk8Kn8ECeCLaTavu6pgMJ6tX7FyVLxhF+lWrG3E/2nMKDXvSKF5ZQKd6eqCIFyVgo0 2RWnzQmu9faJOFIRKVCMUD5URcQsFZjuZ7xgyGcGegVhwbYpl5RnozJvPpcAWucoT+w9 BEPnYTRJl0ifzi8IHGsgtKd/GclYp+EOJRTy9v8omMZskeTR5OWWEYdkxy3hEtu10r6a FoGd70ZEERdZNZWqgLEoxPmTbDzaJnPvxp8RhprXYyD2e8vUdW7MSKnWOXBjC6XDIdPM Q8qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=sTne5hZAu31rl4EuvGi6sNOrobikp18DBXX42xDXRJ4=; b=0Xl+6wtFqXh2FYoav5qlsumNnYvQ/4pNQv9uRVVv/4/OCQvCOTG2V5QcJ3huh2jyt9 lvyNpGmIPqHtMvvj1fjrilCp5wf4diP8NplMygVgmwcSARZs3w0l4jQfU/zJg3R/zeEg esHHJDkTvLIsjjmLF5xlTRSiwteHHaYjTOJsVeAMTkE+5lB2ePjt464mbfZvGUPPN+hZ /H86kSPJH41/Dv5hKqj+Ah/E321S/YKurmtJ2IukpXf0dXqJKvCvRIZzdQfPeEUE8wJm mRgruAQw0YxUBSeXY/JsUOPJtlIt8N3NBeH9n7nlDeCDQfF8uI/wmcV5BRXInRFjpFIS e8RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 194-v6si17367206pfz.101.2018.07.16.10.12.09; Mon, 16 Jul 2018 10:12:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730002AbeGPRjV (ORCPT + 99 others); Mon, 16 Jul 2018 13:39:21 -0400 Received: from mga02.intel.com ([134.134.136.20]:43956 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbeGPRjU (ORCPT ); Mon, 16 Jul 2018 13:39:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 10:11:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,362,1526367600"; d="scan'208";a="246149807" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga006.fm.intel.com with ESMTP; 16 Jul 2018 10:11:01 -0700 Subject: [PATCH v2 08/14] tools/testing/nvdimm: Allow a NULL-pfn to ->direct_access() From: Dan Williams To: akpm@linux-foundation.org Cc: Huaisheng Ye , Jan Kara , vishal.l.verma@intel.com, hch@lst.de, linux-mm@kvack.org, jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Mon, 16 Jul 2018 10:01:03 -0700 Message-ID: <153176046336.12695.10183072594003102353.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huaisheng Ye The mock / test version of pmem_direct_access() needs to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate the value. This is in support of asynchronous memmap init and avoid page lookups when possible. Suggested-by: Dan Williams Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- tools/testing/nvdimm/pmem-dax.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index b53596ad601b..d4cb5281b30e 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -33,7 +33,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); - *pfn = page_to_pfn_t(page); + if (pfn) + *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", __func__, pmem, pgoff, page_to_pfn(page)); @@ -41,7 +42,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, } *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the