Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2257449yba; Fri, 19 Apr 2019 15:39:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7Bmt142Ab+UBepgayx3lg14mDyLN8pqMKo8asJSRq4ZzeYIZXrOoUuXZmbsAHv5owSW41 X-Received: by 2002:a17:902:da4:: with SMTP id 33mr4465566plv.20.1555713580780; Fri, 19 Apr 2019 15:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555713580; cv=none; d=google.com; s=arc-20160816; b=GP9moJ9Uqalo69nco4eQvn2BtruJIdEQiEwqd7G2oHTX24mQEBbFH2j5nHM3P3TOvv SKy/yH9aadlb6zgVEhxzvUGmY9rQBj9XLYxB5RfV7AI8dMR5diAjrEqOIDF/gnWDdMFs HaTduGY0SOUWNSO7xDeIGSeS8Golgz8gRHc0cdQbGk1u9mFdREEI7Z7guTbnyWJSVqZa nTqY+56+CnIsqpTBqb6f6vMwo36zhN6h/yH8BRwdEnj0P9DApF4ht13aRaUTbkG8tOLA yWPwCOyj/ATq5pKe0IEMzo+cpt4VxA/eA8m0Ink7Wj1WNVrctcCT66KmvJN+my/pLXmL OeyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=CfvcO8vti3twykYANcJx0ucggxeHBxOuIW3oPk1HmoU=; b=OT7pKiU7Nct2hqxXdbgUxSwmDva3ZaAwVtN2+eCaVq2GTexTJcg+WC6iwLCLTlCiuo nI2KPu82SW6OvJAG/gC0+snbSs9sQPMihCn4TKc67EdJ6REupon+/TXiJu1kxD111M0l elUQsYdotdUd3EiYEvQdk2fcTVT/Ml+QpbqSiyGfOrX16/F+C8XJS7Fssb7BSM9DcDz1 lYsPzhvMKs6vihaheR5Mfk8YwzsqMmMzYHp0oWl0z3g5LLyzQIm3AAQvZPuGtWEGew1s 4odybyfTzQvveamzFwfXj+q8Lsf+PbDmJmh/s17MsrusVfOy83r8bxbP1Vl1Z9XQOm4b jD6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=kOm0J+Kg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15si6442352pff.225.2019.04.19.15.39.25; Fri, 19 Apr 2019 15:39:40 -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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=kOm0J+Kg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727261AbfDSWiE (ORCPT + 99 others); Fri, 19 Apr 2019 18:38:04 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:5390 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbfDSWiE (ORCPT ); Fri, 19 Apr 2019 18:38:04 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 19 Apr 2019 15:38:00 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 19 Apr 2019 15:38:03 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 19 Apr 2019 15:38:03 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Apr 2019 22:38:03 +0000 From: To: CC: , Ralph Campbell , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Ira Weiny , John Hubbard , Dan Williams , Arnd Bergmann , Balbir Singh , Dan Carpenter , Matthew Wilcox , Souptick Joarder , Andrew Morton Subject: [PATCH] mm/hmm: Fix initial PFN for hugetlbfs pages Date: Fri, 19 Apr 2019 15:37:37 -0700 Message-ID: <20190419223737.32111-1-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-NVConfidentiality: public X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1555713480; bh=CfvcO8vti3twykYANcJx0ucggxeHBxOuIW3oPk1HmoU=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: MIME-Version:X-NVConfidentiality:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Transfer-Encoding; b=kOm0J+KgvDsPnBZeSkNYUddnrw3GrVqFzCacV1dt8vP42r+Y6gsj6V9tpSVvRjGTW VB2ijDvwWXCcmZeoTeEWHDnTAfjvcl9LZ1JfxnSDNkqhzo+hssgI39Aw7h4x5PBC1J U26+ZSkNNF3G/Ol88gOvGDS5XlKQvQlc1QB1Kesc59DaNpx5O9DxGdVu5uGnPXSwO9 cbeQQjFvAZkbyuJ+dP/Df+FC68qquvmDNtX5t4Dj7zULYRe3Be3eWf1Wb5HAOIFlya Fshk5mw9Z6U201bTFUF9uYcTkVxxZpUOBNgBljSkJkDIU6XScASiJpSQtocR7TTFSb 7jwIqZbEd9hug== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ralph Campbell The mmotm patch [1] adds hugetlbfs support for HMM but the initial PFN used to fill the HMM range->pfns[] array doesn't properly compute the starting PFN offset. This can be tested by running test-hugetlbfs-read from [2]. Fix the PFN offset by adjusting the page offset by the device's page size. Andrew, this should probably be squashed into Jerome's patch. [1] https://marc.info/?l=3Dlinux-mm&m=3D155432003506068&w=3D2 ("mm/hmm: mirror hugetlbfs (snapshoting, faulting and DMA mapping)") [2] https://gitlab.freedesktop.org/glisse/svm-cl-tests Signed-off-by: Ralph Campbell Cc: J=C3=A9r=C3=B4me Glisse Cc: Ira Weiny Cc: John Hubbard Cc: Dan Williams Cc: Arnd Bergmann Cc: Balbir Singh Cc: Dan Carpenter Cc: Matthew Wilcox Cc: Souptick Joarder Cc: Andrew Morton --- mm/hmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hmm.c b/mm/hmm.c index def451a56c3e..fcf8e4fb5770 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -868,7 +868,7 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsig= ned long hmask, goto unlock; } =20 - pfn =3D pte_pfn(entry) + (start & mask); + pfn =3D pte_pfn(entry) + ((start & mask) >> range->page_shift); for (; addr < end; addr +=3D size, i++, pfn +=3D pfn_inc) range->pfns[i] =3D hmm_device_entry_from_pfn(range, pfn) | cpu_flags; --=20 2.20.1