Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5499176ybi; Tue, 30 Jul 2019 22:15:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKMHL91C8iGYlx/I6saAnBJCbwaYeGwAtqk6ubZVhKcLW0pF8P2/r1fMmhzaiamwsah11Q X-Received: by 2002:a62:764d:: with SMTP id r74mr47237122pfc.110.1564550109518; Tue, 30 Jul 2019 22:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564550109; cv=none; d=google.com; s=arc-20160816; b=diXaJogeTNPoMac5FcfcXX1Ewq11Unp2DnhbrOryLqmSNcg+rZJfSo/U214Oek/MAz WTqB8mS7/VpB+PCMM+6JJp951LDNP/hcLr2RE60AZ7COMNvjJyxE3kDW81DyBUGYYt+b vZNJxciQ1QSDa+M9xqsojk1IignjQtmYNaTcV49iM88foYhAVxE/kybBdrZS/lEaCOod FD3QI+kuOmpdPPCFKE+TrXBtV0KBi64f3mcSz9GZWVbIUovqIbxEjKmSrhnD03iOhYGP aPvshFh8wWWVcZMas3yUEoAw/fpyIKgX34+3n4PdqvcT0P39uSgLYFmicZg/Baclllnd y/pw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=OHyHSrA6JVDY2Oejcs6WpJIunzrly1fjS6RVFY7YqjM=; b=ADQSQhkyyEYE7O4Gg2++lGrZ2D6IBbQ3K1SNOhAhuJDieo41JwrYlIAKvU2e4RLeVv xURy9fj3I4+nU0sg5LUylVbM6Yi4kgE+ArS6V1e/WobWd4l0fyYada4MBwH6/ErphgWk bZVWGrnKmtWiJ7hoWmlHiKJMoFndfCFYpX6VVtquaHLR2tf1ltjb/lzj8atmn/PwWr9Y Zd1QxizEIS+fP9JzgncY7BXwSjNvIsGmmR5QxATSs/Hio6tBhA0VDgP7vU6U9tk9/NG5 J1xI1VP6OHFNOx+HCeHnq+/PlVlBanT7O9Vs7sp/ob51EMGVHEGEGTZnyl/8hWVV1tH/ UoUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=ajEzn9uW; 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 p9si14880957pgk.304.2019.07.30.22.14.54; Tue, 30 Jul 2019 22:15:09 -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=ajEzn9uW; 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 S1727309AbfGaBBP (ORCPT + 99 others); Tue, 30 Jul 2019 21:01:15 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:8983 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727136AbfGaBBO (ORCPT ); Tue, 30 Jul 2019 21:01:14 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 30 Jul 2019 18:01:23 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 30 Jul 2019 18:01:14 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 30 Jul 2019 18:01:14 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 31 Jul 2019 01:01:11 +0000 Subject: Re: [PATCH 08/13] mm: remove the mask variable in hmm_vma_walk_hugetlb_entry To: Christoph Hellwig , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs , Felix Kuehling CC: , , , , References: <20190730055203.28467-1-hch@lst.de> <20190730055203.28467-9-hch@lst.de> X-Nvconfidentiality: public From: Ralph Campbell Message-ID: <5f8e6310-5e97-3e57-bfbf-5eef553b4d91@nvidia.com> Date: Tue, 30 Jul 2019 18:01:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190730055203.28467-9-hch@lst.de> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1564534883; bh=OHyHSrA6JVDY2Oejcs6WpJIunzrly1fjS6RVFY7YqjM=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=ajEzn9uWQgkCJeHEaoBa1ebIKX456rMGd39kWLEC/7A9cOmd9kLxD/rfHhXnnzvtr p8dxFxMmc9Ht+btkwqvj95qMs6DnmoOqgpiDmTYwV4dQWlBWsw5Les1qXHiV0VM+pc 6eLW+qk0O9HGG/H3cFIxfLKOcWS5roJB4JnQLeWEgBgvU0eJQEGHKIwFkwqHg8yEvK UqHAkGFEpMKcWKCnqFErM2grwMv5QR13mPLqhQIdIi6Nq4GCA2AI47+gTlrUlw3Bz/ teNwUz4zv3BXuhvbEzfoJagndrzFIMXS9QDwkJi6PrOjJJZYCP5Xb7mMbAmAJq3QId Pp062/GoAjfpg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/29/19 10:51 PM, Christoph Hellwig wrote: > The pagewalk code already passes the value as the hmask parameter. > > Signed-off-by: Christoph Hellwig > --- > mm/hmm.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/mm/hmm.c b/mm/hmm.c > index f26d6abc4ed2..88b77a4a6a1e 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -771,19 +771,16 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, > struct mm_walk *walk) > { > #ifdef CONFIG_HUGETLB_PAGE > - unsigned long addr = start, i, pfn, mask; > + unsigned long addr = start, i, pfn; > struct hmm_vma_walk *hmm_vma_walk = walk->private; > struct hmm_range *range = hmm_vma_walk->range; > struct vm_area_struct *vma = walk->vma; > - struct hstate *h = hstate_vma(vma); > uint64_t orig_pfn, cpu_flags; > bool fault, write_fault; > spinlock_t *ptl; > pte_t entry; > int ret = 0; > > - mask = huge_page_size(h) - 1; > - > ptl = huge_pte_lock(hstate_vma(vma), walk->mm, pte); > entry = huge_ptep_get(pte); > > @@ -799,7 +796,7 @@ static int hmm_vma_walk_hugetlb_entry(pte_t *pte, unsigned long hmask, > goto unlock; > } > > - pfn = pte_pfn(entry) + ((start & mask) >> PAGE_SHIFT); > + pfn = pte_pfn(entry) + ((start & hmask) >> PAGE_SHIFT); This needs to be "~hmask" so that the upper bits of the start address are not added to the pfn. It's the middle bits of the address that offset into the huge page that are needed. > for (; addr < end; addr += PAGE_SIZE, i++, pfn++) > range->pfns[i] = hmm_device_entry_from_pfn(range, pfn) | > cpu_flags; >