From patchwork Mon Jul 16 17:01:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10527253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D621560348 for ; Mon, 16 Jul 2018 17:11:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF94928D80 for ; Mon, 16 Jul 2018 17:11:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3B5B28D8F; Mon, 16 Jul 2018 17:11:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481D628D80 for ; Mon, 16 Jul 2018 17:11:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AA046B0271; Mon, 16 Jul 2018 13:11:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 45AD26B0272; Mon, 16 Jul 2018 13:11:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 371EB6B0273; Mon, 16 Jul 2018 13:11:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id EC0EF6B0271 for ; Mon, 16 Jul 2018 13:11:02 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id y8-v6so4046515plp.17 for ; Mon, 16 Jul 2018 10:11:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=sTne5hZAu31rl4EuvGi6sNOrobikp18DBXX42xDXRJ4=; b=e7IZVIkQjC7Aq1+OysqKGCvAO6z6WFTbMpsMkGXbkpLJXQ6oJRbd/2Syx1xsszwjzB k9nToK8T9yU8G4mXoutK9AGUsNJRFcgr4sNJNDzfKKrx4NRwzqsSTkIXGPClABQ0ECAH WHvIdpjC3jH0NNhxfyevh0pgHLYkOBQkWNChhGsguOjVm4UsYs6ZCVTOjZLFdpLGJ4Ys RWEmVzSCVO5nlyzPyg3e5/5Y28qbATIbBdyh6CBQIyYzbDrb7QYFl/bLl9OMSqsqlDeY 0P/Z43VXWOcVI91+LmIVEaVU5Vpq+Emhhf6iFGFzz76pInnuGEunUvANi8NDQ2cnbiJc L/9w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlGXF+tS/JW56rXdRucFk+9y+yutygs8czkUMELlDtIkQBuB+RGK Ul3UmibN8dJmCGWuNW94eLJDgtN+Ff18qn6mYwldC0VZJFT+Q8KbO8ywNfzfItvoqNAb8m+QknZ U9jBDEG7+4Y5xERUAMoMvn6QxKG4ROqY88E1HgWSUYXIMIgaczAf8MHiNUaY6P6sq6Q== X-Received: by 2002:a17:902:7898:: with SMTP id q24-v6mr17234803pll.254.1531761062658; Mon, 16 Jul 2018 10:11:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/ZlARVv4kRDggWMLwaj3Rbs7pE3Vxx6oVSh6UNwgTrajuq200dJ2JAkQ13nuf9HYGnRw0 X-Received: by 2002:a17:902:7898:: with SMTP id q24-v6mr17234760pll.254.1531761061953; Mon, 16 Jul 2018 10:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531761061; cv=none; d=google.com; s=arc-20160816; b=dlXRSvWMYhojx+p8m22t9kK4cgjdjBpW53IDBvPJC7M76MnH+jc1H12zPJr9A/DkZ2 dsakXEd86lAGqG9LEZXuXj3/a4J1rkI4l8lNfvAxBtkU4pQPpMhesHnGDfTDQpiHP2Jg hdT6nX1p/BhaGf5/RPD+kujqme8LLxhendIPaJvXZ2MOGIvYLqCEnS8Dwa7azo6QslQD huq6OM5NoQd9JZJP5ddDGAyx9q/9qtnOQCxOttkJdhSMMi8GRpfPS7uAKlfTTUMSkTfN QQveDyvQR5aut4T1thWt554y8SE4eeGurXA2zWZTuoQyVLFRlV+w+L/NW/sWJR+NB1tt capA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=sTne5hZAu31rl4EuvGi6sNOrobikp18DBXX42xDXRJ4=; b=eWD1VNAxKEO5lqgPm8YBEs3OIieiLhiHRsYzsmlTewcqJGYYE5Emr7i63fQbSHJmS8 3hrpMRjpA5JFajeLshABjlKlc9x9cFyCcm1LZTrI7xmLZ7lPjwfKup8pFNoFiCYjCrIH j4VM/rIYgR4wj6vy+qDm3Y8x3GgWk//V2CZOj9tjBEzDUTsOIKVfnk4SVMu1MpCbEvbG oGLgSHYMM9UxoiyZyrSRHE44vGjNN6Y74FWaiqkVWzAj1bmN9XSuXG9ek/iYOVlb2IHj ah8BdV3fQxTagKWSrliPdHffyeYbGJhYGw0y+GuTfpvBr9EEGkPm9JF5unQbEPir7OAo sHaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id l33-v6si30786029pld.514.2018.07.16.10.11.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 10:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.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 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: X-Virus-Scanned: ClamAV using ClamSMTP 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