From patchwork Wed Jul 4 21:40:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10507633 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 620E5602BC for ; Wed, 4 Jul 2018 21:50:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5860228DA2 for ; Wed, 4 Jul 2018 21:50:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CEB728DAB; Wed, 4 Jul 2018 21:50:49 +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 D9FF928DA2 for ; Wed, 4 Jul 2018 21:50:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCF006B0010; Wed, 4 Jul 2018 17:50:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C7DFC6B0266; Wed, 4 Jul 2018 17:50:47 -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 B94F56B0269; Wed, 4 Jul 2018 17:50:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f72.google.com (mail-pl0-f72.google.com [209.85.160.72]) by kanga.kvack.org (Postfix) with ESMTP id 91D1D6B0010 for ; Wed, 4 Jul 2018 17:50:47 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id s3-v6so460767plp.21 for ; Wed, 04 Jul 2018 14:50:47 -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=EQDufybVCAJcCn6LK6mWfblSUCoXXSZOigO5JO3c188=; b=a6mfw/SAcu0UuG62FkQTPfOxJs0vMgPzDjqv4vwnXo9WW27ddFsXZv3UstOUKYmrMA O7Xo+4MofGgZWsKNoriHn7EY/ZEvJPJK0ZdxxUlrGnYi5oPZXPCzMSok3plSxB95DkVw KW++C0hhSijZAhNw4EcS0Q97TmqJrYLiFqoaYZZHr2GtbKVxaIjH2ixRbFT+JwLmVVQG 1uXz+D1dsOSFq/j0F8WxGGRcNLlTrTDKqOncvSzFWnftMtzEI7sR2uNc7w0xQz9/HJVH ffyFOYk7lW6k3FfOTxKzBFnI0V39VNi9+GE9Ix4VArhXtwUc77doTcHF/y5mHuiRijG7 9EKw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.24 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: APt69E1bb5DJ5ho66L+9cyAIqQBOfkFNB9XnSJ9/oF9JYz9efqggzdOV LsQvvStHRlur4hocaj/5sBeP7PF/1HIR8PFMc4fqnKo4r+ubaJr3yN88NkiFABN0aFL/yTXhMVv GC5D/Leq05omXRu7V8cctjFseC3jZQJppdyMXdAy8QrL2vDulk2TpKioQqWg7MtebRQ== X-Received: by 2002:a17:902:201:: with SMTP id 1-v6mr3649049plc.310.1530741047300; Wed, 04 Jul 2018 14:50:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeaSTcwrSvZRxRML5Tik4w8q/atGv1qy0QnPUFVioAaxvxQnXbeY4rp7sncWazGeG217IZz X-Received: by 2002:a17:902:201:: with SMTP id 1-v6mr3649028plc.310.1530741046502; Wed, 04 Jul 2018 14:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530741046; cv=none; d=google.com; s=arc-20160816; b=V3Cqq5Ct6cXrRP1cUn7wtVR0kd4ign4a5gnNox1iqzLzlTsrHPuSRRI5bghePs/e/h RnI/hioeDMSwvkcuGbTvtwmx3mMwWe7KFNk6NQhlKEoMnx8/u1jxj0OE8YK4Qi5EitA/ q/g4pIlTaEnmS5BgQSMBeYNpglis61SldAirkMWQP/s82SpA/2aoQttKF6nixpAVc6wv sum/2T0NigbMX+5tw4uz5RNUkYrdZu/lBa0//hZvfmNmsdvi+Cz3w2EAD++fzhm3EcDX CKcQT8gh0UfooxYYYzqeMF8GIFSfvotoC0JphMPcMsWEw8zJI8ohG7+rCra1qvtu9M9D 6P+g== 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=EQDufybVCAJcCn6LK6mWfblSUCoXXSZOigO5JO3c188=; b=Yp2z/iEkHrW1v+wxHdfTV0OYGCwm0pkbBMhdszARWwHS7DW8TCrHz7h10/RLmCloyG FWXT4n5ZtH/9sXQDnllTXGFNMzIBjC74PCpbVRZpbH+xmGZjLVgNWmaNmKWL1vHFx3ZY SttM+fK41gm4v/sEQ53JyTfSoDA+Q+ykZ/VHZjxOaJrio5oJy7teqtmt3IFyQsJ/lcDv 9y9q8+nUfM93CGfqNJPA/pfEDMuKAyjVcMRLdFX1dj/pFv72h553vFyZx7bsnX4DtE7d +iK1bDR5jsWSWvPMQfCFLRLykEw35hry1ng41f0B0BcA2tEXHKMu2WCCmywaU+wmgJur WPkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id i66-v6si4770331pfb.149.2018.07.04.14.50.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 14:50:46 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.24 as permitted sender) client-ip=134.134.136.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.24 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 fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 14:50:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,309,1526367600"; d="scan'208";a="52057511" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga007.fm.intel.com with ESMTP; 04 Jul 2018 14:50:36 -0700 Subject: [PATCH v5 03/11] device-dax: Set page->index From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Jan Kara , hch@lst.de, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jack@suse.cz, ross.zwisler@linux.intel.com Date: Wed, 04 Jul 2018 14:40:39 -0700 Message-ID: <153074043918.27838.10612469015732111514.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153074042316.27838.17319837331947007626.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 In support of enabling memory_failure() handling for device-dax mappings, set ->index to the pgoff of the page. The rmap implementation requires ->index to bound the search through the vma interval tree. The ->index value is never cleared. There is no possibility for the page to become associated with another pgoff while the device is enabled. When the device is disabled the 'struct page' array for the device is destroyed and ->index is reinitialized to zero. Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- drivers/dax/device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 95cfcfd612df..361a11089591 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -416,6 +416,7 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, if (rc == VM_FAULT_NOPAGE) { unsigned long i; + pgoff_t pgoff; /* * In the device-dax case the only possibility for a @@ -423,6 +424,8 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, * mapped. No need to consider the zero page, or racing * conflicting mappings. */ + pgoff = linear_page_index(vmf->vma, vmf->address + & ~(fault_size - 1)); for (i = 0; i < fault_size / PAGE_SIZE; i++) { struct page *page; @@ -430,6 +433,7 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, if (page->mapping) continue; page->mapping = filp->f_mapping; + page->index = pgoff + i; } } dax_read_unlock(id);