Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp626590ybl; Fri, 9 Aug 2019 11:05:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzB6BJm120jy1s3usJ4kVQW2UEOL+p3PcnOuCxvscGVe/hsRawd0rEkzqXQx7kWgqK6rawV X-Received: by 2002:aa7:9591:: with SMTP id z17mr23030282pfj.215.1565373952529; Fri, 09 Aug 2019 11:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565373952; cv=none; d=google.com; s=arc-20160816; b=zAingta/zTKgh76xTNJfR3BS4Po8Y0lMSb9jgLxafMD+EgkZvzNmTeS0AguJRAsRhg VXLg8UsKWuYXVbQByTg/x2rtS/kx1DcAHhyVV2uwf8QoSw3a8l+zRR7HW22FFej7TOKm Yw2p4LY3JHsS9CNDLT5bbm/qT8rzBezgAeQMOk7euQh6wwLHuMqByiPbHovHGEnNJ5dI zD5s3s0lJG3e8qCVixZ5V/pvftBud5Puori5G+DU+GOIqWkX32QH6aL2P/wCk/mxGZFw cPOyLmuz4oOzEhTgpFjBr+JeDczc8P6bOcdNHQ34J3BiIDuTgSGjUmB8ahk4z1tdfSfd nTOw== 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=g0FmRWOVSQw+ovYa/Gu5Q2BPMATNeZLwtOFaVN9ZPw0=; b=G1mFYOoSlocT64+2xD40VTxbi/lEYTJA4din+Mn6DtQ8dvRteMJdZwBMP3Jwf1BLXT qjC91lULHJ07XIn34mx/XQemLOQU6HYi3HOmg0feeH0P6hlBP4n5RQgIKjch6SutHoKa Jz9+vLxdBZViWaYRm7ABu5nHaJO7GjKOnRuO6ztnUA5fE5/TVI+QDmGwh1aQraj7ZKq6 ZWO3kih077Jw2fvtngfaHGumYSy3TyrIjBe3KaqUVR91HxIjnq5bZ15kv1/jeQJMXYhe mVwal6mmlY0vJ6AOMpGtNRaiRne5NpxVoDad5dEAiMOQKfjvwG0VxRoB0zMuqOY7uMAY 7g8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b="Lm48/h4n"; 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 s66si59509739pfs.120.2019.08.09.11.05.36; Fri, 09 Aug 2019 11:05:52 -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="Lm48/h4n"; 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 S2437205AbfHISEs (ORCPT + 99 others); Fri, 9 Aug 2019 14:04:48 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:13666 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfHISEr (ORCPT ); Fri, 9 Aug 2019 14:04:47 -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, 09 Aug 2019 11:04:48 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 09 Aug 2019 11:04:47 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 09 Aug 2019 11:04:47 -0700 Received: from [10.2.165.207] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 9 Aug 2019 18:04:46 +0000 Subject: Re: [Linux-kernel-mentees][PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions To: Bharath Vedartham CC: , , , , , , , , , References: <1565290555-14126-1-git-send-email-linux.bhar@gmail.com> <1565290555-14126-2-git-send-email-linux.bhar@gmail.com> <20190809094406.GA22457@bharath12345-Inspiron-5559> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Fri, 9 Aug 2019 11:03:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190809094406.GA22457@bharath12345-Inspiron-5559> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) 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=1565373888; bh=g0FmRWOVSQw+ovYa/Gu5Q2BPMATNeZLwtOFaVN9ZPw0=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=Lm48/h4n/E5d/oO1iuhNqiTdYfI3bWD99pXlSulIAVr+7+NFRBRx04unypjYa1LXI Qu4NX+U659GBezGwaMcDXMJU0olVDQx+bBlgV+unRtfatA4yS2dWJxVAXe/iowCU4x 0GAz9g4BgSU+xFpBfQVrsgoJPYC5iS30AC3Opk/9+2XoJDfHTPY12Ub/9+JxFl6irE KcsFlVYTcES6cGUQKT3HWrC/e0R6pQqwaF3SLlUyeXHHoS6q3AkNvxCzBgk8SbSyTj pO7Z0ED/1Dy0mBD1w54rbULkdwFKXtgUu6IGkQ7U0H1qrJd68vPLFJvdGloq1H30oh sfUnjNFy9oqKA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/9/19 2:44 AM, Bharath Vedartham wrote: > On Thu, Aug 08, 2019 at 04:21:44PM -0700, John Hubbard wrote: >> On 8/8/19 11:55 AM, Bharath Vedartham wrote: >> ... >>> static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr, >>> int write, int atomic, unsigned long *gpa, int *pageshift) >>> { >>> struct mm_struct *mm = gts->ts_mm; >>> struct vm_area_struct *vma; >>> unsigned long paddr; >>> - int ret, ps; >>> + int ret; >>> + struct page *page; >>> >>> vma = find_vma(mm, vaddr); >>> if (!vma) >>> @@ -263,21 +187,33 @@ static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr, >>> >>> /* >>> * Atomic lookup is faster & usually works even if called in non-atomic >>> - * context. >>> + * context. get_user_pages_fast does atomic lookup before falling back to >>> + * slow gup. >>> */ >>> rmb(); /* Must/check ms_range_active before loading PTEs */ >>> - ret = atomic_pte_lookup(vma, vaddr, write, &paddr, &ps); >>> - if (ret) { >>> - if (atomic) >>> + if (atomic) { >>> + ret = __get_user_pages_fast(vaddr, 1, write, &page); >>> + if (!ret) >>> goto upm; >>> - if (non_atomic_pte_lookup(vma, vaddr, write, &paddr, &ps)) >>> + } else { >>> + ret = get_user_pages_fast(vaddr, 1, write ? FOLL_WRITE : 0, &page); >>> + if (!ret) >>> goto inval; >>> } >>> + >>> + paddr = page_to_phys(page); >>> + put_user_page(page); >>> + >>> + if (unlikely(is_vm_hugetlb_page(vma))) >>> + *pageshift = HPAGE_SHIFT; >>> + else >>> + *pageshift = PAGE_SHIFT; >>> + >>> if (is_gru_paddr(paddr)) >>> goto inval; >>> - paddr = paddr & ~((1UL << ps) - 1); >>> + paddr = paddr & ~((1UL << *pageshift) - 1); >>> *gpa = uv_soc_phys_ram_to_gpa(paddr); >>> - *pageshift = ps; >> >> Why are you no longer setting *pageshift? There are a couple of callers >> that both use this variable. > Hi John, > > I did set *pageshift. The if statement above sets *pageshift. ps was > used to retrive the pageshift value when the pte_lookup functions were > present. ps was passed by reference to those functions and set by them. > But here since we are trying to remove those functions, we don't need ps > and we directly set *pageshift to HPAGE_SHIFT or PAGE_SHIFT based on the > type of vma. > > Hope this clears things up? > Right you are, sorry for overlooking that. Looks good. thanks, -- John Hubbard NVIDIA